Commit 76105b07 authored by pali's avatar pali

bluetooth: Rename microphone to rx_volume and speaker to tx_volume

In A2DP context there is no microphone and in HSP/HFP AG roles is microphone and speaker definition switched. So for local socket names rx and tx are unambiguous.
parent a5f89e12
......@@ -2261,10 +2261,10 @@ static DBusMessage *endpoint_set_configuration(DBusConnection *conn, DBusMessage
t = pa_bluetooth_transport_new(d, sender, path, p, config, size);
/* We do not support AVRCP Absolute Volume yet, so use softvol */
t->microphone_soft_volume = true;
t->speaker_soft_volume = true;
t->max_microphone_gain = PA_VOLUME_NORM;
t->max_speaker_gain = PA_VOLUME_NORM;
t->rx_soft_volume = true;
t->tx_soft_volume = true;
t->max_rx_volume_gain = PA_VOLUME_NORM;
t->max_tx_volume_gain = PA_VOLUME_NORM;
t->acquire = bluez5_transport_acquire_cb;
t->release = bluez5_transport_release_cb;
pa_bluetooth_transport_put(t);
......
......@@ -49,8 +49,8 @@ typedef enum pa_bluetooth_hook {
PA_BLUETOOTH_HOOK_PROFILE_CONNECTION_CHANGED, /* Call data: pa_bluetooth_device_and_profile */
PA_BLUETOOTH_HOOK_DEVICE_UNLINK, /* Call data: pa_bluetooth_device */
PA_BLUETOOTH_HOOK_TRANSPORT_STATE_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_TRANSPORT_RX_VOLUME_GAIN_CHANGED, /* Call data: pa_bluetooth_transport */
PA_BLUETOOTH_HOOK_TRANSPORT_TX_VOLUME_GAIN_CHANGED, /* Call data: pa_bluetooth_transport */
PA_BLUETOOTH_HOOK_MAX
} pa_bluetooth_hook_t;
......@@ -86,8 +86,8 @@ typedef enum pa_bluetooth_transport_state {
typedef int (*pa_bluetooth_transport_acquire_cb)(pa_bluetooth_transport *t, size_t *imtu, size_t *omtu);
typedef void (*pa_bluetooth_transport_release_cb)(pa_bluetooth_transport *t);
typedef void (*pa_bluetooth_transport_destroy_cb)(pa_bluetooth_transport *t);
typedef void (*pa_bluetooth_transport_set_speaker_gain_cb)(pa_bluetooth_transport *t, uint16_t gain);
typedef void (*pa_bluetooth_transport_set_microphone_gain_cb)(pa_bluetooth_transport *t, uint16_t gain);
typedef void (*pa_bluetooth_transport_set_rx_volume_gain_cb)(pa_bluetooth_transport *t, uint16_t gain);
typedef void (*pa_bluetooth_transport_set_tx_volume_gain_cb)(pa_bluetooth_transport *t, uint16_t gain);
struct pa_bluetooth_transport {
pa_bluetooth_device *device;
......@@ -99,20 +99,20 @@ struct pa_bluetooth_transport {
uint8_t *config;
size_t config_size;
bool microphone_soft_volume;
bool speaker_soft_volume;
pa_volume_t microphone_gain;
pa_volume_t speaker_gain;
pa_volume_t max_microphone_gain;
pa_volume_t max_speaker_gain;
bool rx_soft_volume;
bool tx_soft_volume;
pa_volume_t rx_volume_gain;
pa_volume_t tx_volume_gain;
pa_volume_t max_rx_volume_gain;
pa_volume_t max_tx_volume_gain;
pa_bluetooth_transport_state_t state;
pa_bluetooth_transport_acquire_cb acquire;
pa_bluetooth_transport_release_cb release;
pa_bluetooth_transport_destroy_cb destroy;
pa_bluetooth_transport_set_speaker_gain_cb set_speaker_gain;
pa_bluetooth_transport_set_microphone_gain_cb set_microphone_gain;
pa_bluetooth_transport_set_rx_volume_gain_cb set_rx_volume_gain;
pa_bluetooth_transport_set_tx_volume_gain_cb set_tx_volume_gain;
void *userdata;
};
......
......@@ -350,24 +350,24 @@ static void hsphfpd_transport_destroy(pa_bluetooth_transport *transport) {
pa_xfree(transport_data);
}
static void hsphfpd_transport_set_speaker_gain(pa_bluetooth_transport *transport, uint16_t gain) {
static void hsphfpd_transport_set_tx_volume_gain(pa_bluetooth_transport *transport, uint16_t gain) {
struct hsphfpd_transport_data *transport_data = transport->userdata;
if (transport->speaker_gain == gain)
if (transport->tx_volume_gain == gain)
return;
set_tx_volume_gain_property(transport_data, gain);
transport->speaker_gain = gain;
transport->tx_volume_gain = gain;
}
static void hsphfpd_transport_set_microphone_gain(pa_bluetooth_transport *transport, uint16_t gain) {
static void hsphfpd_transport_set_rx_volume_gain(pa_bluetooth_transport *transport, uint16_t gain) {
struct hsphfpd_transport_data *transport_data = transport->userdata;
if (transport->microphone_gain == gain)
if (transport->rx_volume_gain == gain)
return;
set_rx_volume_gain_property(transport_data, gain);
transport->microphone_gain = gain;
transport->rx_volume_gain = gain;
}
static void parse_transport_properties_values(pa_bluetooth_hsphfpd *hsphfpd, const char *transport_path, DBusMessageIter *i, const char **endpoint_path, const char **air_codec, enum hsphfpd_volume_control *rx_volume_control, enum hsphfpd_volume_control *tx_volume_control, uint16_t *rx_volume_gain, uint16_t *tx_volume_gain, uint16_t *mtu) {
......@@ -475,9 +475,9 @@ static void parse_transport_properties(pa_bluetooth_transport *transport, DBusMe
pa_log_warn("Transport %s received a duplicate '%s' property, ignoring", transport_data->transport_path, "MTU");
if (rx_volume_control) {
if (!!transport->microphone_soft_volume != !!(rx_volume_control != HSPHFPD_VOLUME_CONTROL_REMOTE)) {
pa_log_info("Transport %s changed rx soft volume from %s to %s", transport_data->transport_path, pa_yes_no(transport->microphone_soft_volume), pa_yes_no(rx_volume_control != HSPHFPD_VOLUME_CONTROL_REMOTE));
transport->microphone_soft_volume = (rx_volume_control != HSPHFPD_VOLUME_CONTROL_REMOTE);
if (!!transport->rx_soft_volume != !!(rx_volume_control != HSPHFPD_VOLUME_CONTROL_REMOTE)) {
pa_log_info("Transport %s changed rx soft volume from %s to %s", transport_data->transport_path, pa_yes_no(transport->rx_soft_volume), pa_yes_no(rx_volume_control != HSPHFPD_VOLUME_CONTROL_REMOTE));
transport->rx_soft_volume = (rx_volume_control != HSPHFPD_VOLUME_CONTROL_REMOTE);
rx_soft_volume_changed = true;
}
if (transport_data->rx_volume_control != rx_volume_control) {
......@@ -487,9 +487,9 @@ static void parse_transport_properties(pa_bluetooth_transport *transport, DBusMe
}
if (tx_volume_control) {
if (!!transport->speaker_soft_volume != !!(rx_volume_control != HSPHFPD_VOLUME_CONTROL_REMOTE)) {
pa_log_info("Transport %s changed tx soft volume from %s to %s", transport_data->transport_path, pa_yes_no(transport->speaker_soft_volume), pa_yes_no(rx_volume_control != HSPHFPD_VOLUME_CONTROL_REMOTE));
transport->speaker_soft_volume = (rx_volume_control != HSPHFPD_VOLUME_CONTROL_REMOTE);
if (!!transport->tx_soft_volume != !!(rx_volume_control != HSPHFPD_VOLUME_CONTROL_REMOTE)) {
pa_log_info("Transport %s changed tx soft volume from %s to %s", transport_data->transport_path, pa_yes_no(transport->rx_soft_volume), pa_yes_no(rx_volume_control != HSPHFPD_VOLUME_CONTROL_REMOTE));
transport->tx_soft_volume = (rx_volume_control != HSPHFPD_VOLUME_CONTROL_REMOTE);
tx_soft_volume_changed = true;
}
if (transport_data->rx_volume_control != rx_volume_control) {
......@@ -499,32 +499,32 @@ static void parse_transport_properties(pa_bluetooth_transport *transport, DBusMe
}
if (rx_volume_gain != (uint16_t)-1) {
if (transport->microphone_gain != rx_volume_gain) {
pa_log_info("Transport %s changed microphone gain from %u to %u", transport_data->transport_path, (unsigned)transport->microphone_gain, (unsigned)rx_volume_gain);
transport->microphone_gain = rx_volume_gain;
if (transport->rx_volume_gain != rx_volume_gain) {
pa_log_info("Transport %s changed rx volume gain from %u to %u", transport_data->transport_path, (unsigned)transport->rx_volume_gain, (unsigned)rx_volume_gain);
transport->rx_volume_gain = rx_volume_gain;
rx_volume_gain_changed = true;
}
}
if (tx_volume_gain != (uint16_t)-1) {
if (transport->speaker_gain != tx_volume_gain) {
pa_log_info("Transport %s changed speaker gain from %u to %u", transport_data->transport_path, (unsigned)transport->speaker_gain, (unsigned)tx_volume_gain);
transport->speaker_gain = tx_volume_gain;
if (transport->tx_volume_gain != tx_volume_gain) {
pa_log_info("Transport %s changed tx volume gain from %u to %u", transport_data->transport_path, (unsigned)transport->tx_volume_gain, (unsigned)tx_volume_gain);
transport->tx_volume_gain = tx_volume_gain;
tx_volume_gain_changed = true;
}
}
if (rx_volume_gain_changed || rx_soft_volume_changed)
pa_hook_fire(pa_bluetooth_discovery_hook(transport_data->hsphfpd->discovery, PA_BLUETOOTH_HOOK_TRANSPORT_MICROPHONE_GAIN_CHANGED), transport);
pa_hook_fire(pa_bluetooth_discovery_hook(transport_data->hsphfpd->discovery, PA_BLUETOOTH_HOOK_TRANSPORT_RX_VOLUME_GAIN_CHANGED), transport);
if (tx_volume_gain_changed || tx_soft_volume_changed)
pa_hook_fire(pa_bluetooth_discovery_hook(transport_data->hsphfpd->discovery, PA_BLUETOOTH_HOOK_TRANSPORT_SPEAKER_GAIN_CHANGED), transport);
pa_hook_fire(pa_bluetooth_discovery_hook(transport_data->hsphfpd->discovery, PA_BLUETOOTH_HOOK_TRANSPORT_TX_VOLUME_GAIN_CHANGED), transport);
if (rx_volume_control_changed)
set_rx_volume_gain_property(transport_data, transport->microphone_gain);
set_rx_volume_gain_property(transport_data, transport->rx_volume_gain);
if (tx_volume_control_changed)
set_tx_volume_gain_property(transport_data, transport->speaker_gain);
set_tx_volume_gain_property(transport_data, transport->tx_volume_gain);
}
static void parse_endpoint_properties(pa_bluetooth_hsphfpd *hsphfpd, struct hsphfpd_endpoint *endpoint, DBusMessageIter *i) {
......@@ -645,15 +645,15 @@ static void parse_endpoint_properties(pa_bluetooth_hsphfpd *hsphfpd, struct hsph
/* By default we do not know if remote device supports hw volume control
* So use local softvol filter until remote device announce volume control support */
transport = pa_bluetooth_transport_new(device, hsphfpd->hsphfpd_service_id, endpoint->path, profile, NULL, 0);
transport->microphone_soft_volume = true;
transport->speaker_soft_volume = true;
transport->max_microphone_gain = 15;
transport->max_speaker_gain = 15;
transport->rx_soft_volume = true;
transport->tx_soft_volume = true;
transport->max_rx_volume_gain = 15;
transport->max_tx_volume_gain = 15;
transport->acquire = hsphfpd_transport_acquire;
transport->release = hsphfpd_transport_release;
transport->destroy = hsphfpd_transport_destroy;
transport->set_speaker_gain = hsphfpd_transport_set_speaker_gain;
transport->set_microphone_gain = hsphfpd_transport_set_microphone_gain;
transport->set_rx_volume_gain = hsphfpd_transport_set_rx_volume_gain;
transport->set_tx_volume_gain = hsphfpd_transport_set_tx_volume_gain;
transport->userdata = transport_data;
pa_bluetooth_transport_put(transport);
......@@ -960,13 +960,13 @@ static DBusMessage *hsphfpd_new_connection(pa_bluetooth_hsphfpd *hsphfpd, DBusMe
return r;
}
transport->microphone_soft_volume = (rx_volume_control != HSPHFPD_VOLUME_CONTROL_REMOTE);
transport->speaker_soft_volume = (tx_volume_control != HSPHFPD_VOLUME_CONTROL_REMOTE);
transport->microphone_gain = rx_volume_gain;
transport->speaker_gain = tx_volume_gain;
transport->rx_soft_volume = (rx_volume_control != HSPHFPD_VOLUME_CONTROL_REMOTE);
transport->tx_soft_volume = (tx_volume_control != HSPHFPD_VOLUME_CONTROL_REMOTE);
transport->rx_volume_gain = rx_volume_gain;
transport->tx_volume_gain = tx_volume_gain;
pa_hook_fire(pa_bluetooth_discovery_hook(hsphfpd->discovery, PA_BLUETOOTH_HOOK_TRANSPORT_MICROPHONE_GAIN_CHANGED), transport);
pa_hook_fire(pa_bluetooth_discovery_hook(hsphfpd->discovery, PA_BLUETOOTH_HOOK_TRANSPORT_SPEAKER_GAIN_CHANGED), transport);
pa_hook_fire(pa_bluetooth_discovery_hook(hsphfpd->discovery, PA_BLUETOOTH_HOOK_TRANSPORT_RX_VOLUME_GAIN_CHANGED), transport);
pa_hook_fire(pa_bluetooth_discovery_hook(hsphfpd->discovery, PA_BLUETOOTH_HOOK_TRANSPORT_TX_VOLUME_GAIN_CHANGED), transport);
transport_data->transport_path = pa_xstrdup(transport_path);
transport_data->agent_codec = pa_xstrdup("PCM_s16le_8kHz");
......
......@@ -356,12 +356,12 @@ static void rfcomm_io_callback(pa_mainloop_api *io, pa_io_event *e, int fd, pa_i
* We support only local AG role and only microphone and speaker gain commands.
* Leading space in sscanf format matches any amount of whitespace characters including none */
if (sscanf(buf, " AT+VGS=%d", &gain) == 1 || sscanf(buf, " +VGS=%d", &gain) == 1) {
t->speaker_gain = gain;
pa_hook_fire(pa_bluetooth_discovery_hook(t->device->discovery, PA_BLUETOOTH_HOOK_TRANSPORT_SPEAKER_GAIN_CHANGED), t);
t->tx_volume_gain = gain;
pa_hook_fire(pa_bluetooth_discovery_hook(t->device->discovery, PA_BLUETOOTH_HOOK_TRANSPORT_TX_VOLUME_GAIN_CHANGED), t);
success = true;
} else if (sscanf(buf, " AT+VGM=%d", &gain) == 1 || sscanf(buf, " +VGM=%d", &gain) == 1) {
t->microphone_gain = gain;
pa_hook_fire(pa_bluetooth_discovery_hook(t->device->discovery, PA_BLUETOOTH_HOOK_TRANSPORT_MICROPHONE_GAIN_CHANGED), t);
t->rx_volume_gain = gain;
pa_hook_fire(pa_bluetooth_discovery_hook(t->device->discovery, PA_BLUETOOTH_HOOK_TRANSPORT_RX_VOLUME_GAIN_CHANGED), t);
success = true;
} else {
success = false;
......@@ -406,15 +406,15 @@ static void transport_destroy(pa_bluetooth_transport *t) {
pa_xfree(trd);
}
static void set_speaker_gain(pa_bluetooth_transport *t, uint16_t gain) {
static void set_tx_volume_gain(pa_bluetooth_transport *t, uint16_t gain) {
struct transport_data *trd = t->userdata;
char buf[512];
ssize_t len, written;
if (t->speaker_gain == gain)
if (t->tx_volume_gain == gain)
return;
t->speaker_gain = gain;
t->tx_volume_gain = gain;
len = sprintf(buf, "\r\n+VGS=%d\r\n", gain);
pa_log_debug("RFCOMM >> +VGS=%d", gain);
......@@ -425,15 +425,15 @@ static void set_speaker_gain(pa_bluetooth_transport *t, uint16_t gain) {
pa_log_error("RFCOMM write error: %s", pa_cstrerror(errno));
}
static void set_microphone_gain(pa_bluetooth_transport *t, uint16_t gain) {
static void set_rx_volume_gain(pa_bluetooth_transport *t, uint16_t gain) {
struct transport_data *trd = t->userdata;
char buf[512];
ssize_t len, written;
if (t->microphone_gain == gain)
if (t->rx_volume_gain == gain)
return;
t->microphone_gain = gain;
t->rx_volume_gain = gain;
len = sprintf(buf, "\r\n+VGM=%d\r\n", gain);
pa_log_debug("RFCOMM >> +VGM=%d", gain);
......@@ -489,16 +489,16 @@ static DBusMessage *profile_new_connection(DBusConnection *conn, DBusMessage *m,
t = pa_bluetooth_transport_new(d, sender, path, PA_BLUETOOTH_PROFILE_HSP_HEAD_UNIT, NULL, 0);
/* Expects that remote HSP headset supports volume control and we do not need to use local softvol */
t->microphone_soft_volume = false;
t->speaker_soft_volume = false;
t->max_microphone_gain = 15;
t->max_speaker_gain = 15;
t->rx_soft_volume = false;
t->tx_soft_volume = false;
t->max_rx_volume_gain = 15;
t->max_tx_volume_gain = 15;
t->acquire = sco_acquire_cb;
t->release = sco_release_cb;
t->destroy = transport_destroy;
t->set_speaker_gain = set_speaker_gain;
t->set_microphone_gain = set_microphone_gain;
t->set_rx_volume_gain = set_rx_volume_gain;
t->set_tx_volume_gain = set_tx_volume_gain;
trd = pa_xnew0(struct transport_data, 1);
trd->rfcomm_fd = fd;
......
......@@ -95,8 +95,8 @@ struct userdata {
pa_hook_slot *device_connection_changed_slot;
pa_hook_slot *profile_connection_changed_slot;
pa_hook_slot *transport_state_changed_slot;
pa_hook_slot *transport_speaker_gain_changed_slot;
pa_hook_slot *transport_microphone_gain_changed_slot;
pa_hook_slot *transport_rx_volume_gain_changed_slot;
pa_hook_slot *transport_tx_volume_gain_changed_slot;
pa_bluetooth_discovery *discovery;
pa_bluetooth_device *device;
......@@ -988,15 +988,15 @@ static void source_set_volume_cb(pa_source *s) {
pa_assert(u);
pa_assert(u->source == s);
if (u->transport->set_microphone_gain == NULL)
if (u->transport->set_rx_volume_gain == NULL)
return;
gain = (pa_cvolume_max(&s->real_volume) * u->transport->max_microphone_gain) / PA_VOLUME_NORM;
gain = (pa_cvolume_max(&s->real_volume) * u->transport->max_rx_volume_gain) / PA_VOLUME_NORM;
if (gain > u->transport->max_microphone_gain)
gain = u->transport->max_microphone_gain;
if (gain > u->transport->max_rx_volume_gain)
gain = u->transport->max_rx_volume_gain;
volume = (pa_volume_t) (gain * PA_VOLUME_NORM / u->transport->max_microphone_gain);
volume = (pa_volume_t) (gain * PA_VOLUME_NORM / u->transport->max_rx_volume_gain);
/* increment volume by one to correct rounding errors */
if (volume < PA_VOLUME_NORM)
......@@ -1005,12 +1005,12 @@ static void source_set_volume_cb(pa_source *s) {
pa_cvolume_set(&s->real_volume, u->decoder_sample_spec.channels, volume);
/* Set soft volume when transport requires it, otherwise reset soft volume to default */
if (u->transport->microphone_soft_volume)
if (u->transport->rx_soft_volume)
pa_cvolume_set(&s->soft_volume, u->decoder_sample_spec.channels, volume);
else
pa_cvolume_reset(&s->soft_volume, u->decoder_sample_spec.channels);
u->transport->set_microphone_gain(u->transport, gain);
u->transport->set_rx_volume_gain(u->transport, gain);
}
/* Run from main thread */
......@@ -1051,7 +1051,7 @@ static int add_source(struct userdata *u) {
u->source->set_state_in_io_thread = source_set_state_in_io_thread_cb;
pa_source_set_set_volume_callback(u->source, source_set_volume_cb);
u->source->n_volume_steps = u->transport->max_microphone_gain + 1;
u->source->n_volume_steps = u->transport->max_rx_volume_gain + 1;
return 0;
}
......@@ -1157,15 +1157,15 @@ static void sink_set_volume_cb(pa_sink *s) {
pa_assert(u);
pa_assert(u->sink == s);
if (u->transport->set_speaker_gain == NULL)
if (u->transport->set_tx_volume_gain == NULL)
return;
gain = (pa_cvolume_max(&s->real_volume) * u->transport->max_speaker_gain) / PA_VOLUME_NORM;
gain = (pa_cvolume_max(&s->real_volume) * u->transport->max_tx_volume_gain) / PA_VOLUME_NORM;
if (gain > u->transport->max_speaker_gain)
gain = u->transport->max_speaker_gain;
if (gain > u->transport->max_tx_volume_gain)
gain = u->transport->max_tx_volume_gain;
volume = (pa_volume_t) (gain * PA_VOLUME_NORM / u->transport->max_speaker_gain);
volume = (pa_volume_t) (gain * PA_VOLUME_NORM / u->transport->max_tx_volume_gain);
/* increment volume by one to correct rounding errors */
if (volume < PA_VOLUME_NORM)
......@@ -1174,12 +1174,12 @@ static void sink_set_volume_cb(pa_sink *s) {
pa_cvolume_set(&s->real_volume, u->encoder_sample_spec.channels, volume);
/* Set soft volume when transport requires it, otherwise reset soft volume to default */
if (u->transport->speaker_soft_volume)
if (u->transport->tx_soft_volume)
pa_cvolume_set(&s->soft_volume, u->encoder_sample_spec.channels, volume);
else
pa_cvolume_reset(&s->soft_volume, u->encoder_sample_spec.channels);
u->transport->set_speaker_gain(u->transport, gain);
u->transport->set_tx_volume_gain(u->transport, gain);
}
/* Run from main thread */
......@@ -1220,7 +1220,7 @@ static int add_sink(struct userdata *u) {
u->sink->set_state_in_io_thread = sink_set_state_in_io_thread_cb;
pa_sink_set_set_volume_callback(u->sink, sink_set_volume_cb);
u->sink->n_volume_steps = u->transport->max_speaker_gain + 1;
u->sink->n_volume_steps = u->transport->max_tx_volume_gain + 1;
return 0;
}
......@@ -2425,7 +2425,7 @@ static pa_hook_result_t transport_state_changed_cb(pa_bluetooth_discovery *y, pa
return PA_HOOK_OK;
}
static pa_hook_result_t transport_speaker_gain_changed_cb(pa_bluetooth_discovery *y, pa_bluetooth_transport *t, struct userdata *u) {
static pa_hook_result_t transport_tx_volume_gain_changed_cb(pa_bluetooth_discovery *y, pa_bluetooth_transport *t, struct userdata *u) {
pa_volume_t volume;
pa_cvolume v;
uint16_t gain;
......@@ -2436,8 +2436,8 @@ static pa_hook_result_t transport_speaker_gain_changed_cb(pa_bluetooth_discovery
if (t != u->transport)
return PA_HOOK_OK;
gain = t->speaker_gain;
volume = (pa_volume_t) (gain * PA_VOLUME_NORM / t->max_speaker_gain);
gain = t->tx_volume_gain;
volume = (pa_volume_t) (gain * PA_VOLUME_NORM / t->max_tx_volume_gain);
/* increment volume by one to correct rounding errors */
if (volume < PA_VOLUME_NORM)
......@@ -2445,7 +2445,7 @@ static pa_hook_result_t transport_speaker_gain_changed_cb(pa_bluetooth_discovery
pa_cvolume_set(&v, u->encoder_sample_spec.channels, volume);
if (!t->speaker_soft_volume)
if (!t->tx_soft_volume)
pa_sink_volume_changed(u->sink, &v);
else
pa_sink_set_volume(u->sink, &v, true, true);
......@@ -2453,7 +2453,7 @@ static pa_hook_result_t transport_speaker_gain_changed_cb(pa_bluetooth_discovery
return PA_HOOK_OK;
}
static pa_hook_result_t transport_microphone_gain_changed_cb(pa_bluetooth_discovery *y, pa_bluetooth_transport *t, struct userdata *u) {
static pa_hook_result_t transport_rx_volume_gain_changed_cb(pa_bluetooth_discovery *y, pa_bluetooth_transport *t, struct userdata *u) {
pa_volume_t volume;
pa_cvolume v;
uint16_t gain;
......@@ -2464,8 +2464,8 @@ static pa_hook_result_t transport_microphone_gain_changed_cb(pa_bluetooth_discov
if (t != u->transport)
return PA_HOOK_OK;
gain = t->microphone_gain;
volume = (pa_volume_t) (gain * PA_VOLUME_NORM / t->max_microphone_gain);
gain = t->rx_volume_gain;
volume = (pa_volume_t) (gain * PA_VOLUME_NORM / t->max_rx_volume_gain);
/* increment volume by one to correct rounding errors */
if (volume < PA_VOLUME_NORM)
......@@ -2473,7 +2473,7 @@ static pa_hook_result_t transport_microphone_gain_changed_cb(pa_bluetooth_discov
pa_cvolume_set(&v, u->decoder_sample_spec.channels, volume);
if (!t->microphone_soft_volume)
if (!t->rx_soft_volume)
pa_source_volume_changed(u->source, &v);
else
pa_source_set_volume(u->source, &v, true, true);
......@@ -2560,11 +2560,11 @@ int pa__init(pa_module* m) {
pa_hook_connect(pa_bluetooth_discovery_hook(u->discovery, PA_BLUETOOTH_HOOK_TRANSPORT_STATE_CHANGED),
PA_HOOK_NORMAL, (pa_hook_cb_t) transport_state_changed_cb, u);
u->transport_speaker_gain_changed_slot =
pa_hook_connect(pa_bluetooth_discovery_hook(u->discovery, PA_BLUETOOTH_HOOK_TRANSPORT_SPEAKER_GAIN_CHANGED), PA_HOOK_NORMAL, (pa_hook_cb_t) transport_speaker_gain_changed_cb, u);
u->transport_rx_volume_gain_changed_slot =
pa_hook_connect(pa_bluetooth_discovery_hook(u->discovery, PA_BLUETOOTH_HOOK_TRANSPORT_RX_VOLUME_GAIN_CHANGED), PA_HOOK_NORMAL, (pa_hook_cb_t) transport_rx_volume_gain_changed_cb, u);
u->transport_microphone_gain_changed_slot =
pa_hook_connect(pa_bluetooth_discovery_hook(u->discovery, PA_BLUETOOTH_HOOK_TRANSPORT_MICROPHONE_GAIN_CHANGED), PA_HOOK_NORMAL, (pa_hook_cb_t) transport_microphone_gain_changed_cb, u);
u->transport_tx_volume_gain_changed_slot =
pa_hook_connect(pa_bluetooth_discovery_hook(u->discovery, PA_BLUETOOTH_HOOK_TRANSPORT_TX_VOLUME_GAIN_CHANGED), PA_HOOK_NORMAL, (pa_hook_cb_t) transport_tx_volume_gain_changed_cb, u);
if (add_card(u) < 0)
goto fail;
......@@ -2624,11 +2624,11 @@ void pa__done(pa_module *m) {
if (u->transport_state_changed_slot)
pa_hook_slot_free(u->transport_state_changed_slot);
if (u->transport_speaker_gain_changed_slot)
pa_hook_slot_free(u->transport_speaker_gain_changed_slot);
if (u->transport_rx_volume_gain_changed_slot)
pa_hook_slot_free(u->transport_rx_volume_gain_changed_slot);
if (u->transport_microphone_gain_changed_slot)
pa_hook_slot_free(u->transport_microphone_gain_changed_slot);
if (u->transport_tx_volume_gain_changed_slot)
pa_hook_slot_free(u->transport_tx_volume_gain_changed_slot);
if (u->encoder_buffer)
pa_xfree(u->encoder_buffer);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment