summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2007-09-16 15:05:26 +0000
committerLennart Poettering <lennart@poettering.net>2007-09-16 15:05:26 +0000
commit0469c8436655cb4cc422216ab8a13849080f14c0 (patch)
tree63b17e9d4e5a2554b3cf4ea4ee9c19c7c06d5fb5
parent298d2392f9b5e586977ddb7e31b45ec322998602 (diff)
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)
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1826 fefdeb5f-60dc-0310-8127-8f9354f1896f
-rw-r--r--src/pulsecore/sample-util.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/pulsecore/sample-util.c b/src/pulsecore/sample-util.c
index a1361f4e..add6608d 100644
--- a/src/pulsecore/sample-util.c
+++ b/src/pulsecore/sample-util.c
@@ -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 @@ void pa_silence_memchunk(pa_memchunk *c, const pa_sample_spec *spec) {
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 @@ void pa_volume_memchunk(
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;
+}
+