summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-01-08 21:12:03 +0100
committerLennart Poettering <lennart@poettering.net>2009-01-08 21:12:03 +0100
commitaff7768fb1076b53bc8416fdbdcc454e4b52ec41 (patch)
tree53a559cebe18b4e74c72bd6f94cf6f3315548332 /src
parent2ff20ceccb7334b0d491fec119a324cda1045803 (diff)
Add new debuuging API pa_memchunk_dump_to_file()
Diffstat (limited to 'src')
-rw-r--r--src/pulsecore/sample-util.c27
-rw-r--r--src/pulsecore/sample-util.h2
2 files changed, 29 insertions, 0 deletions
diff --git a/src/pulsecore/sample-util.c b/src/pulsecore/sample-util.c
index 9f0f795c..414c1c81 100644
--- a/src/pulsecore/sample-util.c
+++ b/src/pulsecore/sample-util.c
@@ -27,6 +27,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+#include <stdio.h>
#include <liboil/liboilfuncs.h>
#include <liboil/liboil.h>
@@ -987,3 +988,29 @@ size_t pa_usec_to_bytes_round_up(pa_usec_t t, const pa_sample_spec *spec) {
return (size_t) u;
}
+
+void pa_memchunk_dump_to_file(pa_memchunk *c, const char *fn) {
+ FILE *f;
+ void *p;
+
+ pa_assert(c);
+ pa_assert(fn);
+
+ /* Only for debugging purposes */
+
+ f = fopen(fn, "a");
+
+ if (!f) {
+ pa_log_warn("Failed to open '%s': %s", fn, pa_cstrerror(errno));
+ return;
+ }
+
+ p = pa_memblock_acquire(c->memblock);
+
+ if (fwrite((uint8_t*) p + c->index, 1, c->length, f) != c->length)
+ pa_log_warn("Failed to write to '%s': %s", fn, pa_cstrerror(errno));
+
+ pa_memblock_release(c->memblock);
+
+ fclose(f);
+}
diff --git a/src/pulsecore/sample-util.h b/src/pulsecore/sample-util.h
index 2fe2c81d..36d19e48 100644
--- a/src/pulsecore/sample-util.h
+++ b/src/pulsecore/sample-util.h
@@ -81,4 +81,6 @@ void pa_sample_clamp(pa_sample_format_t format, void *dst, size_t dstr, const vo
pa_usec_t pa_bytes_to_usec_round_up(uint64_t length, const pa_sample_spec *spec);
size_t pa_usec_to_bytes_round_up(pa_usec_t t, const pa_sample_spec *spec);
+void pa_memchunk_dump_to_file(pa_memchunk *c, const char *fn);
+
#endif