Add new debuuging API pa_memchunk_dump_to_file()

This commit is contained in:
Lennart Poettering 2009-01-08 21:12:03 +01:00
parent 2ff20ceccb
commit aff7768fb1
2 changed files with 29 additions and 0 deletions

View file

@ -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);
}

View file

@ -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