Skip to content

Commit ed34cd5

Browse files
committed
Remove String from AudioPlayer
1 parent 3450f26 commit ed34cd5

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/AudioTools/AudioPlayer.h

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,17 @@ namespace audio_tools {
3939
/// Returns next audio stream
4040
virtual Stream* nextStream(int offset) = 0;
4141

42+
/// Returns previous audio stream
43+
virtual Stream* previousStream(int offset) {
44+
return nextStream(-offset);
45+
};
46+
4247
/// Returns next audio stream
4348
virtual Stream* selectStream(int index) {
4449
LOGE("Not Supported!");
4550
return nullptr;
4651
}
4752

48-
/// Returns previous audio stream
49-
virtual Stream* previousStream(int offset) = 0;
50-
5153
/// Provides the timeout which is triggering to move to the next stream
5254
virtual int timeoutMs() {
5355
return 500;
@@ -156,6 +158,9 @@ namespace audio_tools {
156158
LOGD(LOG_METHOD);
157159
// move to next file
158160
pos += offset;
161+
if (pos<0){
162+
pos = 0;
163+
}
159164
file.close();
160165
file = getFile(start_path, pos);
161166
file.getName(file_name, MAX_FILE_LEN);
@@ -167,7 +172,7 @@ namespace audio_tools {
167172
file.close();
168173
file = getFile(start_path, index);
169174
file.getName(file_name, MAX_FILE_LEN);
170-
LOGI("-> nextStream: '%s'", file_name);
175+
LOGI("-> selectStream: '%s'", file_name);
171176
return file ? &file : nullptr;
172177
}
173178

@@ -281,7 +286,7 @@ namespace audio_tools {
281286
if (pos < 1 || pos > max) {
282287
pos = 1;
283288
}
284-
LOGI("nextStream: %d -> %s", String(pos) + "/" + String(max), urlArray[pos-1]);
289+
LOGI("nextStream: %d/%d -> %s", pos, max, urlArray[pos-1]);
285290
if (offset != 0 || actual_stream == nullptr) {
286291
if (started) actual_stream->end();
287292
actual_stream->begin(urlArray[pos-1], mime);
@@ -302,7 +307,7 @@ namespace audio_tools {
302307
pos = max;
303308
LOGI("url array out of limits: %d -> %d", Station, pos);
304309
}
305-
LOGI("selectStream: %s -> %s", String(pos) + "/" + String(max), urlArray[pos-1]);
310+
LOGI("selectStream: %d/%d -> %s", pos, max, urlArray[pos-1]);
306311
if (Station != 0 || actual_stream == nullptr) {
307312
if (started) actual_stream->end();
308313
actual_stream->begin(urlArray[pos-1], mime);
@@ -317,7 +322,7 @@ namespace audio_tools {
317322
if (pos < 1 || pos > max) {
318323
pos = max;
319324
}
320-
LOGI("previousStream: %s -> %s", String(pos) + "/" + String(max), urlArray[pos-1]);
325+
LOGI("previousStream: %d/%d -> %s", pos, max, urlArray[pos-1]);
321326
if (offset != 0 || actual_stream == nullptr) {
322327
if (started) actual_stream->end();
323328
actual_stream->begin(urlArray[pos-1], mime);

0 commit comments

Comments
 (0)