[pulseaudio-discuss] What's the purpose of "rewind" on corking and uncorking?

Lin, Mengdong mengdong.lin at intel.com
Tue Jun 14 08:33:18 PDT 2011


Many thanks for the information!

> When corking, we want that the audio in the stream buffer will be "taken
> away" from the sink buffer, but we still want to keep the data in the
> stream buffer. When uncorking, the sink should take back the same stream
> data that was originally taken away from it.
>

But it seems on corking, no data will be "taken away" from the sink buffer. Here is the code:

void pa_sink_input_set_state_within_thread(pa_sink_input *i, pa_sink_input_state_t state) {
	...
    i->thread_info.state = state;   ---> so the sink input's thread_info.state changed to PA_SINK_INPUT_CORKED. So pa_sink_input_request_rewind() will do nothing. 

    if (corking) {

        pa_log_debug("Requesting rewind due to corking");

        /* This will tell the implementing sink input driver to rewind
         * so that the unplayed already mixed data is not lost */
        pa_sink_input_request_rewind(i, 0, TRUE, TRUE, FALSE);

    }

void pa_sink_input_request_rewind(
        pa_sink_input *i,
        size_t nbytes  /* in our sample spec */,
        pa_bool_t rewrite,
        pa_bool_t flush,
        pa_bool_t dont_rewind_render) {
...
    /* We don't take rewind requests while we are corked */
    if (i->thread_info.state == PA_SINK_INPUT_CORKED)
        return; 

...

If I misunderstand something, please correct me.

Thanks again!
Amanda
                                            


More information about the pulseaudio-discuss mailing list