[pulseaudio-discuss] [PATCH 47/56] bluetooth: Initialize profiles for BlueZ 5 cards

João Paulo Rechi Vita jprvita at gmail.com
Thu Jul 25 21:36:34 PDT 2013


On Tue, Jul 23, 2013 at 4:38 AM, Tanu Kaskinen
<tanu.kaskinen at linux.intel.com> wrote:
> On Fri, 2013-07-12 at 15:07 -0300, jprvita at gmail.com wrote:
>> +/* Run from main thread */
>> +static void transport_config(struct userdata *u) {
>> +    sbc_info_t *sbc_info = &u->sbc_info;
>> +    a2dp_sbc_t *config;
>> +
>> +    pa_assert(u->transport);
>> +
>> +    u->sample_spec.format = PA_SAMPLE_S16LE;
>> +    config = (a2dp_sbc_t *) u->transport->config;
>> +
>> +    if (sbc_info->sbc_initialized)
>> +        sbc_reinit(&sbc_info->sbc, 0);
>> +    else
>> +        sbc_init(&sbc_info->sbc, 0);
>> +    sbc_info->sbc_initialized = true;
>> +
>> +    switch (config->frequency) {
>> +        case SBC_SAMPLING_FREQ_16000:
>> +            sbc_info->sbc.frequency = SBC_FREQ_16000;
>> +            u->sample_spec.rate = 16000U;
>> +            break;
>> +        case SBC_SAMPLING_FREQ_32000:
>> +            sbc_info->sbc.frequency = SBC_FREQ_32000;
>> +            u->sample_spec.rate = 32000U;
>> +            break;
>> +        case SBC_SAMPLING_FREQ_44100:
>> +            sbc_info->sbc.frequency = SBC_FREQ_44100;
>> +            u->sample_spec.rate = 44100U;
>> +            break;
>> +        case SBC_SAMPLING_FREQ_48000:
>> +            sbc_info->sbc.frequency = SBC_FREQ_48000;
>> +            u->sample_spec.rate = 48000U;
>> +            break;
>> +        default:
>> +            pa_assert_not_reached();
>> +    }
>
> If broken config is handled with assertions (which I totally agree is a
> good way to do it), then the config definitely must be checked at the
> time it's received.
>

Ok, I'm adding that to the patch that implements the SetConfiguration() method.

>> @@ -517,6 +722,8 @@ void pa__done(pa_module *m) {
>>      if (u->device_connection_changed_slot)
>>          pa_hook_slot_free(u->device_connection_changed_slot);
>>
>> +    sbc_finish(&u->sbc_info.sbc);
>
> This should be done only if sbc_initialized is true. The code may work
> just fine, since the sbc struct is initialized to all zero when userdata
> is allocated, but that's relying on undocumented internal details of
> sbc_finish().
>

Ok.

-- 
João Paulo Rechi Vita
http://about.me/jprvita


More information about the pulseaudio-discuss mailing list