How to decode long files via streaming? #632
Replies: 2 comments 10 replies
-
It doesn't work the way you're thinking. You don't receive notifications to tell you when some audio is ready. Put simply, when you call A data source created by the resource manager is a |
Beta Was this translation helpful? Give feedback.
-
Thanks for the quick reply! Yes, I read the bit about (For context, the use case here is just rendering an audio waveform to the screen as quickly as possible.) |
Beta Was this translation helpful? Give feedback.
-
I am trying to decode a file into memory asynchronously via streaming, to avoid having to wait for the entire file to be processed before any data becomes available.
If possible, I'd like to do it without implementing my own thread handling. To do so, I thought I'd use the notification functionality of the resource manager.
I'm passing a
ma_resource_manager_pipeline_notifications
object toma_resource_manager_data_source_init
, along with flagsMA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_STREAM
andMA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_ASYNC
.This way, I'm receiving an "init" event after the first bit of audio has been decoded. Here
ma_resource_manager_data_source_get_available_frames
returns 88000 frames, which I then consume viama_data_source_read_pcm_frames
.But then I'm stuck. How do I continue from here? I would have hoped to receive events continuously as each bit of audio becomes available, but it seems like "init" is only emitted once, and "done" only at the end, as you'd expect.
Would I have to set up a polling thread that checks for new data at regular intervals?
Furthermore, I'm not quite clear about whether I should use
ma_data_source_read_pcm_frames
orma_resource_manager_data_source_read_pcm_frames
to consume the audio in this scenario. What is the difference between these two functions?Thanks!
Beta Was this translation helpful? Give feedback.
All reactions