[pulseaudio-discuss] [PATCH] profile-switcher: Deal with new Bluetooth cards
Tanu Kaskinen
tanuk at iki.fi
Mon Jun 4 23:03:23 PDT 2012
On Thu, 2012-02-09 at 19:13 +0530, Arun Raghavan wrote:
> @@ -189,6 +191,47 @@ static pa_hook_result_t source_output_unlink_post_cb(pa_core *c, pa_source_outpu
> return PA_HOOK_OK;
> }
>
> +/* Set the inital profile for the card based on currently available
Typo: "inital" -> "initial".
> + * sink-inputs and source-outputs. */
> +static pa_hook_result_t card_new_cb(pa_core *c, pa_card_new_data *data, void *userdata) {
> + const char *device_api;
> + pa_sink_input *input;
> + pa_source_output *output;
> + pa_bool_t use_a2dp = TRUE;
> + uint32_t idx;
> +
> + device_api = pa_proplist_gets(data->proplist, PA_PROP_DEVICE_API);
> + if (!device_api || !pa_streq(device_api, "bluez"))
> + return PA_HOOK_OK;
> +
> + PA_IDXSET_FOREACH(input, c->sink_inputs, idx) {
> + if (pa_streq(GET_ROLE(input), "phone")) {
> + use_a2dp = FALSE;
> + goto done;
> + }
> + }
> +
> + PA_IDXSET_FOREACH(output, c->source_outputs, idx) {
> + if (pa_streq(GET_ROLE(output), "phone")) {
> + use_a2dp = FALSE;
> + break;
> + }
> + }
> +
> +done:
> + if (use_a2dp) {
> + pa_log_info("No phone streams, switching card '%s' to A2DP profile", data->name);
To be precise, you're not switching the profile, you're setting the
initial profile.
> + pa_card_new_data_set_profile(data, "a2dp");
> + data->save_profile = FALSE;
> + } else {
> + pa_log_info("Have a phone stream, switching card '%s' to HSP/HFP profile", data->name);
> + pa_card_new_data_set_profile(data, "hsp");
> + data->save_profile = FALSE;
> + }
The profile should be set only if it's not already set by someone else.
--
Tanu
More information about the pulseaudio-discuss
mailing list