mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-02 09:01:46 -05:00
bluez5-device: use get_profile_direction
Use the get_profile_direction() helper function to decide when to add a source and a sink instead of enumerating profiles.
This commit is contained in:
parent
8718496d14
commit
2251085dda
1 changed files with 15 additions and 17 deletions
|
|
@ -1209,6 +1209,19 @@ static int setup_transport(struct userdata *u) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* Run from main thread */
|
||||
static pa_direction_t get_profile_direction(pa_bluetooth_profile_t p) {
|
||||
static const pa_direction_t profile_direction[] = {
|
||||
[PA_BLUETOOTH_PROFILE_A2DP_SINK] = PA_DIRECTION_OUTPUT,
|
||||
[PA_BLUETOOTH_PROFILE_A2DP_SOURCE] = PA_DIRECTION_INPUT,
|
||||
[PA_BLUETOOTH_PROFILE_HEADSET_HEAD_UNIT] = PA_DIRECTION_INPUT | PA_DIRECTION_OUTPUT,
|
||||
[PA_BLUETOOTH_PROFILE_HEADSET_AUDIO_GATEWAY] = PA_DIRECTION_INPUT | PA_DIRECTION_OUTPUT,
|
||||
[PA_BLUETOOTH_PROFILE_OFF] = 0
|
||||
};
|
||||
|
||||
return profile_direction[p];
|
||||
}
|
||||
|
||||
/* Run from main thread */
|
||||
static int init_profile(struct userdata *u) {
|
||||
int r = 0;
|
||||
|
|
@ -1220,13 +1233,11 @@ static int init_profile(struct userdata *u) {
|
|||
|
||||
pa_assert(u->transport);
|
||||
|
||||
if (u->profile == PA_BLUETOOTH_PROFILE_A2DP_SINK || u->profile == PA_BLUETOOTH_PROFILE_HEADSET_HEAD_UNIT ||
|
||||
u->profile == PA_BLUETOOTH_PROFILE_HEADSET_AUDIO_GATEWAY)
|
||||
if (get_profile_direction (u->profile) & PA_DIRECTION_OUTPUT)
|
||||
if (add_sink(u) < 0)
|
||||
r = -1;
|
||||
|
||||
if (u->profile == PA_BLUETOOTH_PROFILE_A2DP_SOURCE || u->profile == PA_BLUETOOTH_PROFILE_HEADSET_HEAD_UNIT ||
|
||||
u->profile == PA_BLUETOOTH_PROFILE_HEADSET_AUDIO_GATEWAY)
|
||||
if (get_profile_direction (u->profile) & PA_DIRECTION_INPUT)
|
||||
if (add_source(u) < 0)
|
||||
r = -1;
|
||||
|
||||
|
|
@ -1545,19 +1556,6 @@ static char *cleanup_name(const char *name) {
|
|||
return t;
|
||||
}
|
||||
|
||||
/* Run from main thread */
|
||||
static pa_direction_t get_profile_direction(pa_bluetooth_profile_t p) {
|
||||
static const pa_direction_t profile_direction[] = {
|
||||
[PA_BLUETOOTH_PROFILE_A2DP_SINK] = PA_DIRECTION_OUTPUT,
|
||||
[PA_BLUETOOTH_PROFILE_A2DP_SOURCE] = PA_DIRECTION_INPUT,
|
||||
[PA_BLUETOOTH_PROFILE_HEADSET_HEAD_UNIT] = PA_DIRECTION_INPUT | PA_DIRECTION_OUTPUT,
|
||||
[PA_BLUETOOTH_PROFILE_HEADSET_AUDIO_GATEWAY] = PA_DIRECTION_INPUT | PA_DIRECTION_OUTPUT,
|
||||
[PA_BLUETOOTH_PROFILE_OFF] = 0
|
||||
};
|
||||
|
||||
return profile_direction[p];
|
||||
}
|
||||
|
||||
/* Run from main thread */
|
||||
static pa_available_t get_port_availability(struct userdata *u, pa_direction_t direction) {
|
||||
pa_available_t result = PA_AVAILABLE_NO;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue