[pulseaudio-discuss] [V2 PATCH] rescue-streams: try to find best one using availability and priority

hwang4 hui.wang at canonical.com
Thu May 29 23:06:29 PDT 2014


On 2014年05月30日 13:29, David Henningsson wrote:
> Hi Hui,
>
> Please see comments below:
>
> On 2014-05-30 05:26, Hui Wang wrote:
>> Recently met a problem: when I disconnect the bluetooth headset, the
>> pulseaudio automatically switch the sound to sink of HDMI output
>> instead of the sink of internal speaker even though there is no HDMI
>> cable connected.
>>
>> To fix this problem, I want to change the rule of selecting the target
>>
<snip>
>> - def = pa_namereg_get_default_
>> -
>> - if (def && def != skip && pa_sink_input_may_move_to(i, def))
>> - return def;
>
> You have removed the rows above. Was that really necessary, i e, was 
> the HDMI sink the default sink in this case?
I will do a test again to verify if it is necessary to remove def sink 
or not here.

>
>> + all_ports = pa_hashmap_new(pa_idxset_string_hash_func, 
>> pa_idxset_string_compare_func);
>
> You probably want the pa_idxset_trivial_* funcs here instead (and use 
> port pointers as key rather than the name), because ports may have the 
> same name if they belong to different sinks.
Got it.

>
>>
>> PA_IDXSET_FOREACH(target, c->sinks, idx) {
>> - if (target == def)
>> - continue;
>> -
>> if (target == skip)
>> continue;
>>
>> if (!PA_SINK_IS_LINKED(pa_sink_get_state(target)))
>> continue;
>>
>> - if (pa_sink_input_may_move_to(i, target))
>> - return target;
>> + if (!pa_sink_input_may_move_to(i, target))
>> + continue;
>> +
>> + build_group_ports(all_ports, target->ports);
>
> The line above has wrong indentation.
>
Got it.
>> }
>>
>> - pa_log_debug("No evacuation sink found.");
>> - return NULL;
>> + best_port = pa_device_port_find_best(all_ports);
>> + if(!best_port)
>> + pa_log_debug("No evacuation sink found.");
>
> We're still missing a fallback here: some sinks have no ports. I think 
> we should still try to switch to them in case we did not find a 
> best_port.
Got it, all comments will be fixed in the V3.

thanks.
Hui.



More information about the pulseaudio-discuss mailing list