--- chan_alsa.c.org 2004-03-24 03:45:07.257879616 +0000 +++ chan_alsa.c 2004-03-24 04:27:14.800634712 +0000 @@ -26,7 +26,11 @@ #include #include #include + +#define ALSA_PCM_NEW_HW_PARAMS_API +#define ALSA_PCM_NEW_SW_PARAMS_API #include + #include "busy.h" #include "ringtone.h" #include "ring10.h" @@ -316,13 +320,14 @@ static snd_pcm_t *alsa_card_init(char *dev, snd_pcm_stream_t stream) { int err; + int direction; snd_pcm_t *handle = NULL; snd_pcm_hw_params_t *hwparams = NULL; snd_pcm_sw_params_t *swparams = NULL; struct pollfd pfd; - int period_size = PERIOD_FRAMES * 4; + snd_pcm_uframes_t period_size = PERIOD_FRAMES * 4; //int period_bytes = 0; - int buffer_size = 0; + snd_pcm_uframes_t buffer_size = 0; unsigned int rate = DESIRED_RATE; unsigned int per_min = 1; @@ -354,36 +359,36 @@ if (err < 0) { ast_log(LOG_ERROR, "set_channels failed: %s\n", snd_strerror(err)); } - - rate = snd_pcm_hw_params_set_rate_near(handle, hwparams, rate, 0); + direction = 0; + err = snd_pcm_hw_params_set_rate_near(handle, hwparams, &rate, &direction); if (rate != DESIRED_RATE) { ast_log(LOG_WARNING, "Rate not correct, requested %d, got %d\n", DESIRED_RATE, rate); } - err = snd_pcm_hw_params_set_period_size_near(handle, hwparams, period_size, 0); + direction = 0; + err = snd_pcm_hw_params_set_period_size_near(handle, hwparams, &period_size, &direction); if (err < 0) { - ast_log(LOG_ERROR, "period_size(%d frames) is bad: %s\n", period_size, snd_strerror(err)); + 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); } - period_size = err; buffer_size = 4096 * 2; //period_size * 16; - err = snd_pcm_hw_params_set_buffer_size_near(handle, hwparams, buffer_size); + 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 %d: %s\n", buffer_size, snd_strerror(err)); + 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); } - buffer_size = err; - err = snd_pcm_hw_params_set_periods_min(handle, hwparams, &per_min, 0); +#if 0 + direction = 0; + err = snd_pcm_hw_params_set_periods_min(handle, hwparams, &per_min, &direction); if (err < 0) { ast_log(LOG_ERROR, "periods_min: %s\n", snd_strerror(err)); } -#if 0 err = snd_pcm_hw_params_set_periods_max(handle, hwparams, &per_max, 0); if (err < 0) { ast_log(LOG_ERROR, "periods_max: %s\n", snd_strerror(err)); @@ -429,10 +434,12 @@ } #endif +#if 0 err = snd_pcm_sw_params_set_silence_threshold(handle, swparams, silencethreshold); if (err < 0) { ast_log(LOG_ERROR, "Unable to set silence threshold: %s\n", snd_strerror(err)); } +#endif err = snd_pcm_sw_params(handle, swparams); if (err < 0) {