[pulseaudio-discuss] [PATCH v4 1/2] loopback: Enable routing on loopback streams

Tanu Kaskinen tanuk at iki.fi
Wed Jul 4 06:11:26 PDT 2012


On Wed, 2012-06-20 at 17:33 +0200, Frédéric Dalleau wrote:
> At module-loopback load, if no sink is given, the default sink is used. If the
> stream has a media.role property, the property cannot be used because a the
> source or sink is forced to default. Both module-intended-roles and
> module-device-manager are affected. The same apply to sources.
> 
> With this patch, if sink or source is missing, routing modules can be used.

Thanks, pushed with some changes (see below).

> @@ -683,8 +685,21 @@ int pa__init(pa_module *m) {
>          goto fail;
>      }
>  
> -    ss = sink->sample_spec;
> -    map = sink->channel_map;
> +    if (sink) {
> +        ss = sink->sample_spec;
> +        map = sink->channel_map;
> +    } else if (source) {
> +        ss = source->sample_spec;
> +        map = source->channel_map;
> +    } else {
> +        /* Dummy sample format */

I expanded this comment to say that the dummy stream format shouldn't be
needed and pa_sink_input_new() should be fixed. I filed a bug too:
https://bugs.freedesktop.org/show_bug.cgi?id=51719

> @@ -723,20 +740,16 @@ int pa__init(pa_module *m) {
>          goto fail;
>      }
>  
> -    if (!pa_proplist_contains(sink_input_data.proplist, PA_PROP_MEDIA_NAME))
> -        pa_proplist_setf(sink_input_data.proplist, PA_PROP_MEDIA_NAME, "Loopback from %s",
> -                         pa_strnull(pa_proplist_gets(source->proplist, PA_PROP_DEVICE_DESCRIPTION)));
> -
>      if (!pa_proplist_contains(sink_input_data.proplist, PA_PROP_MEDIA_ROLE))
>          pa_proplist_sets(sink_input_data.proplist, PA_PROP_MEDIA_ROLE, "abstract");
>  
> -    if (!pa_proplist_contains(sink_input_data.proplist, PA_PROP_MEDIA_ICON_NAME)
> -            && (n = pa_proplist_gets(source->proplist, PA_PROP_DEVICE_ICON_NAME)))
> -        pa_proplist_sets(sink_input_data.proplist, PA_PROP_MEDIA_ICON_NAME, n);
> -
>      pa_sink_input_new_data_set_sample_spec(&sink_input_data, &ss);
>      pa_sink_input_new_data_set_channel_map(&sink_input_data, &map);
> -    sink_input_data.flags = PA_SINK_INPUT_VARIABLE_RATE | (remix ? 0 : PA_SINK_INPUT_NO_REMIX);
> +    if (sink || source) {
> +        sink_input_data.flags = PA_SINK_INPUT_VARIABLE_RATE | (remix ? 0 : PA_SINK_INPUT_NO_REMIX);

These flags should be set always, not only when sink or source is
defined.

> +    } else {
> +        sink_input_data.flags = PA_SINK_INPUT_FIX_FORMAT | PA_SINK_INPUT_FIX_RATE | PA_SINK_INPUT_FIX_CHANNELS;
> +    }

I realized that the user may give, for example, only the "format" module
argument, in which case PA_SINK_INPUT_FIX_FORMAT shouldn't be used but
FIX_RATE and FIX_CHANNELS should. I added three boolean variables:
format_set, rate_set and channels_set, and added code to enable the
flags individually if one or more of those variables are not set.

-- 
Tanu



More information about the pulseaudio-discuss mailing list