[pulseaudio-discuss] Questions about device_start_waiting_for_profiles
Tanu Kaskinen
tanuk at iki.fi
Wed Sep 16 16:01:09 UTC 2020
On Sun, 2020-09-13 at 17:28 +0800, Chengyi Zhao wrote:
> Hi guys,
>
> I have a question for the code below, please give your opinion, thanks!
>
> The function device_start_waiting_for_profiles is to wait for connecting
> profiles,
> but only waited 3 seconds(WAIT_FOR_PROFILES_TIMEOUT_USEC), if Bluetooth
> transport state
> will be changed after 3 seconds(WAIT_FOR_PROFILES_TIMEOUT_USEC),
> I think whether there are any issues with the code logic or not.
>
>
> /* src/modules/bluetooth/bluez5-util.c */
>
> n_disconnected_profiles =
> device_count_disconnected_profiles(t->device);
>
> new_device_appeared = !old_any_connected &&
> pa_bluetooth_device_any_transport_connected(t->device);
> device_disconnected = old_any_connected &&
> !pa_bluetooth_device_any_transport_connected(t->device);
>
> if (new_device_appeared) {
> if (n_disconnected_profiles > 0)
> device_start_waiting_for_profiles(t->device); <---- here
> else
> pa_hook_fire(&t->device->discovery->hooks[PA_BLUETOOTH_HOOK_DEVICE_CONNECTION_CHANGED],
> t->device);
> return;
> }
>
> static void device_start_waiting_for_profiles(pa_bluetooth_device
> *device) {
> pa_assert(!device->wait_for_profiles_timer);
> device->wait_for_profiles_timer =
> pa_core_rttime_new(device->discovery->core,
> pa_rtclock_now() + WAIT_FOR_PROFILES_TIMEOUT_USEC, <---- here
> wait_for_profiles_cb, device);
> }
>
> static void wait_for_profiles_cb(pa_mainloop_api *api,
> pa_time_event* event, const struct timeval *tv, void *userdata) {
> pa_bluetooth_device *device = userdata;
> pa_strbuf *buf;
> pa_bluetooth_profile_t profile;
> bool first = true;
> char *profiles_str;
>
> device_stop_waiting_for_profiles(device); <---- here
>
> /* ...... */
> }
>
> Best Regards,
> Chengyi
I don't know what issues you're worried about. I'm not aware of any
issues, to my knowledge the code does what it's designed to do: delay
card creation until all profiles have been connected, but if that takes
more than 3 seconds, then the card is created with some profiles
disabled. We don't want to wait forever if those profiles never
connect.
--
Tanu
https://www.patreon.com/tanuk
https://liberapay.com/tanuk
More information about the pulseaudio-discuss
mailing list