-
Hey there, I'm making a program that needs to audio streams from the internet, and I've hit some challenges using Symphonia with HTTP readers, because I cannot block on the audio thread but the reader might not have any data available. My general strategy until now was to pre-fill a buffer with some data on a separate thread, and hook Symphonia to that buffer. This works for normal audio streaming, but requires additional logic when first creating the source (ensuring enough data is available for the FormatReader to initialize), and when seeking (making sure the data at the next location is available). For some formats this is easy: However for more complex formats, like Another strategy I thought of is to just put Symphonia in a separate thread from the audio buffer so that it can block. But I'm not sure how wasteful it would be to transfer the audio samples across threads, instead of only compressed data, so I'm hesitant. Does any of these approaches make sense or is there an easier possibility that I'm missing? I think if Symphonia supported resuming after WouldBlock errors, it would make things easier for me (was also mentioned here: #27 (comment)) because then I wouldn't need complex pre-fetching and could just return silence when I see a WouldBlock. But I assume that would require quite a bit more logic on Symphonia's side to handle this. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 15 replies
-
Hi @Azorlogh, I also encountered this problem when integrating Symphonia into Psst. I think it works quite well, but I have zero experience with audio processing, so beware (@pdeljanov would be the authoritative voice here). I also might have over-engineered things a little. Related sources:
|
Beta Was this translation helpful? Give feedback.
-
If anyone else stumbles on this discussion looking for a way to add streaming to their project, I made a crate for this that should hopefully be flexible enough for most use cases: https://github.com/aschey/stream-download-rs. |
Beta Was this translation helpful? Give feedback.
Hi @Azorlogh, I also encountered this problem when integrating Symphonia into Psst. I think it works quite well, but I have zero experience with audio processing, so beware (@pdeljanov would be the authoritative voice here). I also might have over-engineered things a little.
Related sources: