summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2020-08-09 14:46:41 -0400
committerSolomon Peachy <pizza@shaftnet.org>2020-08-09 19:53:13 +0000
commit92d66f761f030bd6ec022e2f969d044e3bfd8c00 (patch)
treee7798731f9750a493b5f1860bfe609e9b293cda1
parent0d4752e3f6b7558ce260fff04c70af643d222172 (diff)
downloadrockbox-92d66f761f030bd6ec022e2f969d044e3bfd8c00.tar.gz
rockbox-92d66f761f030bd6ec022e2f969d044e3bfd8c00.zip
Un-hardcode 44.1KHz settings from ALSA and iBasso PCM code
Change-Id: I69a69dabc799f360b73b1cf252645bd4cde13715
-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)
310 pcm_thread_run relies on this size match. See pcm_mixer.h. 310 pcm_thread_run relies on this size match. See pcm_mixer.h.
311 */ 311 */
312 _config.channels = 2; 312 _config.channels = 2;
313 _config.rate = 44100; 313 _config.rate = pcm_sampr;
314 _config.period_size = 256; 314 _config.period_size = 256;
315 _config.period_count = 4; 315 _config.period_count = 4;
316 _config.format = PCM_FORMAT_S16_LE; 316 _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 @@
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 *
77typedef short sample_t; 77typedef short sample_t;
78#endif 78#endif
79static const int channels = 2; /* count of channels */ 79static const int channels = 2; /* count of channels */
80static unsigned int rate = 44100; /* stream rate */ 80static snd_pcm_t *handle = NULL;
81
82static snd_pcm_t *handle;
83static snd_pcm_sframes_t buffer_size = MIX_FRAME_SAMPLES * 32; /* ~16k */ 81static snd_pcm_sframes_t buffer_size = MIX_FRAME_SAMPLES * 32; /* ~16k */
84static snd_pcm_sframes_t period_size = MIX_FRAME_SAMPLES * 4; /* ~4k */ 82static snd_pcm_sframes_t period_size = MIX_FRAME_SAMPLES * 4; /* ~4k */
85static sample_t *frames; 83static 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 }