diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2020-08-09 14:46:41 -0400 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2020-08-09 19:53:13 +0000 |
commit | 92d66f761f030bd6ec022e2f969d044e3bfd8c00 (patch) | |
tree | e7798731f9750a493b5f1860bfe609e9b293cda1 /firmware/target/hosted/pcm-alsa.c | |
parent | 0d4752e3f6b7558ce260fff04c70af643d222172 (diff) | |
download | rockbox-92d66f761f030bd6ec022e2f969d044e3bfd8c00.tar.gz rockbox-92d66f761f030bd6ec022e2f969d044e3bfd8c00.zip |
Un-hardcode 44.1KHz settings from ALSA and iBasso PCM code
Change-Id: I69a69dabc799f360b73b1cf252645bd4cde13715
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 | } |