diff options
author | mogorman <mogorman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-10-03 15:53:07 +0000 |
---|---|---|
committer | mogorman <mogorman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-10-03 15:53:07 +0000 |
commit | 4a1aaf52ae4189e660ad57ba69253f54603a2beb (patch) | |
tree | 27a80e26cf8f6ea1728ab5b2b8cc7573fd9f7cdc /channels/chan_alsa.c | |
parent | 1bd1494da59a95dce73628aafc4ba892036b82b2 (diff) |
bug #8076 check option_debug before printing to debug channel.
patch provided in bugnote, with minor changes.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@44253 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_alsa.c')
-rw-r--r-- | channels/chan_alsa.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/channels/chan_alsa.c b/channels/chan_alsa.c index 15e0222b7..44dc22fc3 100644 --- a/channels/chan_alsa.c +++ b/channels/chan_alsa.c @@ -366,8 +366,10 @@ static snd_pcm_t *alsa_card_init(char *dev, snd_pcm_stream_t stream) if (err < 0) { ast_log(LOG_ERROR, "snd_pcm_open failed: %s\n", snd_strerror(err)); return NULL; - } else - ast_log(LOG_DEBUG, "Opening device %s in %s mode\n", dev, (stream == SND_PCM_STREAM_CAPTURE) ? "read" : "write"); + } else { + if (option_debug) + ast_log(LOG_DEBUG, "Opening device %s in %s mode\n", dev, (stream == SND_PCM_STREAM_CAPTURE) ? "read" : "write"); + } snd_pcm_hw_params_alloca(&hwparams); snd_pcm_hw_params_any(handle, hwparams); @@ -393,15 +395,19 @@ static snd_pcm_t *alsa_card_init(char *dev, snd_pcm_stream_t stream) err = snd_pcm_hw_params_set_period_size_near(handle, hwparams, &period_size, &direction); if (err < 0) ast_log(LOG_ERROR, "period_size(%ld frames) is bad: %s\n", period_size, snd_strerror(err)); - else - ast_log(LOG_DEBUG, "Period size is %d\n", err); + else { + if (option_debug) + ast_log(LOG_DEBUG, "Period size is %d\n", err); + } buffer_size = 4096 * 2; /* period_size * 16; */ err = snd_pcm_hw_params_set_buffer_size_near(handle, hwparams, &buffer_size); if (err < 0) ast_log(LOG_WARNING, "Problem setting buffer size of %ld: %s\n", buffer_size, snd_strerror(err)); - else - ast_log(LOG_DEBUG, "Buffer size is set to %d frames\n", err); + else { + if (option_debug) + ast_log(LOG_DEBUG, "Buffer size is set to %d frames\n", err); + } #if 0 direction = 0; @@ -460,11 +466,14 @@ static snd_pcm_t *alsa_card_init(char *dev, snd_pcm_stream_t stream) err = snd_pcm_poll_descriptors_count(handle); if (err <= 0) ast_log(LOG_ERROR, "Unable to get a poll descriptors count, error is %s\n", snd_strerror(err)); - if (err != 1) - ast_log(LOG_DEBUG, "Can't handle more than one device\n"); + if (err != 1) { + if (option_debug) + ast_log(LOG_DEBUG, "Can't handle more than one device\n"); + } snd_pcm_poll_descriptors(handle, &pfd, err); - ast_log(LOG_DEBUG, "Acquired fd %d from the poll descriptor\n", pfd.fd); + if (option_debug) + ast_log(LOG_DEBUG, "Acquired fd %d from the poll descriptor\n", pfd.fd); if (stream == SND_PCM_STREAM_CAPTURE) readdev = pfd.fd; @@ -628,7 +637,8 @@ static int alsa_write(struct ast_channel *chan, struct ast_frame *f) res = snd_pcm_writei(alsa.ocard, sizbuf, len / 2); if (res == -EPIPE) { #if DEBUG - ast_log(LOG_DEBUG, "XRUN write\n"); + if (option_debug) + ast_log(LOG_DEBUG, "XRUN write\n"); #endif snd_pcm_prepare(alsa.ocard); res = snd_pcm_writei(alsa.ocard, sizbuf, len / 2); |