a2dp: improve negotiation

This commit is contained in:
Wim Taymans 2018-10-05 11:10:36 +02:00
parent 41d38e56df
commit a95cd608e7

View file

@ -608,6 +608,7 @@ static void a2dp_on_timeout(struct spa_source *source)
if (spa_list_is_empty(&this->ready)) { if (spa_list_is_empty(&this->ready)) {
spa_log_trace(this->log, "a2dp-sink %p: %d", this, io->status); spa_log_trace(this->log, "a2dp-sink %p: %d", this, io->status);
io->status = SPA_STATUS_NEED_BUFFER; io->status = SPA_STATUS_NEED_BUFFER;
if (this->range) { if (this->range) {
this->range->offset = this->sample_count * this->frame_size; this->range->offset = this->sample_count * this->frame_size;
@ -616,10 +617,8 @@ static void a2dp_on_timeout(struct spa_source *source)
} }
this->callbacks->process(this->callbacks_data, SPA_STATUS_NEED_BUFFER); this->callbacks->process(this->callbacks_data, SPA_STATUS_NEED_BUFFER);
} }
else {
flush_data(this, now_time); flush_data(this, now_time);
} }
}
static int init_sbc(struct impl *this) static int init_sbc(struct impl *this)
@ -963,21 +962,27 @@ impl_node_port_enum_params(struct spa_node *node,
if (this->transport->codec == 0) { if (this->transport->codec == 0) {
a2dp_sbc_t *config = this->transport->configuration; a2dp_sbc_t *config = this->transport->configuration;
int rate, channels; struct spa_audio_info_raw info = { 0, };
if ((rate = a2dp_sbc_get_frequency(config)) < 0) info.format = SPA_AUDIO_FORMAT_S16;
if ((info.rate = a2dp_sbc_get_frequency(config)) < 0)
return -EIO; return -EIO;
if ((channels = a2dp_sbc_get_channels(config)) < 0) if ((info.channels = a2dp_sbc_get_channels(config)) < 0)
return -EIO; return -EIO;
param = spa_pod_builder_object(&b, switch (info.channels) {
SPA_TYPE_OBJECT_Format, id, case 1:
SPA_FORMAT_mediaType, &SPA_POD_Id(SPA_MEDIA_TYPE_audio), info.position[0] = SPA_AUDIO_CHANNEL_MONO;
SPA_FORMAT_mediaSubtype, &SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw), break;
SPA_FORMAT_AUDIO_format, &SPA_POD_Id(SPA_AUDIO_FORMAT_S16), case 2:
SPA_FORMAT_AUDIO_rate, &SPA_POD_Int(rate), info.position[0] = SPA_AUDIO_CHANNEL_FL;
SPA_FORMAT_AUDIO_channels, &SPA_POD_Int(channels), info.position[1] = SPA_AUDIO_CHANNEL_FR;
0); break;
default:
return -EIO;
}
param = spa_format_audio_raw_build(&b, id, &info);
} }
else else
return -EIO; return -EIO;