1
0
Fork 0
forked from len0rd/rockbox

Un-hardcode 44.1KHz settings from ALSA and iBasso PCM code

Change-Id: I69a69dabc799f360b73b1cf252645bd4cde13715
This commit is contained in:
Solomon Peachy 2020-08-09 14:46:41 -04:00
parent 0d4752e3f6
commit 92d66f761f
2 changed files with 12 additions and 14 deletions

View file

@ -310,7 +310,7 @@ void pcm_play_dma_init(void)
pcm_thread_run relies on this size match. See pcm_mixer.h. pcm_thread_run relies on this size match. See pcm_mixer.h.
*/ */
_config.channels = 2; _config.channels = 2;
_config.rate = 44100; _config.rate = pcm_sampr;
_config.period_size = 256; _config.period_size = 256;
_config.period_count = 4; _config.period_count = 4;
_config.format = PCM_FORMAT_S16_LE; _config.format = PCM_FORMAT_S16_LE;

View file

@ -1,10 +1,10 @@
/*************************************************************************** /***************************************************************************
* __________ __ ___. * __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/ * \/ \/ \/ \/ \/
* $Id$ * $Id$
* *
* Copyright (C) 2010 Thomas Martitz * 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; typedef short sample_t;
#endif #endif
static const int channels = 2; /* count of channels */ static const int channels = 2; /* count of channels */
static unsigned int rate = 44100; /* stream rate */ static snd_pcm_t *handle = NULL;
static snd_pcm_t *handle;
static snd_pcm_sframes_t buffer_size = MIX_FRAME_SAMPLES * 32; /* ~16k */ 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 snd_pcm_sframes_t period_size = MIX_FRAME_SAMPLES * 4; /* ~4k */
static sample_t *frames; 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); err = snd_pcm_hw_params_set_rate_near(handle, params, &rrate, 0);
if (err < 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; goto error;
} }
if (rrate != sample_rate) 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; err = -EINVAL;
goto error; goto error;
} }
@ -359,7 +357,7 @@ static int async_rw(snd_pcm_t *handle)
DEBUGF("Unable to install alternative signal stack: %s", strerror(err)); DEBUGF("Unable to install alternative signal stack: %s", strerror(err));
return err; return err;
} }
err = snd_async_add_pcm_handler(&ahandler, handle, async_callback, NULL); err = snd_async_add_pcm_handler(&ahandler, handle, async_callback, NULL);
if (err < 0) if (err < 0)
{ {
@ -430,7 +428,7 @@ void pcm_play_dma_init(void)
if ((err = snd_pcm_nonblock(handle, 1))) if ((err = snd_pcm_nonblock(handle, 1)))
panicf("Could not set non-block mode: %s\n", snd_strerror(err)); 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)); panicf("Setting of hwparams failed: %s\n", snd_strerror(err));
} }