[pulseaudio-commits] r1626 - in /branches/lennart/src/pulsecore: pstream.c pstream.h

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Fri Aug 10 16:41:51 PDT 2007


Author: lennart
Date: Sat Aug 11 01:41:50 2007
New Revision: 1626

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=3D1626&root=3Dpulseaudio&vi=
ew=3Drev
Log:
add callbacks for the revoke/release stuff, so that we can make this thing =
thread-safe

Modified:
    branches/lennart/src/pulsecore/pstream.c
    branches/lennart/src/pulsecore/pstream.h

Modified: branches/lennart/src/pulsecore/pstream.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/=
pstream.c?rev=3D1626&root=3Dpulseaudio&r1=3D1625&r2=3D1626&view=3Ddiff
=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/pstream.c (original)
+++ branches/lennart/src/pulsecore/pstream.c Sat Aug 11 01:41:50 2007
@@ -155,6 +155,12 @@
     pa_pstream_notify_cb_t die_callback;
     void *die_callback_userdata;
 =

+    pa_pstream_block_id_cb_t revoke_callback;
+    void *revoke_callback_userdata;
+
+    pa_pstream_block_id_cb_t release_callback;
+    void *release_callback_userdata;
+
     pa_mempool *mempool;
 =

 #ifdef HAVE_CREDS
@@ -254,7 +260,11 @@
     p->drain_callback_userdata =3D NULL;
     p->die_callback =3D NULL;
     p->die_callback_userdata =3D NULL;
-
+    p->revoke_callback =3D NULL;
+    p->revoke_callback_userdata =3D NULL;
+    p->release_callback =3D NULL;
+    p->release_callback_userdata =3D NULL;
+    =

     p->mempool =3D pool;
 =

     p->use_shm =3D 0;
@@ -376,11 +386,8 @@
     p->mainloop->defer_enable(p->defer_event, 1);
 }
 =

-/* might be called from thread context */
-static void memimport_release_cb(pa_memimport *i, uint32_t block_id, void =
*userdata) {
+void pa_pstream_send_release(pa_pstream *p, uint32_t block_id) {
     struct item_info *item;
-    pa_pstream *p =3D userdata;
-
     pa_assert(p);
     pa_assert(PA_REFCNT_VALUE(p) > 0);
 =

@@ -401,10 +408,23 @@
 }
 =

 /* might be called from thread context */
-static void memexport_revoke_cb(pa_memexport *e, uint32_t block_id, void *=
userdata) {
+static void memimport_release_cb(pa_memimport *i, uint32_t block_id, void =
*userdata) {
+    pa_pstream *p =3D userdata;
+
+    pa_assert(p);
+    pa_assert(PA_REFCNT_VALUE(p) > 0);
+
+    if (p->dead)
+        return;
+
+    if (p->release_callback)
+        p->release_callback(p, block_id, p->release_callback_userdata);
+    else
+        pa_pstream_send_release(p, block_id);
+}
+
+void pa_pstream_send_revoke(pa_pstream *p, uint32_t block_id) {
     struct item_info *item;
-    pa_pstream *p =3D userdata;
-
     pa_assert(p);
     pa_assert(PA_REFCNT_VALUE(p) > 0);
 =

@@ -421,6 +441,19 @@
 =

     pa_queue_push(p->send_queue, item);
     p->mainloop->defer_enable(p->defer_event, 1);
+}
+
+/* might be called from thread context */
+static void memexport_revoke_cb(pa_memexport *e, uint32_t block_id, void *=
userdata) {
+    pa_pstream *p =3D userdata;
+
+    pa_assert(p);
+    pa_assert(PA_REFCNT_VALUE(p) > 0);
+
+    if (p->revoke_callback)
+        p->revoke_callback(p, block_id, p->revoke_callback_userdata);
+    else
+        pa_pstream_send_revoke(p, block_id);
 }
 =

 static void prepare_next_write_item(pa_pstream *p) {
@@ -875,6 +908,22 @@
     p->recieve_memblock_callback_userdata =3D userdata;
 }
 =

+void pa_pstream_set_release_callback(pa_pstream *p, pa_pstream_block_id_cb=
_t cb, void *userdata) {
+    pa_assert(p);
+    pa_assert(PA_REFCNT_VALUE(p) > 0);
+
+    p->release_callback =3D cb;
+    p->release_callback_userdata =3D userdata;
+}
+
+void pa_pstream_set_revoke_callback(pa_pstream *p, pa_pstream_block_id_cb_=
t cb, void *userdata) {
+    pa_assert(p);
+    pa_assert(PA_REFCNT_VALUE(p) > 0);
+
+    p->release_callback =3D cb;
+    p->release_callback_userdata =3D userdata;
+}
+
 int pa_pstream_is_pending(pa_pstream *p) {
     int b;
 =


Modified: branches/lennart/src/pulsecore/pstream.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/=
pstream.h?rev=3D1626&root=3Dpulseaudio&r1=3D1625&r2=3D1626&view=3Ddiff
=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/pstream.h (original)
+++ branches/lennart/src/pulsecore/pstream.h Sat Aug 11 01:41:50 2007
@@ -41,6 +41,7 @@
 typedef void (*pa_pstream_packet_cb_t)(pa_pstream *p, pa_packet *packet, c=
onst pa_creds *creds, void *userdata);
 typedef void (*pa_pstream_memblock_cb_t)(pa_pstream *p, uint32_t channel, =
int64_t offset, pa_seek_mode_t seek, const pa_memchunk *chunk, void *userda=
ta);
 typedef void (*pa_pstream_notify_cb_t)(pa_pstream *p, void *userdata);
+typedef void (*pa_pstream_block_id_cb_t)(pa_pstream *p, uint32_t block_id,=
 void *userdata);
 =

 pa_pstream* pa_pstream_new(pa_mainloop_api *m, pa_iochannel *io, pa_mempoo=
l *p);
 void pa_pstream_unref(pa_pstream*p);
@@ -48,12 +49,15 @@
 =

 void pa_pstream_send_packet(pa_pstream*p, pa_packet *packet, const pa_cred=
s *creds);
 void pa_pstream_send_memblock(pa_pstream*p, uint32_t channel, int64_t offs=
et, pa_seek_mode_t seek, const pa_memchunk *chunk);
+void pa_pstream_send_release(pa_pstream *p, uint32_t block_id);
+void pa_pstream_send_revoke(pa_pstream *p, uint32_t block_id);
 =

 void pa_pstream_set_recieve_packet_callback(pa_pstream *p, pa_pstream_pack=
et_cb_t cb, void *userdata);
 void pa_pstream_set_recieve_memblock_callback(pa_pstream *p, pa_pstream_me=
mblock_cb_t cb, void *userdata);
 void pa_pstream_set_drain_callback(pa_pstream *p, pa_pstream_notify_cb_t c=
b, void *userdata);
-
 void pa_pstream_set_die_callback(pa_pstream *p, pa_pstream_notify_cb_t cb,=
 void *userdata);
+void pa_pstream_set_release_callback(pa_pstream *p, pa_pstream_block_id_cb=
_t cb, void *userdata);
+void pa_pstream_set_revoke_callback(pa_pstream *p, pa_pstream_block_id_cb_=
t cb, void *userdata);
 =

 int pa_pstream_is_pending(pa_pstream *p);
 =





More information about the pulseaudio-commits mailing list