mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-31 22:25:33 -04:00
bluetooth: Don't find device if set profile is off
If the card is being set to off profile, it is not necessary to check if the device exists. This could potentially happen during shutdown, immediately before the module is unloaded.
This commit is contained in:
parent
b76ee00873
commit
0c5054e04a
1 changed files with 20 additions and 22 deletions
|
|
@ -2184,7 +2184,6 @@ static int card_set_profile(pa_card *c, pa_card_profile *new_profile) {
|
|||
struct userdata *u;
|
||||
enum profile *d;
|
||||
pa_queue *inputs = NULL, *outputs = NULL;
|
||||
const pa_bluetooth_device *device;
|
||||
|
||||
pa_assert(c);
|
||||
pa_assert(new_profile);
|
||||
|
|
@ -2192,28 +2191,27 @@ static int card_set_profile(pa_card *c, pa_card_profile *new_profile) {
|
|||
|
||||
d = PA_CARD_PROFILE_DATA(new_profile);
|
||||
|
||||
if (!(device = pa_bluetooth_discovery_get_by_path(u->discovery, u->path))) {
|
||||
pa_log_error("Failed to get device object.");
|
||||
return -PA_ERR_IO;
|
||||
}
|
||||
if (*d != PROFILE_OFF) {
|
||||
const pa_bluetooth_device *device;
|
||||
|
||||
/* The state signal is sent by bluez, so it is racy to check
|
||||
strictly for CONNECTED, we should also accept STREAMING state
|
||||
as being good enough. However, if the profile is used
|
||||
concurrently (which is unlikely), ipc will fail later on, and
|
||||
module will be unloaded. */
|
||||
if (device->headset_state < PA_BT_AUDIO_STATE_CONNECTED && *d == PROFILE_HSP) {
|
||||
pa_log_warn("HSP is not connected, refused to switch profile");
|
||||
return -PA_ERR_IO;
|
||||
} else if (device->audio_sink_state < PA_BT_AUDIO_STATE_CONNECTED && *d == PROFILE_A2DP) {
|
||||
pa_log_warn("A2DP Sink is not connected, refused to switch profile");
|
||||
return -PA_ERR_IO;
|
||||
} else if (device->audio_source_state < PA_BT_AUDIO_STATE_CONNECTED && *d == PROFILE_A2DP_SOURCE) {
|
||||
pa_log_warn("A2DP Source is not connected, refused to switch profile");
|
||||
return -PA_ERR_IO;
|
||||
} else if (device->hfgw_state < PA_BT_AUDIO_STATE_CONNECTED && *d == PROFILE_HFGW) {
|
||||
pa_log_warn("HandsfreeGateway is not connected, refused to switch profile");
|
||||
return -PA_ERR_IO;
|
||||
if (!(device = pa_bluetooth_discovery_get_by_path(u->discovery, u->path))) {
|
||||
pa_log_error("Failed to get device object.");
|
||||
return -PA_ERR_IO;
|
||||
}
|
||||
|
||||
if (device->headset_state < PA_BT_AUDIO_STATE_CONNECTED && *d == PROFILE_HSP) {
|
||||
pa_log_warn("HSP is not connected, refused to switch profile");
|
||||
return -PA_ERR_IO;
|
||||
} else if (device->audio_sink_state < PA_BT_AUDIO_STATE_CONNECTED && *d == PROFILE_A2DP) {
|
||||
pa_log_warn("A2DP Sink is not connected, refused to switch profile");
|
||||
return -PA_ERR_IO;
|
||||
} else if (device->audio_source_state < PA_BT_AUDIO_STATE_CONNECTED && *d == PROFILE_A2DP_SOURCE) {
|
||||
pa_log_warn("A2DP Source is not connected, refused to switch profile");
|
||||
return -PA_ERR_IO;
|
||||
} else if (device->hfgw_state < PA_BT_AUDIO_STATE_CONNECTED && *d == PROFILE_HFGW) {
|
||||
pa_log_warn("HandsfreeGateway is not connected, refused to switch profile");
|
||||
return -PA_ERR_IO;
|
||||
}
|
||||
}
|
||||
|
||||
if (u->sink) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue