[pulseaudio-discuss] Why does PA need to rewrite and rewind when I change the volume while playing audio?

Chengyi Zhao zhaochengyi at uniontech.com
Tue Jul 27 03:18:19 UTC 2021


Hi guys,

I found the following logic when I change the volume while playing 
audio.I guess there is some audio expertise here, would you please tell 
me the principle, thanks a lot!

In the file sink-input.c(./src/pulsecore/sink-input.c), why does pa need 
to invoke the function pa_sink_input_request_rewind to rewrite and 
rewind the data?

void pa_sink_input_set_volume(...) {
     ...

     pa_assert_se(pa_asyncmsgq_send(i->sink->asyncmsgq, PA_MSGOBJECT(i), 
PA_SINK_INPUT_MESSAGE_SET_SOFT_VOLUME, NULL, 0, NULL) == 0);
     }

     ...
}

int pa_sink_input_process_msg(...) {
     ...

     switch (code) {

         case PA_SINK_INPUT_MESSAGE_SET_SOFT_VOLUME:
             if (!pa_cvolume_equal(&i->thread_info.soft_volume, 
&i->soft_volume)) {
                 i->thread_info.soft_volume = i->soft_volume;
                 pa_sink_input_request_rewind(i, 0, true, false, false);
             }

            return 0;

     ...
}

Best Regards,
Chengyi




More information about the pulseaudio-discuss mailing list