diff options
Diffstat (limited to 'firmware/target/hosted/pcm-alsa.c')
-rw-r--r-- | firmware/target/hosted/pcm-alsa.c | 24 |
1 files changed, 11 insertions, 13 deletions
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 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * __________ __ ___. | 2 | * __________ __ ___. |
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
7 | * \/ \/ \/ \/ \/ | 7 | * \/ \/ \/ \/ \/ |
8 | * $Id$ | 8 | * $Id$ |
9 | * | 9 | * |
10 | * Copyright (C) 2010 Thomas Martitz | 10 | * Copyright (C) 2010 Thomas Martitz |
@@ -77,9 +77,7 @@ static const snd_pcm_format_t format = SND_PCM_FORMAT_S16; /* sample format * | |||
77 | typedef short sample_t; | 77 | typedef short sample_t; |
78 | #endif | 78 | #endif |
79 | static const int channels = 2; /* count of channels */ | 79 | static const int channels = 2; /* count of channels */ |
80 | static unsigned int rate = 44100; /* stream rate */ | 80 | static snd_pcm_t *handle = NULL; |
81 | |||
82 | static snd_pcm_t *handle; | ||
83 | static snd_pcm_sframes_t buffer_size = MIX_FRAME_SAMPLES * 32; /* ~16k */ | 81 | static snd_pcm_sframes_t buffer_size = MIX_FRAME_SAMPLES * 32; /* ~16k */ |
84 | static snd_pcm_sframes_t period_size = MIX_FRAME_SAMPLES * 4; /* ~4k */ | 82 | static snd_pcm_sframes_t period_size = MIX_FRAME_SAMPLES * 4; /* ~4k */ |
85 | static sample_t *frames; | 83 | static sample_t *frames; |
@@ -136,12 +134,12 @@ static int set_hwparams(snd_pcm_t *handle, unsigned sample_rate) | |||
136 | err = snd_pcm_hw_params_set_rate_near(handle, params, &rrate, 0); | 134 | err = snd_pcm_hw_params_set_rate_near(handle, params, &rrate, 0); |
137 | if (err < 0) | 135 | if (err < 0) |
138 | { | 136 | { |
139 | printf("Rate %iHz not available for playback: %s\n", rate, snd_strerror(err)); | 137 | printf("Rate %iHz not available for playback: %s\n", sample_rate, snd_strerror(err)); |
140 | goto error; | 138 | goto error; |
141 | } | 139 | } |
142 | if (rrate != sample_rate) | 140 | if (rrate != sample_rate) |
143 | { | 141 | { |
144 | printf("Rate doesn't match (requested %iHz, get %iHz)\n", sample_rate, err); | 142 | printf("Rate doesn't match (requested %iHz, get %iHz)\n", sample_rate, rrate); |
145 | err = -EINVAL; | 143 | err = -EINVAL; |
146 | goto error; | 144 | goto error; |
147 | } | 145 | } |
@@ -359,7 +357,7 @@ static int async_rw(snd_pcm_t *handle) | |||
359 | DEBUGF("Unable to install alternative signal stack: %s", strerror(err)); | 357 | DEBUGF("Unable to install alternative signal stack: %s", strerror(err)); |
360 | return err; | 358 | return err; |
361 | } | 359 | } |
362 | 360 | ||
363 | err = snd_async_add_pcm_handler(&ahandler, handle, async_callback, NULL); | 361 | err = snd_async_add_pcm_handler(&ahandler, handle, async_callback, NULL); |
364 | if (err < 0) | 362 | if (err < 0) |
365 | { | 363 | { |
@@ -430,7 +428,7 @@ void pcm_play_dma_init(void) | |||
430 | if ((err = snd_pcm_nonblock(handle, 1))) | 428 | if ((err = snd_pcm_nonblock(handle, 1))) |
431 | panicf("Could not set non-block mode: %s\n", snd_strerror(err)); | 429 | panicf("Could not set non-block mode: %s\n", snd_strerror(err)); |
432 | 430 | ||
433 | if ((err = set_hwparams(handle, rate)) < 0) | 431 | if ((err = set_hwparams(handle, pcm_sampr)) < 0) |
434 | { | 432 | { |
435 | panicf("Setting of hwparams failed: %s\n", snd_strerror(err)); | 433 | panicf("Setting of hwparams failed: %s\n", snd_strerror(err)); |
436 | } | 434 | } |