[pulseaudio-discuss] [PATCH v9] loopback: Correct corking logic during sink or source move

Georg Chini georg at chini.tk
Mon Mar 20 20:35:10 UTC 2017


On 20.03.2017 21:15, Georg Chini wrote:
> On 17.03.2017 21:50, Tanu Kaskinen wrote:
>> On Mon, 2017-02-27 at 18:17 +0100, Georg Chini wrote:
>>> The corking logic of module-loopback was incorrectly implemented. If 
>>> you suspended
>>> the source, the sink input would be corked. When then the sink was 
>>> suspended because
>>> of being idle, the source output was also corked. If you moved then 
>>> away from the
>>> suspended source, module-loopback would not start the stream again, 
>>> because sink
>>> input and source output were both corked. The same applied if the 
>>> sink was suspended.
>>>
>>> This patch corrects this behavior. It also uncorks sink input or 
>>> source output if the
>>> destination source or sink during a move is suspended because it is 
>>> idle. This avoids
>>> unnecessary interruptions of the stream, which makes the latency 
>>> reports used to
>>> correct the initial latency more reliable.
>>>
>>> The patch also takes profile switches into account, where sink and 
>>> source become invalid
>>> at the same time. In this case, corking or uncorking must be delayed 
>>> until the appropriate
>>> attach callback.
>>>
>>> ---
>>>   src/modules/module-loopback.c | 98 
>>> +++++++++++++++++++++++++++++++++++--------
>>>   1 file changed, 81 insertions(+), 17 deletions(-)
>>> @@ -480,6 +487,15 @@ static void 
>>> source_output_attach_cb(pa_source_output *o) {
>>>               o->source->thread_info.rtpoll,
>>>               PA_RTPOLL_LATE,
>>>               u->asyncmsgq);
>>> +
>>> +    /* Delayed state schange if necessary */
>>> +    if 
>>> (u->input_thread_info.delayed_source_output_state_change_required) {
>>> + u->input_thread_info.delayed_source_output_state_change_required = 
>>> false;
>>> +        if (u->input_thread_info.delayed_source_output_should_cork)
>>> +            pa_source_output_set_state_within_thread(o, 
>>> PA_SOURCE_OUTPUT_CORKED);
>>> +        else
>>> +            pa_source_output_set_state_within_thread(o, 
>>> PA_SOURCE_OUTPUT_RUNNING);
>>> +    }
>> pa_source_output_cork() does a bunch of things that
>> pa_source_output_set_state_within_thread() doesn't do, so it looks like
>> you can't replace the former with the latter.
>
> That's wrong. pa_source_output_cork()  only calls 
> source_output_set_state()
> and does nothing else. The same applies to sink_input_cork().

Sorry, did not look properly, I mixed up source_output_set_state() and
pa_source_output_set_state_within_thread ... I'll look into it some time 
this week.


More information about the pulseaudio-discuss mailing list