diff options
Diffstat (limited to 'apps/plugins')
| -rw-r--r-- | apps/plugins/SOURCES | 2 | ||||
| -rw-r--r-- | apps/plugins/mpegplayer/audio_thread.c | 1 | ||||
| -rw-r--r-- | apps/plugins/mpegplayer/mpegplayer.h | 2 | ||||
| -rw-r--r-- | apps/plugins/mpegplayer/pcm_output.c | 6 | ||||
| -rw-r--r-- | apps/plugins/oscilloscope.c | 19 | ||||
| -rw-r--r-- | apps/plugins/test_codec.c | 7 |
6 files changed, 29 insertions, 8 deletions
diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES index c512a9e..00bf960 100644 --- a/apps/plugins/SOURCES +++ b/apps/plugins/SOURCES @@ -37,6 +37,8 @@ resistor.c remote_control.c #endif +test_codec.c +test_sampr.c #ifdef HAVE_BACKLIGHT diff --git a/apps/plugins/mpegplayer/audio_thread.c b/apps/plugins/mpegplayer/audio_thread.c index 1c167ea..764ad11 100644 --- a/apps/plugins/mpegplayer/audio_thread.c +++ b/apps/plugins/mpegplayer/audio_thread.c @@ -481,6 +481,7 @@ static void audio_thread(void) init_mad(); td.dsp = rb->dsp_get_config(CODEC_IDX_AUDIO); + rb->dsp_configure(td.dsp, DSP_SET_OUT_FREQUENCY, CLOCK_RATE); #ifdef HAVE_PITCHCONTROL rb->sound_set_pitch(PITCH_SPEED_100); rb->dsp_set_timestretch(PITCH_SPEED_100); diff --git a/apps/plugins/mpegplayer/mpegplayer.h b/apps/plugins/mpegplayer/mpegplayer.h index 32cc7b2..4ddf0ca 100644 --- a/apps/plugins/mpegplayer/mpegplayer.h +++ b/apps/plugins/mpegplayer/mpegplayer.h @@ -44,7 +44,7 @@ #define AUDIOBUF_ALLOC_SIZE (AUDIOBUF_SIZE+AUDIOBUF_GUARD_SIZE) /** PCM buffer **/ -#define CLOCK_RATE NATIVE_FREQUENCY /* Our clock rate in ticks/second (samplerate) */ +#define CLOCK_RATE 44100 /* Our clock rate in ticks/second (samplerate) */ /* Define this as "1" to have a test tone instead of silence clip */ #define SILENCE_TEST_TONE 0 diff --git a/apps/plugins/mpegplayer/pcm_output.c b/apps/plugins/mpegplayer/pcm_output.c index 3af8e91..82e3584 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 */ static int pcm_skipped = 0; static int pcm_underruns = 0; +static unsigned int old_sampr = 0; + /* Small silence clip. ~5.80ms @ 44.1kHz */ static int16_t silence[256*2] ALIGNED_ATTR(4) = { 0 }; @@ -380,9 +382,13 @@ bool pcm_output_init(void) } #endif + old_sampr = rb->mixer_get_frequency(); + rb->mixer_set_frequency(CLOCK_RATE); return true; } void pcm_output_exit(void) { + if (old_sampr != 0) + rb->mixer_set_frequency(old_sampr); } diff --git a/apps/plugins/oscilloscope.c b/apps/plugins/oscilloscope.c index a4ec6a8..4d80749 100644 --- a/apps/plugins/oscilloscope.c +++ b/apps/plugins/oscilloscope.c @@ -1200,13 +1200,14 @@ static long anim_peaks_vertical(void) /** Waveform View **/ #ifdef OSCILLOSCOPE_GRAPHMODE -static int16_t waveform_buffer[2*ALIGN_UP(NATIVE_FREQUENCY, 2048)+2*2048] +static int16_t waveform_buffer[2*ALIGN_UP(PLAY_SAMPR_MAX, 2048)+2*2048] MEM_ALIGN_ATTR; static size_t waveform_buffer_threshold = 0; static size_t volatile waveform_buffer_have = 0; static size_t waveform_buffer_break = 0; +static unsigned long mixer_sampr = PLAY_SAMPR_DEFAULT; #define PCM_SAMPLESIZE (2*sizeof(int16_t)) -#define PCM_BYTERATE (NATIVE_FREQUENCY*PCM_SAMPLESIZE) +#define PCM_BYTERATE(sampr) ((sampr)*PCM_SAMPLESIZE) #define WAVEFORM_SCALE_PCM(full_scale, sample) \ ((((full_scale) * (sample)) + (1 << 14)) >> 15) @@ -1390,7 +1391,7 @@ static long anim_waveform_horizontal(void) return cur_tick + HZ/5; } - int count = (NATIVE_FREQUENCY*osc_delay + 100*HZ - 1) / (100*HZ); + int count = (mixer_sampr*osc_delay + 100*HZ - 1) / (100*HZ); waveform_buffer_set_threshold(count*PCM_SAMPLESIZE); @@ -1516,7 +1517,8 @@ static long anim_waveform_horizontal(void) osd_lcd_update(); long delay = get_next_delay(); - return cur_tick + delay - waveform_buffer_have * HZ / PCM_BYTERATE; + return cur_tick + delay - waveform_buffer_have * HZ / + PCM_BYTERATE(mixer_sampr); } static void anim_waveform_plot_filled_v(int y, int y_prev, @@ -1583,7 +1585,7 @@ static long anim_waveform_vertical(void) return cur_tick + HZ/5; } - int count = (NATIVE_FREQUENCY*osc_delay + 100*HZ - 1) / (100*HZ); + int count = (mixer_sampr*osc_delay + 100*HZ - 1) / (100*HZ); waveform_buffer_set_threshold(count*PCM_SAMPLESIZE); @@ -1709,7 +1711,8 @@ static long anim_waveform_vertical(void) osd_lcd_update(); long delay = get_next_delay(); - return cur_tick + delay - waveform_buffer_have * HZ / PCM_BYTERATE; + return cur_tick + delay - waveform_buffer_have * HZ + / PCM_BYTERATE(mixer_sampr); } static void anim_waveform_exit(void) @@ -1872,6 +1875,10 @@ static void osc_setup(void) osd_lcd_update(); #endif +#ifdef OSCILLOSCOPE_GRAPHMODE + mixer_sampr = rb->mixer_get_frequency(); +#endif + /* Turn off backlight timeout */ backlight_ignore_timeout(); graphmode_setup(); diff --git a/apps/plugins/test_codec.c b/apps/plugins/test_codec.c index 7523d9e..0b409f8 100644 --- a/apps/plugins/test_codec.c +++ b/apps/plugins/test_codec.c @@ -502,7 +502,12 @@ static void configure(int setting, intptr_t value) { case DSP_SET_FREQUENCY: DEBUGF("samplerate=%d\n",(int)value); - wavinfo.samplerate = use_dsp ? NATIVE_FREQUENCY : (int)value; + if (use_dsp) { + wavinfo.samplerate = rb->dsp_configure( + ci.dsp, DSP_GET_OUT_FREQUENCY, 0); + } else { + wavinfo.samplerate = (int)value; + } break; case DSP_SET_SAMPLE_DEPTH: |