summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--firmware/target/hosted/ibasso/pcm-ibasso.c2
-rw-r--r--firmware/target/hosted/pcm-alsa.c24
2 files changed, 12 insertions, 14 deletions
diff --git a/firmware/target/hosted/ibasso/pcm-ibasso.c b/firmware/target/hosted/ibasso/pcm-ibasso.c
index 14ef298af0..4721501d25 100644
--- a/firmware/target/hosted/ibasso/pcm-ibasso.c
+++ b/firmware/target/hosted/ibasso/pcm-ibasso.c
@@ -310,7 +310,7 @@ void pcm_play_dma_init(void)
pcm_thread_run relies on this size match. See pcm_mixer.h.
*/
_config.channels = 2;
- _config.rate = 44100;
+ _config.rate = pcm_sampr;
_config.period_size = 256;
_config.period_count = 4;
_config.format = PCM_FORMAT_S16_LE;
diff --git a/firmware/target/hosted/pcm-alsa.c b/firmware/target/hosted/pcm-alsa.c
index f6a3ffce71..1b8e3c4477 100644
--- a/firmware/target/hosted/pcm-alsa.c
+++ b/firmware/target/hosted/pcm-alsa.c
@@ -1,10 +1,10 @@
/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2010 Thomas Martitz
@@ -77,9 +77,7 @@ static const snd_pcm_format_t format = SND_PCM_FORMAT_S16; /* sample format *
typedef short sample_t;
#endif
static const int channels = 2; /* count of channels */
-static unsigned int rate = 44100; /* stream rate */
-
-static snd_pcm_t *handle;
+static snd_pcm_t *handle = NULL;
static snd_pcm_sframes_t buffer_size = MIX_FRAME_SAMPLES * 32; /* ~16k */
static snd_pcm_sframes_t period_size = MIX_FRAME_SAMPLES * 4; /* ~4k */
static sample_t *frames;
@@ -136,12 +134,12 @@ static int set_hwparams(snd_pcm_t *handle, unsigned sample_rate)
err = snd_pcm_hw_params_set_rate_near(handle, params, &rrate, 0);
if (err < 0)
{
- printf("Rate %iHz not available for playback: %s\n", rate, snd_strerror(err));
+ printf("Rate %iHz not available for playback: %s\n", sample_rate, snd_strerror(err));
goto error;
}
if (rrate != sample_rate)
{
- printf("Rate doesn't match (requested %iHz, get %iHz)\n", sample_rate, err);
+ printf("Rate doesn't match (requested %iHz, get %iHz)\n", sample_rate, rrate);
err = -EINVAL;
goto error;
}
@@ -359,7 +357,7 @@ static int async_rw(snd_pcm_t *handle)
DEBUGF("Unable to install alternative signal stack: %s", strerror(err));
return err;
}
-
+
err = snd_async_add_pcm_handler(&ahandler, handle, async_callback, NULL);
if (err < 0)
{
@@ -430,7 +428,7 @@ void pcm_play_dma_init(void)
if ((err = snd_pcm_nonblock(handle, 1)))
panicf("Could not set non-block mode: %s\n", snd_strerror(err));
- if ((err = set_hwparams(handle, rate)) < 0)
+ if ((err = set_hwparams(handle, pcm_sampr)) < 0)
{
panicf("Setting of hwparams failed: %s\n", snd_strerror(err));
}