summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Raghavan <arun.raghavan@collabora.co.uk>2013-08-16 07:30:44 +0530
committerArun Raghavan <arun.raghavan@collabora.co.uk>2013-08-16 15:54:20 +0530
commit324b86579f7b98365c7ac69f692574ddee612bc2 (patch)
tree5df10826afc72ac0205dbcedbfe9173cc7dbfde1
parente6770e10b91faa0dd63a98e891587f4b3e167130 (diff)
Fix disable device make CSD daemon
disable-device should only be run before the next enable-device and not before a stop-voice. We'd like to keep the disable-device in the DisableSequence in UCM for cleanliness, so we'll hide this detail away in the daemon.
-rw-r--r--tools/mako/csd-daemon.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/tools/mako/csd-daemon.c b/tools/mako/csd-daemon.c
index da20a8e..955fd6e 100644
--- a/tools/mako/csd-daemon.c
+++ b/tools/mako/csd-daemon.c
@@ -47,6 +47,7 @@ struct state {
int sockfd;
int rx_dev, tx_dev;
int start_voice;
+ int disable_device;
};
static struct state state;
@@ -192,7 +193,15 @@ static int process(const char *command)
/* Only enable device after we get both rx and tx device */
if (state.rx_dev != -1 && state.tx_dev != -1) {
- ret = csd_client_enable_device(state.rx_dev, state.tx_dev, ACDB_SETTINGS);
+ if (state.disable_device) {
+ state.disable_device = 0;
+ ret = csd_client_disable_device();
+ }
+
+ if (ret == 0) {
+ ret = csd_client_enable_device(state.rx_dev, state.tx_dev,
+ ACDB_SETTINGS);
+ }
if (ret == 0 && state.start_voice) {
state.start_voice = 0;
@@ -201,7 +210,10 @@ static int process(const char *command)
}
} else if (strcmp(command, "disable-device") == 0) {
- ret = csd_client_disable_device();
+ /* We need to disable the device before an enable-device but _after_
+ * stop-voice. Since we don't know what's coming next, we wait for
+ * these to happen before actually executing the command. */
+ state.disable_device = 1;
} else if (strncmp(command, "volume", 6) == 0) {
int volume;
@@ -234,8 +246,10 @@ static int process(const char *command)
} else if (strcmp(command, "stop-voice") == 0) {
ret = csd_client_stop_voice();
+
/* Reset all the things */
state.start_voice = 0;
+ state.disable_device = 0;
state.rx_dev = state.tx_dev = -1;
} else {