mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
Add new debuuging API pa_memchunk_dump_to_file()
This commit is contained in:
parent
2ff20ceccb
commit
aff7768fb1
2 changed files with 29 additions and 0 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue