File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -123,6 +123,7 @@ class SnapOutput : public AudioInfoSupport {
123
123
// writes the audio data to the decoder
124
124
size_t audioWrite (const void *src, size_t size) {
125
125
ESP_LOGD (TAG, " %zu" , size);
126
+ time_last_write = millis ();
126
127
size_t result = decoder_stream.write ((const uint8_t *)src, size);
127
128
128
129
return result;
@@ -160,6 +161,15 @@ class SnapOutput : public AudioInfoSupport {
160
161
return result;
161
162
}
162
163
164
+ uint64_t getLastWriteTime () {
165
+ return time_last_write;
166
+ }
167
+
168
+ // / checks if the audio is still playing
169
+ bool isActive (uint16_t timeout=1000 ){
170
+ return (time_last_write + timeout) >= millis ();
171
+ }
172
+
163
173
protected:
164
174
const char *TAG = " SnapOutput" ;
165
175
AudioOutput *out = nullptr ;
@@ -175,6 +185,7 @@ class SnapOutput : public AudioInfoSupport {
175
185
SnapTimeSync *p_snap_time_sync = nullptr ;
176
186
bool is_sync_started = false ;
177
187
bool is_audio_begin_called = false ;
188
+ uint64_t time_last_write = 0 ;
178
189
179
190
// / setup of all audio objects
180
191
bool audioBegin () {
You can’t perform that action at this time.
0 commit comments