mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-05 13:29:57 -05:00
bluetooth: Abstract speaker gain in transport
Similarly to the microphone gain, the speaker gain can be abstracted inside the transport object, even though the actual D-Bus interface in BlueZ differs.
This commit is contained in:
parent
ce24ef460a
commit
0b524c1078
2 changed files with 28 additions and 0 deletions
|
|
@ -549,6 +549,21 @@ static int parse_audio_property(pa_bluetooth_device *d, const char *interface, D
|
||||||
|
|
||||||
transport->microphone_gain = gain;
|
transport->microphone_gain = gain;
|
||||||
pa_hook_fire(&d->discovery->hooks[PA_BLUETOOTH_HOOK_TRANSPORT_MICROPHONE_GAIN_CHANGED], transport);
|
pa_hook_fire(&d->discovery->hooks[PA_BLUETOOTH_HOOK_TRANSPORT_MICROPHONE_GAIN_CHANGED], transport);
|
||||||
|
} else if (pa_streq(key, "SpeakerGain")) {
|
||||||
|
uint16_t gain;
|
||||||
|
|
||||||
|
pa_log_debug("dbus: property '%s' changed to value '%u'", key, value);
|
||||||
|
|
||||||
|
if (!transport) {
|
||||||
|
pa_log("Volume change does not have an associated transport");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((gain = PA_MIN(value, HSP_MAX_GAIN)) == transport->speaker_gain)
|
||||||
|
break;
|
||||||
|
|
||||||
|
transport->speaker_gain = gain;
|
||||||
|
pa_hook_fire(&d->discovery->hooks[PA_BLUETOOTH_HOOK_TRANSPORT_SPEAKER_GAIN_CHANGED], transport);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
@ -1141,6 +1156,16 @@ void pa_bluetooth_transport_set_microphone_gain(pa_bluetooth_transport *t, uint1
|
||||||
"MicrophoneGain", DBUS_TYPE_UINT16, &gain);
|
"MicrophoneGain", DBUS_TYPE_UINT16, &gain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pa_bluetooth_transport_set_speaker_gain(pa_bluetooth_transport *t, uint16_t value) {
|
||||||
|
dbus_uint16_t gain = PA_MIN(value, HSP_MAX_GAIN);
|
||||||
|
|
||||||
|
pa_assert(t);
|
||||||
|
pa_assert(t->profile == PROFILE_HSP);
|
||||||
|
|
||||||
|
set_property(t->device->discovery, "org.bluez", t->device->path, "org.bluez.Headset",
|
||||||
|
"SpeakerGain", DBUS_TYPE_UINT16, &gain);
|
||||||
|
}
|
||||||
|
|
||||||
static int setup_dbus(pa_bluetooth_discovery *y) {
|
static int setup_dbus(pa_bluetooth_discovery *y) {
|
||||||
DBusError err;
|
DBusError err;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,7 @@ typedef enum pa_bluetooth_hook {
|
||||||
PA_BLUETOOTH_HOOK_TRANSPORT_STATE_CHANGED, /* Call data: pa_bluetooth_transport */
|
PA_BLUETOOTH_HOOK_TRANSPORT_STATE_CHANGED, /* Call data: pa_bluetooth_transport */
|
||||||
PA_BLUETOOTH_HOOK_TRANSPORT_NREC_CHANGED, /* Call data: pa_bluetooth_transport */
|
PA_BLUETOOTH_HOOK_TRANSPORT_NREC_CHANGED, /* Call data: pa_bluetooth_transport */
|
||||||
PA_BLUETOOTH_HOOK_TRANSPORT_MICROPHONE_GAIN_CHANGED, /* Call data: pa_bluetooth_transport */
|
PA_BLUETOOTH_HOOK_TRANSPORT_MICROPHONE_GAIN_CHANGED, /* Call data: pa_bluetooth_transport */
|
||||||
|
PA_BLUETOOTH_HOOK_TRANSPORT_SPEAKER_GAIN_CHANGED, /* Call data: pa_bluetooth_transport */
|
||||||
PA_BLUETOOTH_HOOK_MAX
|
PA_BLUETOOTH_HOOK_MAX
|
||||||
} pa_bluetooth_hook_t;
|
} pa_bluetooth_hook_t;
|
||||||
|
|
||||||
|
|
@ -100,6 +101,7 @@ struct pa_bluetooth_transport {
|
||||||
pa_bluetooth_transport_state_t state;
|
pa_bluetooth_transport_state_t state;
|
||||||
pa_bool_t nrec;
|
pa_bool_t nrec;
|
||||||
uint16_t microphone_gain; /* Used for HSP/HFP */
|
uint16_t microphone_gain; /* Used for HSP/HFP */
|
||||||
|
uint16_t speaker_gain; /* Used for HSP/HFP */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* This enum is shared among Audio, Headset, AudioSink, and AudioSource, although not all values are acceptable in all profiles */
|
/* This enum is shared among Audio, Headset, AudioSink, and AudioSource, although not all values are acceptable in all profiles */
|
||||||
|
|
@ -150,6 +152,7 @@ int pa_bluetooth_transport_acquire(pa_bluetooth_transport *t, const char *access
|
||||||
void pa_bluetooth_transport_release(pa_bluetooth_transport *t, const char *accesstype);
|
void pa_bluetooth_transport_release(pa_bluetooth_transport *t, const char *accesstype);
|
||||||
|
|
||||||
void pa_bluetooth_transport_set_microphone_gain(pa_bluetooth_transport *t, uint16_t value);
|
void pa_bluetooth_transport_set_microphone_gain(pa_bluetooth_transport *t, uint16_t value);
|
||||||
|
void pa_bluetooth_transport_set_speaker_gain(pa_bluetooth_transport *t, uint16_t value);
|
||||||
|
|
||||||
pa_hook* pa_bluetooth_discovery_hook(pa_bluetooth_discovery *y, pa_bluetooth_hook_t hook);
|
pa_hook* pa_bluetooth_discovery_hook(pa_bluetooth_discovery *y, pa_bluetooth_hook_t hook);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue