From: Lennart Poettering Date: Mon, 7 Apr 2008 16:46:13 +0000 (+0000) Subject: add utility functions to dump alsa PCM state X-Git-Tag: submit/2.0-panda/20130828.192557~2837^2^2~179 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=98b0152d7c9fe219448edfd61777b8f7357da25c;p=profile%2Fivi%2Fpulseaudio-panda.git add utility functions to dump alsa PCM state git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/glitch-free@2219 fefdeb5f-60dc-0310-8127-8f9354f1896f --- diff --git a/src/modules/alsa-util.c b/src/modules/alsa-util.c index 38ea863..c8f594a 100644 --- a/src/modules/alsa-util.c +++ b/src/modules/alsa-util.c @@ -894,3 +894,46 @@ void pa_alsa_0dB_capture(snd_mixer_elem_t *elem) { snd_mixer_selem_set_capture_volume_all(elem, v); } + +void pa_alsa_dump(snd_pcm_t *pcm) { + int err; + snd_output_t *out; + + pa_assert(pcm); + + pa_assert_se(snd_output_buffer_open(&out) == 0); + + if ((err = snd_pcm_dump(pcm, out)) < 0) + pa_log_debug("snd_pcm_dump(): %s", snd_strerror(err)); + else { + char *s = NULL; + snd_output_buffer_string(out, &s); + pa_log_debug("snd_pcm_dump():\n%s", pa_strnull(s)); + } + + pa_assert_se(snd_output_close(out) == 0); +} + +void pa_alsa_dump_status(snd_pcm_t *pcm) { + int err; + snd_output_t *out; + snd_pcm_status_t *status; + + pa_assert(pcm); + + snd_pcm_status_alloca(&status); + + pa_assert_se(snd_output_buffer_open(&out) == 0); + + pa_assert_se(snd_pcm_status(pcm, status) == 0); + + if ((err = snd_pcm_status_dump(status, out)) < 0) + pa_log_debug("snd_pcm_dump(): %s", snd_strerror(err)); + else { + char *s = NULL; + snd_output_buffer_string(out, &s); + pa_log_debug("snd_pcm_dump():\n%s", pa_strnull(s)); + } + + pa_assert_se(snd_output_close(out) == 0); +} diff --git a/src/modules/alsa-util.h b/src/modules/alsa-util.h index dee955f..0e536f1 100644 --- a/src/modules/alsa-util.h +++ b/src/modules/alsa-util.h @@ -82,4 +82,7 @@ int pa_alsa_calc_mixer_map(snd_mixer_elem_t *elem, const pa_channel_map *channel void pa_alsa_0dB_playback(snd_mixer_elem_t *elem); void pa_alsa_0dB_capture(snd_mixer_elem_t *elem); +void pa_alsa_dump(snd_pcm_t *pcm); +void pa_alsa_dump_status(snd_pcm_t *pcm); + #endif