Switch madplay to the new API. This is done thanks to a patch written
by Micha Nelissen <micha@neli.hopto.org> and available at
http://article.gmane.org/gmane.comp.audio.mad.devel/729.
--- madplay-0.15.2b/audio_alsa.c 2008-10-18 15:10:16.000000000 +0200
+++ madplay-0.15.2b/audio_alsa.c.new 2008-10-18 15:03:27.000000000 +0200
-#define ALSA_PCM_OLD_HW_PARAMS_API
-#define ALSA_PCM_OLD_SW_PARAMS_API
#include <alsa/asoundlib.h>
+#define BUFFER_TIME_MAX 500000
-int buffer_time = 500000;
-int period_time = 100000;
-char *defaultdev = "plughw:0,0";
+unsigned char *buf = NULL;
+unsigned int channels = -1;
+unsigned int bitdepth = -1;
+unsigned int sample_size = -1;
+unsigned int buffer_time;
+unsigned int period_time;
+char *defaultdev = "plughw:0,0";
snd_pcm_hw_params_t *alsa_hwparams;
snd_pcm_sw_params_t *alsa_swparams;
-snd_pcm_sframes_t buffer_size;
-snd_pcm_sframes_t period_size;
+snd_pcm_uframes_t buffer_size;
snd_pcm_format_t alsa_format = -1;
snd_pcm_access_t alsa_access = SND_PCM_ACCESS_MMAP_INTERLEAVED;
snd_pcm_hw_params_t *params,
/* choose all parameters */
err = snd_pcm_hw_params_any(handle,params);
printf("Access type not available for playback: %s\n", snd_strerror(err));
+ /* set the access type */
+ err = snd_pcm_hw_params_set_access(handle, params, alsa_access);
+ printf("Sample format not available for playback: %s\n", snd_strerror(err));
/* set the sample format */
err = snd_pcm_hw_params_set_format(handle, params, alsa_format);
/* set the stream rate */
- err = snd_pcm_hw_params_set_rate_near(handle, params, rate, 0);
+ err = snd_pcm_hw_params_set_rate(handle, params, rate, 0);
printf("Rate %iHz not available for playback: %s\n", rate, snd_strerror(err));
- printf("Rate doesn't match (requested %iHz, get %iHz)\n", rate, err);
+ err = snd_pcm_hw_params_get_buffer_time_max(params, &buffer_time, NULL);
+ printf("Unable to retrieve buffer time: %s\n", snd_strerror(err));