[pulseaudio-commits] r1497 - /branches/lennart/src/pulsecore/protocol-simple.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Sun Jun 24 09:17:03 PDT 2007


Author: lennart
Date: Sun Jun 24 18:17:02 2007
New Revision: 1497

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=3D1497&root=3Dpulseaudio&vi=
ew=3Drev
Log:
Track the 'missing' variable safely between the threads

Modified:
    branches/lennart/src/pulsecore/protocol-simple.c

Modified: branches/lennart/src/pulsecore/protocol-simple.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/=
protocol-simple.c?rev=3D1497&root=3Dpulseaudio&r1=3D1496&r2=3D1497&view=3Dd=
iff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/pulsecore/protocol-simple.c (original)
+++ branches/lennart/src/pulsecore/protocol-simple.c Sun Jun 24 18:17:02 20=
07
@@ -123,7 +123,7 @@
 static void connection_drop(connection *c) {
     pa_assert(c);
     =

-    pa_idxset_remove_by_data(c->protocol->connections, c, NULL);
+    pa_assert_se(pa_idxset_remove_by_data(c->protocol->connections, c, NUL=
L) =3D=3D c);
 =

     if (c->sink_input) {
         pa_sink_input_disconnect(c->sink_input);
@@ -153,7 +153,7 @@
 =

     pa_assert(c);
 =

-    if (!c->sink_input || !(l =3D pa_atomic_load(&c->playback.missing)))
+    if (!c->sink_input || (l =3D pa_atomic_load(&c->playback.missing)) <=
=3D 0)
         return 0;
 =

     if (l > c->playback.fragment_size)
@@ -191,6 +191,7 @@
     c->playback.memblock_index +=3D r;
 =

     pa_asyncmsgq_post(c->sink_input->sink->asyncmsgq, PA_MSGOBJECT(c->sink=
_input), SINK_INPUT_MESSAGE_POST_DATA, NULL, &chunk, NULL);
+    pa_atomic_sub(&c->playback.missing, r);
 =

     return 0;
 }
@@ -309,7 +310,6 @@
 =

             /* New data from the main loop */
             pa_memblockq_push_align(c->input_memblockq, chunk);
-            pa_atomic_store(&c->playback.missing, pa_memblockq_missing(c->=
input_memblockq));
 =

 /*             pa_log("got data, %u", pa_memblockq_get_length(c->input_mem=
blockq)); */
             =

@@ -368,10 +368,10 @@
     pa_memblockq_drop(c->input_memblockq, chunk, length);
     new =3D pa_memblockq_missing(c->input_memblockq);
 =

-    pa_atomic_store(&c->playback.missing, new);
-
-    if (new > old)
-        pa_asyncmsgq_post(c->protocol->core->asyncmsgq, PA_MSGOBJECT(c), M=
ESSAGE_REQUEST_DATA, NULL, NULL, NULL);
+    if (new > old) {
+        if (pa_atomic_add(&c->playback.missing, new - old) <=3D 0)
+            pa_asyncmsgq_post(c->protocol->core->asyncmsgq, PA_MSGOBJECT(c=
), MESSAGE_REQUEST_DATA, NULL, NULL, NULL);
+    }
 }
 =

 /* Called from main context */




More information about the pulseaudio-commits mailing list