summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2009-02-25 21:40:59 +0200
committerJohan Hedberg <johan.hedberg@nokia.com>2009-02-25 21:40:59 +0200
commit118aad507231bfa28b0621e389f7f717b0065671 (patch)
tree323e5a053050ee16a7bd42be554a9ffcc0c63378
parent1d164657cfacb49852950f697e3ecdabce8d9799 (diff)
Only request the lock when the client doesn't have it
-rw-r--r--audio/unix.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/audio/unix.c b/audio/unix.c
index 3d0b6d7b..2255b263 100644
--- a/audio/unix.c
+++ b/audio/unix.c
@@ -67,6 +67,7 @@ struct a2dp_data {
struct headset_data {
headset_lock_t lock;
+ gboolean locked;
};
struct unix_client {
@@ -314,7 +315,9 @@ static void headset_resume_complete(struct audio_device *dev, void *user_data)
if (!dev)
goto failed;
- if (!headset_lock(dev, hs->lock)) {
+ if (!hs->locked)
+ hs->locked = headset_lock(dev, hs->lock);
+ if (!hs->locked) {
error("Unable to lock headset");
goto failed;
}
@@ -323,6 +326,7 @@ static void headset_resume_complete(struct audio_device *dev, void *user_data)
if (client->data_fd < 0) {
error("Unable to get a SCO fd");
headset_unlock(dev, hs->lock);
+ hs->locked = FALSE;
goto failed;
}
@@ -343,6 +347,7 @@ static void headset_resume_complete(struct audio_device *dev, void *user_data)
if (unix_sendmsg_fd(client->sock, client->data_fd) < 0) {
error("unix_sendmsg_fd: %s(%d)", strerror(errno), errno);
headset_unlock(client->dev, hs->lock);
+ hs->locked = FALSE;
goto failed;
}
@@ -1107,8 +1112,10 @@ static gboolean client_cb(GIOChannel *chan, GIOCondition cond, gpointer data)
debug("Unix client disconnected (fd=%d)", client->sock);
switch (client->type) {
case TYPE_HEADSET:
- if (client->dev)
+ if (client->dev && hs->locked) {
headset_unlock(client->dev, hs->lock);
+ hs->locked = FALSE;
+ }
break;
case TYPE_SOURCE:
case TYPE_SINK: