[pulseaudio-discuss] calling pa_stream_update_timing_info in another thread

golden magic.lixin at gmail.com
Tue May 19 19:10:39 PDT 2015


Dear PulseAudio forks,


      I`m making a function to get the buffer latency of pa_stream(with 
PA_STREAM_AUTO_TIMING_UPDATE flag), here is what it looks like

      void operation_done_callback(pa_stream* , bool, void*)
     {
        LOGD("operation_done");
     }

       int64_t audiostream::getBufferLatencySize()
      {
         // m_stream is a pointer of pa_stream
         pa_operation* o = pa_stream_update_timing_info(m_stream, 
operation_done_callback, this);
         LOGD("enter PA_WAIT_OPEARION2DONE loop");
         if (o != NULL) {
             while (sync && pa_operation_get_state(o) != PA_OPERATION_DONE)
;
pa_operation_unref(o);
             o = NULL;
         } else {
             LOGD("PA_WAIT_OPEARION2DONE operation is NULL");
         }

         LOGD("exit PA_WAIT_OPEARION2DONE loop");

        const pa_timing_info* t = pa_stream_get_timing_info(s);
         if (!t) {
             return -1;
         }
         return t->write_index - t->read_index;
}

     I want that the user can get the accurate result when he calls this 
function,
     so every time if user called getBufferLatencySize, I call 
pa_stream_update_timing_info and wait this operation done, and this 
function is called in user thread.

      Sometimes this operation is never finished, and the operation done 
callback is never called.

      Don't know what I'm doing wrong, any advice will be appreciated, 
Thanks!




BR,
Lixin


More information about the pulseaudio-discuss mailing list