]> code.delx.au - pulseaudio/commitdiff
bluetooth: destruct stream only if it is not already destructed
authorLennart Poettering <lennart@poettering.net>
Fri, 8 Jan 2010 21:18:15 +0000 (22:18 +0100)
committerColin Guthrie <cguthrie@mandriva.org>
Tue, 9 Feb 2010 22:29:56 +0000 (22:29 +0000)
https://bugzilla.redhat.com/show_bug.cgi?id=551842

src/modules/bluetooth/module-bluetooth-device.c

index 19676dfaa57a32aa2eb1330126e9543dcce9c977..2bbae412065defa5b8212bf5cc33e85b69195202 100644 (file)
@@ -823,23 +823,25 @@ static int stop_stream_fd(struct userdata *u) {
 
     pa_assert(u);
     pa_assert(u->rtpoll);
-    pa_assert(u->rtpoll_item);
-    pa_assert(u->stream_fd >= 0);
 
-    pa_rtpoll_item_free(u->rtpoll_item);
-    u->rtpoll_item = NULL;
+    if (u->rtpoll_item) {
+        pa_rtpoll_item_free(u->rtpoll_item);
+        u->rtpoll_item = NULL;
+    }
 
-    memset(msg.buf, 0, BT_SUGGESTED_BUFFER_SIZE);
-    msg.start_req.h.type = BT_REQUEST;
-    msg.start_req.h.name = BT_STOP_STREAM;
-    msg.start_req.h.length = sizeof(msg.start_req);
+    if (u->stream_fd >= 0) {
+        memset(msg.buf, 0, BT_SUGGESTED_BUFFER_SIZE);
+        msg.start_req.h.type = BT_REQUEST;
+        msg.start_req.h.name = BT_STOP_STREAM;
+        msg.start_req.h.length = sizeof(msg.start_req);
 
-    if (service_send(u, &msg.start_req.h) < 0 ||
-        service_expect(u, &msg.rsp, sizeof(msg), BT_STOP_STREAM, sizeof(msg.start_rsp)) < 0)
-        r = -1;
+        if (service_send(u, &msg.start_req.h) < 0 ||
+            service_expect(u, &msg.rsp, sizeof(msg), BT_STOP_STREAM, sizeof(msg.start_rsp)) < 0)
+            r = -1;
 
-    pa_close(u->stream_fd);
-    u->stream_fd = -1;
+        pa_close(u->stream_fd);
+        u->stream_fd = -1;
+    }
 
     if (u->read_smoother) {
         pa_smoother_free(u->read_smoother);