bluetooth: export nrec

This commit is contained in:
Marc-André Lureau 2009-02-03 18:43:54 +02:00
parent 452e2b9fa0
commit cac0f9ef2b

View file

@ -104,6 +104,7 @@ struct a2dp_info {
}; };
struct hsp_info { struct hsp_info {
pcm_capabilities_t pcm_capabilities;
pa_sink *sco_sink; pa_sink *sco_sink;
pa_source *sco_source; pa_source *sco_source;
pa_hook_slot *sink_state_changed_slot; pa_hook_slot *sink_state_changed_slot;
@ -271,23 +272,33 @@ static int parse_caps(struct userdata *u, const struct bt_get_capabilities_rsp *
return -1; return -1;
} }
if (u->profile != PROFILE_A2DP) if (u->profile == PROFILE_HSP) {
return 0; if (bytes_left <= 0 || codec->length != sizeof(u->hsp.pcm_capabilities))
return -1;
while (bytes_left > 0) { pa_assert(codec->type == BT_HFP_CODEC_PCM);
if (codec->type == BT_A2DP_CODEC_SBC)
break;
bytes_left -= codec->length; memcpy(&u->hsp.pcm_capabilities, codec, sizeof(u->hsp.pcm_capabilities));
codec = (const codec_capabilities_t*) ((const uint8_t*) codec + codec->length);
} }
if (bytes_left <= 0 || codec->length != sizeof(u->a2dp.sbc_capabilities)) if (u->profile == PROFILE_A2DP) {
return -1;
pa_assert(codec->type == BT_A2DP_CODEC_SBC); while (bytes_left > 0) {
if (codec->type == BT_A2DP_CODEC_SBC)
break;
bytes_left -= codec->length;
codec = (const codec_capabilities_t*) ((const uint8_t*) codec + codec->length);
}
if (bytes_left <= 0 || codec->length != sizeof(u->a2dp.sbc_capabilities))
return -1;
pa_assert(codec->type == BT_A2DP_CODEC_SBC);
memcpy(&u->a2dp.sbc_capabilities, codec, sizeof(u->a2dp.sbc_capabilities));
}
memcpy(&u->a2dp.sbc_capabilities, codec, sizeof(u->a2dp.sbc_capabilities));
return 0; return 0;
} }
@ -1334,10 +1345,9 @@ static int add_sink(struct userdata *u) {
} }
static int add_source(struct userdata *u) { static int add_source(struct userdata *u) {
pa_proplist *p;
if (USE_SCO_OVER_PCM(u)) { if (USE_SCO_OVER_PCM(u)) {
pa_proplist *p;
u->source = u->hsp.sco_source; u->source = u->hsp.sco_source;
u->source->card = u->card; /* FIXME! */ u->source->card = u->card; /* FIXME! */
p = pa_proplist_new(); p = pa_proplist_new();
@ -1379,6 +1389,11 @@ static int add_source(struct userdata *u) {
/* u->source->get_volume = source_get_volume_cb; */ /* u->source->get_volume = source_get_volume_cb; */
/* u->source->set_volume = source_set_volume_cb; */ /* u->source->set_volume = source_set_volume_cb; */
p = pa_proplist_new();
pa_proplist_sets(p, "bluetooth.nrec", pa_yes_no(u->hsp.pcm_capabilities.flags & BT_PCM_FLAG_NREC));
pa_proplist_update(u->source->proplist, PA_UPDATE_MERGE, p);
pa_proplist_free(p);
return 0; return 0;
} }