Skip to content

Commit 7197022

Browse files
Update MicroBitAudio.isPlaying() to take into account initial silence. (#452)
1 parent 0eafa22 commit 7197022

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

source/MicroBitAudio.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,5 +263,10 @@ bool MicroBitAudio::isPlaying()
263263
uint32_t start = mixer.getSilenceStartTime();
264264
uint32_t end = mixer.getSilenceEndTime();
265265

266-
return !((start && t >= (start + CONFIG_AUDIO_MIXER_OUTPUT_LATENCY_US)) && (end == 0 || t < (end + CONFIG_AUDIO_MIXER_OUTPUT_LATENCY_US - 100)));
267-
}
266+
return !(
267+
(start == 0 && end == 0) || (
268+
(start && t >= (start + CONFIG_AUDIO_MIXER_OUTPUT_LATENCY_US)) &&
269+
(end == 0 || t < (end + CONFIG_AUDIO_MIXER_OUTPUT_LATENCY_US - 100))
270+
)
271+
);
272+
}

0 commit comments

Comments
 (0)