@@ -79,23 +79,17 @@ namespace audio_tools {
79
79
if (onStartCallback != nullptr ) onStartCallback ();
80
80
};
81
81
82
- // / Returns next stream
82
+ // / Returns next (with positive index) or previous stream (with negative index)
83
83
virtual Stream* nextStream (int offset) {
84
84
LOGD (LOG_METHOD);
85
85
return nextStreamCallback == nullptr ? nullptr : nextStreamCallback ();
86
86
}
87
87
88
- // / Returns selected audio stream
88
+ // / Returns selected audio stream
89
89
virtual Stream* selectStream (int index) {
90
90
return indexStreamCallback == nullptr ? nullptr : indexStreamCallback (index);
91
91
}
92
92
93
- // / Returns previous stream
94
- virtual Stream* previousStream (int offset) {
95
- LOGD (LOG_METHOD);
96
- return previousStreamCallback == nullptr ? nullptr : previousStreamCallback ();
97
- }
98
-
99
93
void setCallbackOnStart (void (*callback)()) {
100
94
onStartCallback = callback;
101
95
}
@@ -108,15 +102,11 @@ namespace audio_tools {
108
102
indexStreamCallback = callback;
109
103
}
110
104
111
- void setCallbackPreviousStream (Stream* (*callback)()) {
112
- previousStreamCallback = callback;
113
- }
114
105
115
106
protected:
116
107
void (*onStartCallback)() = nullptr ;
117
108
Stream* (*nextStreamCallback)() = nullptr ;
118
109
Stream* (*indexStreamCallback)(int index) = nullptr ;
119
- Stream* (*previousStreamCallback)() = nullptr ;
120
110
};
121
111
122
112
#ifdef USE_SDFAT
@@ -169,8 +159,12 @@ namespace audio_tools {
169
159
}
170
160
171
161
virtual Stream* selectStream (int index) {
162
+ pos = index;
163
+ if (pos<0 ){
164
+ pos = 0 ;
165
+ }
172
166
file.close ();
173
- file = getFile (start_path, index );
167
+ file = getFile (start_path, pos );
174
168
file.getName (file_name, MAX_FILE_LEN);
175
169
LOGI (" -> selectStream: '%s'" , file_name);
176
170
return file ? &file : nullptr ;
0 commit comments