[pulseaudio-commits] r1627 - /branches/lennart/src/pulsecore/protocol-native.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Fri Aug 10 16:42:18 PDT 2007


Author: lennart
Date: Sat Aug 11 01:42:17 2007
New Revision: 1627

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=3D1627&root=3Dpulseaudio&vi=
ew=3Drev
Log:
make revoke/release thread safe in the native protocol

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

Modified: branches/lennart/src/pulsecore/protocol-native.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/=
protocol-native.c?rev=3D1627&root=3Dpulseaudio&r1=3D1626&r2=3D1627&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-native.c (original)
+++ branches/lennart/src/pulsecore/protocol-native.c Sat Aug 11 01:42:17 20=
07
@@ -139,7 +139,6 @@
     pa_time_event *auth_timeout_event;
 };
 =

-
 PA_DECLARE_CLASS(record_stream);
 #define RECORD_STREAM(o) (record_stream_cast(o))
 static PA_DEFINE_CHECK_TYPE(record_stream, pa_msgobject);
@@ -193,6 +192,11 @@
 =

 enum {
     RECORD_STREAM_MESSAGE_POST_DATA         /* data from source output to =
main loop */
+};
+
+enum {
+    CONNECTION_MESSAGE_RELEASE,
+    CONNECTION_MESSAGE_REVOKE
 };
 =

 static int sink_input_peek_cb(pa_sink_input *i, pa_memchunk *chunk);
@@ -681,6 +685,24 @@
     return s;
 }
 =

+static int connection_process_msg(pa_msgobject *o, int code, void*userdata=
, int64_t offset, pa_memchunk *chunk) {
+    connection *c =3D CONNECTION(o);
+    connection_assert_ref(c);
+
+    switch (code) {
+        =

+        case CONNECTION_MESSAGE_REVOKE:
+            pa_pstream_send_revoke(c->pstream, PA_PTR_TO_UINT(userdata));
+            break;
+
+        case CONNECTION_MESSAGE_RELEASE:
+            pa_pstream_send_release(c->pstream, PA_PTR_TO_UINT(userdata));
+            break;
+    }
+
+    return 0;
+}
+
 static void connection_unlink(connection *c) {
     record_stream *r;
     output_stream *o;
@@ -2702,6 +2724,24 @@
     send_memblock(c);
 }
 =

+static void pstream_revoke_callback(pa_pstream *p, uint32_t block_id, void=
 *userdata) {
+    pa_thread_mq *q;
+    =

+    if (!(q =3D pa_thread_mq_get()))
+        pa_pstream_send_revoke(p, block_id);
+    else
+        pa_asyncmsgq_post(q->outq, PA_MSGOBJECT(userdata), CONNECTION_MESS=
AGE_REVOKE, PA_UINT_TO_PTR(block_id), 0, NULL, NULL);
+}
+
+static void pstream_release_callback(pa_pstream *p, uint32_t block_id, voi=
d *userdata) {
+    pa_thread_mq *q;
+    =

+    if (!(q =3D pa_thread_mq_get()))
+        pa_pstream_send_release(p, block_id);
+    else
+        pa_asyncmsgq_post(q->outq, PA_MSGOBJECT(userdata), CONNECTION_MESS=
AGE_RELEASE, PA_UINT_TO_PTR(block_id), 0, NULL, NULL);
+}
+
 /*** client callbacks ***/
 =

 static void client_kill_cb(pa_client *c) {
@@ -2741,6 +2781,7 @@
 =

     c =3D pa_msgobject_new(connection);
     c->parent.parent.free =3D connection_free;
+    c->parent.process_msg =3D connection_process_msg;
 =

     c->authorized =3D !!p->public;
 =

@@ -2772,6 +2813,8 @@
     pa_pstream_set_recieve_memblock_callback(c->pstream, pstream_memblock_=
callback, c);
     pa_pstream_set_die_callback(c->pstream, pstream_die_callback, c);
     pa_pstream_set_drain_callback(c->pstream, pstream_drain_callback, c);
+    pa_pstream_set_revoke_callback(c->pstream, pstream_revoke_callback, c);
+    pa_pstream_set_release_callback(c->pstream, pstream_release_callback, =
c);
 =

     c->pdispatch =3D pa_pdispatch_new(p->core->mainloop, command_table, PA=
_COMMAND_MAX);
 =





More information about the pulseaudio-commits mailing list