Skip to content

Commit 8811b15

Browse files
committed
play_file example: check if all frames were played
1 parent cab9211 commit 8811b15

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

examples/play_file.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
import soundfile as sf
99

1010
filename = sys.argv[1]
11-
playback_blocksize = 256
12-
latency = 0
13-
reading_blocksize = 1024
14-
rb_size = 16 # Number of blocks, has to be power of two
11+
playback_blocksize = None
12+
latency = None
13+
reading_blocksize = 1024 # (reading_blocksize * rb_size) has to be power of 2
14+
rb_size = 16 # Number of blocks
1515

1616
with sf.SoundFile(filename) as f:
1717
with rtmixer.Mixer(channels=f.channels,
@@ -38,6 +38,7 @@
3838
if written < size:
3939
break
4040
m.wait(action)
41-
# TODO: check for ringbuffer errors
41+
if action.done_frames != f.frames:
42+
RuntimeError('Something went wrong, not all frames were played')
4243
if action.stats.output_underflows:
4344
print('output underflows:', action.stats.output_underflows)

0 commit comments

Comments
 (0)