Replies: 1 comment 1 reply
-
Internal to The likely reason you are having audio stutters is not this buffering. To ensure glitch-free playback you will need to have a decode thread that decodes audio as quickly as possible and then buffer the decoded audio into a ring buffer. Then, the audio playback thread will read decoded audio from this ring buffer. Typically, this ring buffer will be lock-free as well since the audio playback thread is real-time and should never be stalled for an unbounded period of time.
|
Beta Was this translation helpful? Give feedback.
-
I am still new to Symphonia, and i have been wondering what the approach to buffering a Media-Source should be, i have read that MediaSourceStream theoretically buffers somewhat, but on larger files it seems to actually not buffer much.
For example on a file with video + audio + metadata (which is around 62MiB and length about 2:58 (mm:ss)), it calls syscall read 4 to 6 times a second, which does not seem right. (and using a higher
MediaSourceStreamOptions
(4Mib) does not seems to affect anything)So i had tried making a
MediaSource
withBufReader
(4Mib) in-between, which reduced the times of syscall read on the same file to once every 5-6 seconds.Additionally on a smaller file audio + metadata (which is around 3.8Mib and length 2:15 (mm:ss)), it calls syscall read once every 2-3 seconds.
And on the
BufReader
implementation it only calls syscall read once.And seeking also seems to always have at least one syscall read (which should be to my understanding supported without syscall read)
System: Linux Manjaro
symphonia 0.5.1
the syscalls have been seen via
strace
Some more on the strace outputs
the following has been captured on the 62MiB file
No custom buffering (but using
MediaSourceStreamOptions { buffer_len: 1024 * 1024 * 4, }
)(32768 = 32 KiB)
whereas the bufreader does:
(4194304 = 4096 KiB (4Mib))
BufReader impl
i also encountered some hiccups in playback, but i am not sure if this is something wrong with the application or symphonia, but using the custom
BufRead
in-between seems to have at least lessened those hiccups (i know that it is not a problem with my system, because mpv and other players play fine)Beta Was this translation helpful? Give feedback.
All reactions