mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-02 09:01:46 -05:00
instead of failing when the requested sampling rate is not available find the next one that is higher
This commit is contained in:
parent
aa1974b7a0
commit
a35f84a4f9
1 changed files with 23 additions and 19 deletions
|
|
@ -252,33 +252,37 @@ static uint8_t default_bitpool(uint8_t freq, uint8_t mode) {
|
||||||
|
|
||||||
static int bt_a2dp_init(struct userdata *u) {
|
static int bt_a2dp_init(struct userdata *u) {
|
||||||
sbc_capabilities_t *cap = &u->a2dp.sbc_capabilities;
|
sbc_capabilities_t *cap = &u->a2dp.sbc_capabilities;
|
||||||
unsigned int max_bitpool, min_bitpool;
|
uint8_t max_bitpool, min_bitpool;
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
switch (u->ss.rate) {
|
static const struct {
|
||||||
case 48000:
|
uint32_t rate;
|
||||||
cap->frequency = BT_SBC_SAMPLING_FREQ_48000;
|
uint8_t cap;
|
||||||
break;
|
} freq_table[] = {
|
||||||
case 44100:
|
{ 16000U, BT_SBC_SAMPLING_FREQ_16000 },
|
||||||
cap->frequency = BT_SBC_SAMPLING_FREQ_44100;
|
{ 32000U, BT_SBC_SAMPLING_FREQ_32000 },
|
||||||
break;
|
{ 44100U, BT_SBC_SAMPLING_FREQ_44100 },
|
||||||
case 32000:
|
{ 48000U, BT_SBC_SAMPLING_FREQ_48000 }
|
||||||
cap->frequency = BT_SBC_SAMPLING_FREQ_32000;
|
};
|
||||||
break;
|
|
||||||
case 16000:
|
|
||||||
cap->frequency = BT_SBC_SAMPLING_FREQ_16000;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
pa_log_error("Rate %d not supported", u->ss.rate);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (u->ss.channels == 2) {
|
/* Find the lowest freq that is at least as high as the requested
|
||||||
|
* sampling rate */
|
||||||
|
for (i = 0; i < PA_ELEMENTSOF(freq_table); i++)
|
||||||
|
if (freq_table[i].rate >= u->ss.rate || i == PA_ELEMENTSOF(freq_table)-1 ) {
|
||||||
|
u->ss.rate = freq_table[i].rate;
|
||||||
|
cap->frequency = freq_table[i].cap;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (u->ss.channels >= 2) {
|
||||||
if (cap->channel_mode & BT_A2DP_CHANNEL_MODE_JOINT_STEREO)
|
if (cap->channel_mode & BT_A2DP_CHANNEL_MODE_JOINT_STEREO)
|
||||||
cap->channel_mode = BT_A2DP_CHANNEL_MODE_JOINT_STEREO;
|
cap->channel_mode = BT_A2DP_CHANNEL_MODE_JOINT_STEREO;
|
||||||
else if (cap->channel_mode & BT_A2DP_CHANNEL_MODE_STEREO)
|
else if (cap->channel_mode & BT_A2DP_CHANNEL_MODE_STEREO)
|
||||||
cap->channel_mode = BT_A2DP_CHANNEL_MODE_STEREO;
|
cap->channel_mode = BT_A2DP_CHANNEL_MODE_STEREO;
|
||||||
else if (cap->channel_mode & BT_A2DP_CHANNEL_MODE_DUAL_CHANNEL)
|
else if (cap->channel_mode & BT_A2DP_CHANNEL_MODE_DUAL_CHANNEL)
|
||||||
cap->channel_mode = BT_A2DP_CHANNEL_MODE_DUAL_CHANNEL;
|
cap->channel_mode = BT_A2DP_CHANNEL_MODE_DUAL_CHANNEL;
|
||||||
|
|
||||||
|
u->ss.channels = 2;
|
||||||
} else {
|
} else {
|
||||||
if (cap->channel_mode & BT_A2DP_CHANNEL_MODE_MONO)
|
if (cap->channel_mode & BT_A2DP_CHANNEL_MODE_MONO)
|
||||||
cap->channel_mode = BT_A2DP_CHANNEL_MODE_MONO;
|
cap->channel_mode = BT_A2DP_CHANNEL_MODE_MONO;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue