mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-12-16 08:56:40 -05:00
implement proper logging
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@179 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
57e473b61c
commit
6c4fd62040
50 changed files with 416 additions and 225 deletions
|
|
@ -38,6 +38,7 @@
|
|||
#include "sample-util.h"
|
||||
#include "alsa-util.h"
|
||||
#include "xmalloc.h"
|
||||
#include "log.h"
|
||||
|
||||
struct userdata {
|
||||
snd_pcm_t *pcm_handle;
|
||||
|
|
@ -73,10 +74,10 @@ static void update_usage(struct userdata *u) {
|
|||
static void xrun_recovery(struct userdata *u) {
|
||||
assert(u);
|
||||
|
||||
fprintf(stderr, "*** ALSA-XRUN (playback) ***\n");
|
||||
pa_log(__FILE__": *** ALSA-XRUN (playback) ***\n");
|
||||
|
||||
if (snd_pcm_prepare(u->pcm_handle) < 0)
|
||||
fprintf(stderr, "snd_pcm_prepare() failed\n");
|
||||
pa_log(__FILE__": snd_pcm_prepare() failed\n");
|
||||
}
|
||||
|
||||
static void do_write(struct userdata *u) {
|
||||
|
|
@ -108,7 +109,7 @@ static void do_write(struct userdata *u) {
|
|||
continue;
|
||||
}
|
||||
|
||||
fprintf(stderr, "snd_pcm_writei() failed\n");
|
||||
pa_log(__FILE__": snd_pcm_writei() failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -144,7 +145,7 @@ static uint32_t sink_get_latency_cb(struct pa_sink *s) {
|
|||
assert(s && u && u->sink);
|
||||
|
||||
if (snd_pcm_delay(u->pcm_handle, &frames) < 0) {
|
||||
fprintf(stderr, __FILE__": failed to get delay\n");
|
||||
pa_log(__FILE__": failed to get delay\n");
|
||||
s->get_latency = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -166,13 +167,13 @@ int pa_module_init(struct pa_core *c, struct pa_module*m) {
|
|||
size_t frame_size;
|
||||
|
||||
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
|
||||
fprintf(stderr, __FILE__": failed to parse module arguments\n");
|
||||
pa_log(__FILE__": failed to parse module arguments\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ss = c->default_sample_spec;
|
||||
if (pa_modargs_get_sample_spec(ma, &ss) < 0) {
|
||||
fprintf(stderr, __FILE__": failed to parse sample specification\n");
|
||||
pa_log(__FILE__": failed to parse sample specification\n");
|
||||
goto fail;
|
||||
}
|
||||
frame_size = pa_frame_size(&ss);
|
||||
|
|
@ -180,7 +181,7 @@ int pa_module_init(struct pa_core *c, struct pa_module*m) {
|
|||
periods = 12;
|
||||
fragsize = 1024;
|
||||
if (pa_modargs_get_value_u32(ma, "fragments", &periods) < 0 || pa_modargs_get_value_u32(ma, "fragment_size", &fragsize) < 0) {
|
||||
fprintf(stderr, __FILE__": failed to parse buffer metrics\n");
|
||||
pa_log(__FILE__": failed to parse buffer metrics\n");
|
||||
goto fail;
|
||||
}
|
||||
buffer_size = fragsize/frame_size*periods;
|
||||
|
|
@ -190,12 +191,12 @@ int pa_module_init(struct pa_core *c, struct pa_module*m) {
|
|||
u->module = m;
|
||||
|
||||
if (snd_pcm_open(&u->pcm_handle, dev = pa_modargs_get_value(ma, "device", DEFAULT_DEVICE), SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK) < 0) {
|
||||
fprintf(stderr, __FILE__": Error opening PCM device %s\n", dev);
|
||||
pa_log(__FILE__": Error opening PCM device %s\n", dev);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (pa_alsa_set_hw_params(u->pcm_handle, &ss, &periods, &buffer_size) < 0) {
|
||||
fprintf(stderr, __FILE__": Failed to set hardware parameters\n");
|
||||
pa_log(__FILE__": Failed to set hardware parameters\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
|
@ -208,14 +209,14 @@ int pa_module_init(struct pa_core *c, struct pa_module*m) {
|
|||
u->sink->description = pa_sprintf_malloc("Advanced Linux Sound Architecture PCM on '%s'", dev);
|
||||
|
||||
if (pa_create_io_events(u->pcm_handle, c->mainloop, &u->io_events, &u->n_io_events, io_callback, u) < 0) {
|
||||
fprintf(stderr, __FILE__": failed to obtain file descriptors\n");
|
||||
pa_log(__FILE__": failed to obtain file descriptors\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
u->frame_size = frame_size;
|
||||
u->fragment_size = buffer_size*u->frame_size/periods;
|
||||
|
||||
fprintf(stderr, __FILE__": using %u fragments of size %u bytes.\n", periods, u->fragment_size);
|
||||
pa_log(__FILE__": using %u fragments of size %u bytes.\n", periods, u->fragment_size);
|
||||
|
||||
u->silence.memblock = pa_memblock_new(u->silence.length = u->fragment_size, c->memblock_stat);
|
||||
assert(u->silence.memblock);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue