bluetooth: reinitialize the sample spec when switching profile
authorMarc-André Lureau <marcandre.lureau@gmail.com>
Tue, 10 Feb 2009 21:48:37 +0000 (23:48 +0200)
committerMarc-André Lureau <marcandre.lureau@gmail.com>
Tue, 10 Feb 2009 21:53:36 +0000 (23:53 +0200)
When doing init_profile(), the value u->sample_spec is modified to the
one which has been last configured. In case of HSP, it will be 8kHz.

Later on, when setting the profile to A2DP, it picks up the lower rate
available which match with current u->sample_spec.

In my case, it would be 16kHz. To circunvent the issue, I decided to
reinitialize the u->sample_spec to default value with user module
argument requested rate.

src/modules/bluetooth/module-bluetooth-device.c

index fa9d6bf..666dc6a 100644 (file)
@@ -1568,6 +1568,14 @@ static int card_set_profile(pa_card *c, pa_card_profile *new_profile) {
     }
 
     u->profile = *d;
+
+    /* Reinitialize the sample spec to default with module argument rate */
+    u->sample_spec = u->module->core->default_sample_spec;
+    if (pa_modargs_get_value_u32(u->modargs, "rate", &u->sample_spec.rate) < 0 ||
+        u->sample_spec.rate <= 0 || u->sample_spec.rate > PA_RATE_MAX) {
+        u->sample_spec = u->module->core->default_sample_spec;
+    }
+
     init_profile(u);
 
     if (u->sink || u->source)