aboutsummaryrefslogtreecommitdiff
path: root/pd/src/s_audio_alsa.c
diff options
context:
space:
mode:
authorMiller Puckette <millerpuckette@users.sourceforge.net>2004-11-06 16:07:34 +0000
committerMiller Puckette <millerpuckette@users.sourceforge.net>2004-11-06 16:07:34 +0000
commit981f641ef44fe4d72dcb0e1248a2f96ba53cee69 (patch)
treed5871a901628db17e12e6204d13b4bdb4b8a07d9 /pd/src/s_audio_alsa.c
parent5b0640e17d6db9e119d657fcadcf52ff317e704d (diff)
0.38 test 9 (mostly bug fixes)
svn path=/trunk/; revision=2226
Diffstat (limited to 'pd/src/s_audio_alsa.c')
-rw-r--r--pd/src/s_audio_alsa.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/pd/src/s_audio_alsa.c b/pd/src/s_audio_alsa.c
index 10577ad5..27188a72 100644
--- a/pd/src/s_audio_alsa.c
+++ b/pd/src/s_audio_alsa.c
@@ -30,6 +30,11 @@
#define DEBUG(x) x
#define DEBUG2(x) {x;}
+/* needed for alsa 0.9 compatibility: */
+#if (SND_LIB_MAJOR < 1)
+#define ALSAAPI9
+#endif
+
static void alsa_checkiosync( void);
static void alsa_numbertoname(int iodev, char *devname, int nchar);
@@ -83,7 +88,7 @@ static int alsaio_setup(t_alsa_dev *dev, int out, int *channels, int *rate,
if (sys_verbose)
{
- if (out)
+ if (out)
post("configuring sound output...");
else post("configuring sound input...");
}
@@ -134,7 +139,8 @@ static int alsaio_setup(t_alsa_dev *dev, int out, int *channels, int *rate,
dev->a_channels = *channels;
/* set the sampling rate */
- err = snd_pcm_hw_params_set_rate_min(dev->a_handle, hw_params, rate, 0);
+ err = snd_pcm_hw_params_set_rate_min(dev->a_handle, hw_params,
+ (unsigned int *)rate, 0);
check_error(err, "snd_pcm_hw_params_set_rate_min (input)");
#if 0
err = snd_pcm_hw_params_get_rate(hw_params, &subunitdir);
@@ -144,21 +150,37 @@ static int alsaio_setup(t_alsa_dev *dev, int out, int *channels, int *rate,
/* set the period - ie frag size */
/* LATER try this to get a recommended period size...
right now, it trips an assertion failure in ALSA lib */
+
+#ifdef ALSAAPI9
+ err = snd_pcm_hw_params_set_period_size_near(dev->a_handle,
+ hw_params, (snd_pcm_uframes_t)frag_size, 0);
+#else
tmp_snd_pcm_uframes = frag_size;
err = snd_pcm_hw_params_set_period_size_near(dev->a_handle,
hw_params, &tmp_snd_pcm_uframes, 0);
+#endif
check_error(err, "snd_pcm_hw_params_set_period_size_near (input)");
/* set the number of periods - ie numfrags */
+#ifdef ALSAAPI9
+ err = snd_pcm_hw_params_set_periods_near(dev->a_handle,
+ hw_params, nfrags, 0);
+#else
tmp_uint = nfrags;
err = snd_pcm_hw_params_set_periods_near(dev->a_handle,
hw_params, &tmp_uint, 0);
+#endif
check_error(err, "snd_pcm_hw_params_set_periods_near (input)");
/* set the buffer size */
+#ifdef ALSAAPI9
+ err = snd_pcm_hw_params_set_buffer_size_near(dev->a_handle,
+ hw_params, nfrags * frag_size);
+#else
tmp_snd_pcm_uframes = nfrags * frag_size;
err = snd_pcm_hw_params_set_buffer_size_near(dev->a_handle,
hw_params, &tmp_snd_pcm_uframes);
+#endif
check_error(err, "snd_pcm_hw_params_set_buffer_size_near (input)");
err = snd_pcm_hw_params(dev->a_handle, hw_params);
@@ -348,8 +370,6 @@ void alsa_close_audio(void)
alsa_nindev = alsa_noutdev = 0;
}
-// #define DEBUG_ALSA_XFER
-
int alsa_send_dacs(void)
{
#ifdef DEBUG_ALSA_XFER