Using LibCurl to stream audio #13454
Replies: 1 comment
-
If the application blocks inside the write function, the effects will vary depending on the protocol in use. Blocking means that libcurl won't have any chance to run any protocol-specific functions (assuming use of the easy interface and not the multi one), which could have negative repercussions. For some protocols, this won't cause any particular harm. For others, blocking for any length of time could cause protocol retransmits or protocol errors that could take the connection down. For a simple protocol like http it's fine to block for a short while, but for a complicated one like quic that integrates a full transports layer into user space, blocking for too long will be less efficient. Using the multi interface allows libcurl to perform any transfer handshaking necessary even if a handle has been paused, even paused for a long time. |
Beta Was this translation helpful? Give feedback.
-
Is it possible to use LibCurl to stream audio?
I'm thinking of doing the following:
Use a circular buffer to storing incoming data from LibCurl, the LibCurl write_function would write data here.
If there is not enough space in the buffer, I need to pause, so I can either return CURL_WRITEFUNC_PAUSE or use curl_easy_pause(), which one will depend on whether I'm allowed to block inside the write_function - am I? I'm guessing not as all the writing will be happening on the same thread, correct?
Use curl_multi to advance the transfer in steps. After each curl_multi_perform() step, checked if paused. If so, wait on a condition_variable that is set when the buffer is read from another thread.
This doesn't go into the read side details but is this generally the right idea for the write/curl side?
Bye!
Mark
Beta Was this translation helpful? Give feedback.
All reactions