[pulseaudio-commits] r1909 - /branches/lennart/src/pulsecore/asyncmsgq.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Thu Sep 27 17:29:52 PDT 2007


Author: lennart
Date: Fri Sep 28 02:29:51 2007
New Revision: 1909

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=1909&root=pulseaudio&view=rev
Log:
speed up semaphore allocation with an flist

Modified:
    branches/lennart/src/pulsecore/asyncmsgq.c

Modified: branches/lennart/src/pulsecore/asyncmsgq.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/asyncmsgq.c?rev=1909&root=pulseaudio&r1=1908&r2=1909&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/asyncmsgq.c (original)
+++ branches/lennart/src/pulsecore/asyncmsgq.c Fri Sep 28 02:29:51 2007
@@ -40,6 +40,7 @@
 #include "asyncmsgq.h"
 
 PA_STATIC_FLIST_DECLARE(asyncmsgq, 0, pa_xfree);
+PA_STATIC_FLIST_DECLARE(semaphores, 0, (void(*)(void*)) pa_semaphore_free);
 
 struct asyncmsgq_item {
     int code;
@@ -154,7 +155,11 @@
         i.memchunk = *chunk;
     } else
         pa_memchunk_reset(&i.memchunk);
-    pa_assert_se(i.semaphore = pa_semaphore_new(0));
+
+    if (!(i.semaphore = pa_flist_pop(PA_STATIC_FLIST_GET(semaphores))))
+        i.semaphore = pa_semaphore_new(0);
+
+    pa_assert_se(i.semaphore);
 
     /* Thus mutex makes the queue multiple-writer safe. This lock is only used on the writing side */
     pa_mutex_lock(a->mutex);
@@ -162,7 +167,9 @@
     pa_mutex_unlock(a->mutex);
 
     pa_semaphore_wait(i.semaphore);
-    pa_semaphore_free(i.semaphore);
+
+    if (pa_flist_push(PA_STATIC_FLIST_GET(semaphores), i.semaphore) < 0)
+        pa_semaphore_free(i.semaphore);
 
     return i.ret;
 }
@@ -192,7 +199,7 @@
         *chunk = a->current->memchunk;
 
 /*     pa_log_debug("Get q=%p object=%p (%s) code=%i data=%p chunk.length=%lu", (void*) a, (void*) a->current->object, a->current->object ? a->current->object->parent.type_name : NULL, a->current->code, (void*) a->current->userdata, (unsigned long) a->current->memchunk.length); */
-    
+
     return 0;
 }
 
@@ -244,7 +251,7 @@
     } while (c != code);
 
     pa_asyncmsgq_unref(a);
-    
+
     return 0;
 }
 
@@ -257,15 +264,15 @@
     int ret;
 
     pa_assert(PA_REFCNT_VALUE(a) > 0);
-    
+
     if (pa_asyncmsgq_get(a, &object, &code, &data, &offset, &chunk, 0) < 0)
         return 0;
-    
+
     pa_asyncmsgq_ref(a);
     ret = pa_asyncmsgq_dispatch(object, code, data, offset, &chunk);
     pa_asyncmsgq_done(a, ret);
     pa_asyncmsgq_unref(a);
-    
+
     return 1;
 }
 




More information about the pulseaudio-commits mailing list