summaryrefslogtreecommitdiff
path: root/apps/plugins/mpegplayer
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/plugins/mpegplayer
parent00faabef5e902008172e08d3bcd77683cbafef51 (diff)
downloadrockbox-d37bf24d9011addbfbd40942a4e9bbf26de7df00.tar.gz
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/plugins/mpegplayer')
-rw-r--r--apps/plugins/mpegplayer/audio_thread.c1
-rw-r--r--apps/plugins/mpegplayer/mpegplayer.h2
-rw-r--r--apps/plugins/mpegplayer/pcm_output.c6
3 files changed, 8 insertions, 1 deletions
diff --git a/apps/plugins/mpegplayer/audio_thread.c b/apps/plugins/mpegplayer/audio_thread.c
index 1c167ea2a2..764ad111f2 100644
--- a/apps/plugins/mpegplayer/audio_thread.c
+++ b/apps/plugins/mpegplayer/audio_thread.c
@@ -481,6 +481,7 @@ static void audio_thread(void)
481 init_mad(); 481 init_mad();
482 482
483 td.dsp = rb->dsp_get_config(CODEC_IDX_AUDIO); 483 td.dsp = rb->dsp_get_config(CODEC_IDX_AUDIO);
484 rb->dsp_configure(td.dsp, DSP_SET_OUT_FREQUENCY, CLOCK_RATE);
484#ifdef HAVE_PITCHCONTROL 485#ifdef HAVE_PITCHCONTROL
485 rb->sound_set_pitch(PITCH_SPEED_100); 486 rb->sound_set_pitch(PITCH_SPEED_100);
486 rb->dsp_set_timestretch(PITCH_SPEED_100); 487 rb->dsp_set_timestretch(PITCH_SPEED_100);
diff --git a/apps/plugins/mpegplayer/mpegplayer.h b/apps/plugins/mpegplayer/mpegplayer.h
index 32cc7b25be..4ddf0ca7b1 100644
--- a/apps/plugins/mpegplayer/mpegplayer.h
+++ b/apps/plugins/mpegplayer/mpegplayer.h
@@ -44,7 +44,7 @@
44#define AUDIOBUF_ALLOC_SIZE (AUDIOBUF_SIZE+AUDIOBUF_GUARD_SIZE) 44#define AUDIOBUF_ALLOC_SIZE (AUDIOBUF_SIZE+AUDIOBUF_GUARD_SIZE)
45 45
46/** PCM buffer **/ 46/** PCM buffer **/
47#define CLOCK_RATE NATIVE_FREQUENCY /* Our clock rate in ticks/second (samplerate) */ 47#define CLOCK_RATE 44100 /* Our clock rate in ticks/second (samplerate) */
48 48
49/* Define this as "1" to have a test tone instead of silence clip */ 49/* Define this as "1" to have a test tone instead of silence clip */
50#define SILENCE_TEST_TONE 0 50#define SILENCE_TEST_TONE 0
diff --git a/apps/plugins/mpegplayer/pcm_output.c b/apps/plugins/mpegplayer/pcm_output.c
index 3af8e91adc..82e3584277 100644
--- a/apps/plugins/mpegplayer/pcm_output.c
+++ b/apps/plugins/mpegplayer/pcm_output.c
@@ -51,6 +51,8 @@ static uint32_t volatile clock_time IBSS_ATTR; /* Timestamp adjusted */
51static int pcm_skipped = 0; 51static int pcm_skipped = 0;
52static int pcm_underruns = 0; 52static int pcm_underruns = 0;
53 53
54static unsigned int old_sampr = 0;
55
54/* Small silence clip. ~5.80ms @ 44.1kHz */ 56/* Small silence clip. ~5.80ms @ 44.1kHz */
55static int16_t silence[256*2] ALIGNED_ATTR(4) = { 0 }; 57static int16_t silence[256*2] ALIGNED_ATTR(4) = { 0 };
56 58
@@ -380,9 +382,13 @@ bool pcm_output_init(void)
380 } 382 }
381#endif 383#endif
382 384
385 old_sampr = rb->mixer_get_frequency();
386 rb->mixer_set_frequency(CLOCK_RATE);
383 return true; 387 return true;
384} 388}
385 389
386void pcm_output_exit(void) 390void pcm_output_exit(void)
387{ 391{
392 if (old_sampr != 0)
393 rb->mixer_set_frequency(old_sampr);
388} 394}