aboutsummaryrefslogtreecommitdiff
path: root/audio/headset.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz-von@nokia.com>2010-05-25 11:21:46 +0300
committerLuiz Augusto von Dentz <luiz.dentz-von@nokia.com>2010-05-25 11:21:46 +0300
commitee23600edd07e0eb99a5dfed7523916e3de5d319 (patch)
tree7dff77a86f2f00e95d04baf8c0ae0025c9178ee4 /audio/headset.c
parentcb6c0b1058c6db25dce4c21f4de73a5ca1b1b831 (diff)
downloadbluez-ee23600edd07e0eb99a5dfed7523916e3de5d319.tar.gz
Fix redundant speaker/microphone gains being sent
Both D-Bus signals and +VG command are being sent without checking if their values have really changed, this is similar to ignore redundant option used in telephony indicators so we don't disturb the connections with redundant information.
Diffstat (limited to 'audio/headset.c')
-rw-r--r--audio/headset.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/audio/headset.c b/audio/headset.c
index 9a5d7674..045194fd 100644
--- a/audio/headset.c
+++ b/audio/headset.c
@@ -1892,6 +1892,7 @@ static DBusMessage *hs_set_gain(DBusConnection *conn,
struct audio_device *device = data;
struct headset *hs = device->headset;
struct headset_slc *slc = hs->slc;
+ const char *signal;
DBusMessage *reply;
int err;
@@ -1909,6 +1910,24 @@ static DBusMessage *hs_set_gain(DBusConnection *conn,
if (!reply)
return NULL;
+ if (type == HEADSET_GAIN_SPEAKER) {
+ if (slc->sp_gain == gain) {
+ debug("Ignoring no-change in speaker gain");
+ return reply;
+ }
+
+ slc->sp_gain = gain;
+ signal = "SpeakerGainChanged";
+ } else {
+ if (slc->mic_gain == gain) {
+ debug("Ignoring no-change in microphone gain");
+ return reply;
+ }
+
+ slc->mic_gain = gain;
+ signal = "MicrophoneGainChanged";
+ }
+
if (hs->state != HEADSET_STATE_PLAYING)
goto done;
@@ -1920,21 +1939,10 @@ static DBusMessage *hs_set_gain(DBusConnection *conn,
}
done:
- if (type == HEADSET_GAIN_SPEAKER) {
- slc->sp_gain = gain;
- g_dbus_emit_signal(conn, device->path,
- AUDIO_HEADSET_INTERFACE,
- "SpeakerGainChanged",
- DBUS_TYPE_UINT16, &gain,
- DBUS_TYPE_INVALID);
- } else {
- slc->mic_gain = gain;
- g_dbus_emit_signal(conn, device->path,
- AUDIO_HEADSET_INTERFACE,
- "MicrophoneGainChanged",
- DBUS_TYPE_UINT16, &gain,
- DBUS_TYPE_INVALID);
- }
+ g_dbus_emit_signal(conn, device->path,
+ AUDIO_HEADSET_INTERFACE, signal,
+ DBUS_TYPE_UINT16, &gain,
+ DBUS_TYPE_INVALID);
return reply;
}