diff options
author | Mikel Astiz <mikel.astiz@bmw-carit.de> | 2012-08-31 12:50:55 +0200 |
---|---|---|
committer | Jaska Uimonen <jaska.uimonen@intel.com> | 2013-01-24 09:29:36 +0200 |
commit | 6ac06377e20083da361f4357b4991249e4a56214 (patch) | |
tree | 9ea6871e1bcf70b0948795a1b83c8899851b77bb | |
parent | 360852731ce0290ee657e13d7fa9ae0602f083d9 (diff) | |
download | pulseaudio-panda-6ac06377e20083da361f4357b4991249e4a56214.tar.gz pulseaudio-panda-6ac06377e20083da361f4357b4991249e4a56214.tar.bz2 pulseaudio-panda-6ac06377e20083da361f4357b4991249e4a56214.zip |
bluetooth: Refactor code to helper function
Make code more readable by introducing the helper function
bt_transport_is_acquired(). This also adds assertions to check whether
the internal state is consistent.
-rw-r--r-- | src/modules/bluetooth/module-bluetooth-device.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c index 7b4164d2..115416dc 100644 --- a/src/modules/bluetooth/module-bluetooth-device.c +++ b/src/modules/bluetooth/module-bluetooth-device.c @@ -279,12 +279,22 @@ static void setup_stream(struct userdata *u) { TRUE); } +static bool bt_transport_is_acquired(struct userdata *u) { + if (u->accesstype == NULL) { + pa_assert(u->stream_fd < 0); + return FALSE; + } else { + pa_assert(u->stream_fd >= 0); + return TRUE; + } +} + static void bt_transport_release(struct userdata *u) { const char *accesstype = "rw"; const pa_bluetooth_transport *t; /* Ignore if already released */ - if (!u->accesstype) + if (!bt_transport_is_acquired(u)) return; pa_log_debug("Releasing transport %s", u->transport); @@ -316,7 +326,7 @@ static int bt_transport_acquire(struct userdata *u, pa_bool_t start) { const char *accesstype = "rw"; const pa_bluetooth_transport *t; - if (u->accesstype) { + if (bt_transport_is_acquired(u)) { if (start) goto done; return 0; |