summaryrefslogtreecommitdiffstats
path: root/apps/pcmbuf.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2013-05-23 13:58:51 -0400
committerMichael Sevakis <jethead71@rockbox.org>2013-07-06 04:22:04 +0200
commitd37bf24d9011addbfbd40942a4e9bbf26de7df00 (patch)
treedafb7eaeb494081668a4841d490fce2bfbb2438d /apps/pcmbuf.c
parent00faabef5e902008172e08d3bcd77683cbafef51 (diff)
downloadrockbox-d37bf24d9011addbfbd40942a4e9bbf26de7df00.tar.gz
rockbox-d37bf24d9011addbfbd40942a4e9bbf26de7df00.tar.bz2
rockbox-d37bf24d9011addbfbd40942a4e9bbf26de7df00.zip
Enable setting of global output samplerate on certain targets.
Replaces the NATIVE_FREQUENCY constant with a configurable frequency. The user may select 48000Hz if the hardware supports it. The default is still 44100Hz and the minimum is 44100Hz. The setting is located in the playback settings, under "Frequency". "Frequency" was duplicated in english.lang for now to avoid having to fix every .lang file for the moment and throwing everything out of sync because of the new play_frequency feature in features.txt. The next cleanup should combine it with the one included for recording and generalize the ID label. If the hardware doesn't support 48000Hz, no setting will be available. On particular hardware where very high rates are practical and desireable, the upper bound can be extended by patching. The PCM mixer can be configured to play at the full hardware frequency range. The DSP core can configure to the hardware minimum up to the maximum playback setting (some buffers must be reserved according to the maximum rate). If only 44100Hz is supported or possible on a given target for playback, using the DSP and mixer at other samperates is possible if the hardware offers them. Change-Id: I6023cf0c0baa8bc6292b6919b4dd3618a6a25622 Reviewed-on: http://gerrit.rockbox.org/479 Reviewed-by: Michael Sevakis <jethead71@rockbox.org> Tested-by: Michael Sevakis <jethead71@rockbox.org>
Diffstat (limited to 'apps/pcmbuf.c')
-rw-r--r--apps/pcmbuf.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/apps/pcmbuf.c b/apps/pcmbuf.c
index cc454a49ce..ff9b3e16a2 100644
--- a/apps/pcmbuf.c
+++ b/apps/pcmbuf.c
@@ -40,7 +40,6 @@
#include "settings.h"
#include "audio.h"
#include "voice_thread.h"
-#include "dsp_core.h"
/* This is the target fill size of chunks on the pcm buffer
Can be any number of samples but power of two sizes make for faster and
@@ -66,11 +65,11 @@
chunks */
/* Return data level in 1/4-second increments */
-#define DATA_LEVEL(quarter_secs) (NATIVE_FREQUENCY * (quarter_secs))
+#define DATA_LEVEL(quarter_secs) (pcmbuf_sampr * (quarter_secs))
/* Number of bytes played per second:
(sample rate * 2 channels * 2 bytes/sample) */
-#define BYTERATE (NATIVE_FREQUENCY * 4)
+#define BYTERATE (pcmbuf_sampr * 2 * 2)
#if MEMORYSIZE > 2
/* Keep watermark high for large memory target - at least (2s) */
@@ -104,6 +103,7 @@ static size_t pcmbuf_size;
static struct chunkdesc *pcmbuf_descriptors;
static unsigned int pcmbuf_desc_count;
static unsigned int position_key = 1;
+static unsigned int pcmbuf_sampr = 0;
static size_t chunk_ridx;
static size_t chunk_widx;
@@ -111,8 +111,7 @@ static size_t chunk_widx;
static size_t pcmbuf_bytes_waiting;
static struct chunkdesc *current_desc;
-/* Only written if HAVE_CROSSFADE */
-static size_t pcmbuf_watermark = PCMBUF_WATERMARK;
+static size_t pcmbuf_watermark = 0;
static bool low_latency_mode = false;
@@ -545,6 +544,8 @@ size_t pcmbuf_init(void *bufend)
}
pcmbuf_finish_crossfade_enable();
+#else
+ pcmbuf_watermark = PCMBUF_WATERMARK;
#endif /* HAVE_CROSSFADE */
init_buffer_state();
@@ -1331,3 +1332,13 @@ void pcmbuf_set_low_latency(bool state)
{
low_latency_mode = state;
}
+
+void pcmbuf_update_frequency(void)
+{
+ pcmbuf_sampr = mixer_get_frequency();
+}
+
+unsigned int pcmbuf_get_frequency(void)
+{
+ return pcmbuf_sampr;
+}