[pulseaudio-commits] r1826 - /branches/lennart/src/pulsecore/sample-util.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Sun Sep 16 08:05:27 PDT 2007


Author: lennart
Date: Sun Sep 16 17:05:26 2007
New Revision: 1826

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=1826&root=pulseaudio&view=rev
Log:
add frame alignment APIs; don't require memory to be writable when silencing it (required of the mmap modes drivers where the hw data needs to be silenced, although it is not writable to others)

Modified:
    branches/lennart/src/pulsecore/sample-util.c

Modified: branches/lennart/src/pulsecore/sample-util.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/sample-util.c?rev=1826&root=pulseaudio&r1=1825&r2=1826&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/sample-util.c (original)
+++ branches/lennart/src/pulsecore/sample-util.c Sun Sep 16 17:05:26 2007
@@ -38,7 +38,7 @@
 #include "sample-util.h"
 #include "endianmacros.h"
 
-#define PA_SILENCE_MAX (1024*1024*1)
+#define PA_SILENCE_MAX (PA_PAGE_SIZE*16)
 
 pa_memblock *pa_silence_memblock_new(pa_mempool *pool, const pa_sample_spec *spec, size_t length) {
     size_t fs;
@@ -82,7 +82,6 @@
     pa_assert(c->memblock);
     pa_assert(spec);
 
-    pa_memchunk_make_writable(c, 0);
     data = pa_memblock_acquire(c->memblock);
     pa_silence_memory((uint8_t*) data+c->index, c->length, spec);
     pa_memblock_release(c->memblock);
@@ -474,3 +473,23 @@
     pa_memblock_release(c->memblock);
 }
 
+size_t pa_frame_align(size_t l, const pa_sample_spec *ss) {
+    size_t fs;
+
+    pa_assert(ss);
+    
+    fs = pa_frame_size(ss);
+
+    return (l/fs) * fs;
+}
+
+int pa_frame_aligned(size_t l, const pa_sample_spec *ss) {
+    size_t fs;
+    
+    pa_assert(ss);
+
+    fs = pa_frame_size(ss);
+    
+    return l % fs == 0;
+}
+




More information about the pulseaudio-commits mailing list