diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2012-12-02 01:09:44 -0500 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2012-12-05 02:03:58 +0100 |
commit | 0f8aedbe9492a5226fddd4ad27dae21b8a39e1b4 (patch) | |
tree | fa337438065d277926a254af74d3843b060b37eb /firmware | |
parent | e1ea08417bca57c607df6686472fa0a86f38b6d1 (diff) | |
download | rockbox-0f8aedbe9492a5226fddd4ad27dae21b8a39e1b4.tar.gz rockbox-0f8aedbe9492a5226fddd4ad27dae21b8a39e1b4.zip |
Add a true waveform display to the oscilloscope plugin.
* Adds some additional niftyness like a floating popup display that
is implemented in an OSD library for use by other plugins.
* Speed changes are now gradual for both views and follow a curve
derived from some fiddling around to get a nice feel.
* Refined a few behavioral things overall.
It needs a bit of help from a direct PCM channel callback so it may
capture PCM for waveform display. Also need a few other core routines
to help out for the OSD.
Messes with some keymaps. Some targets need keymaps to access the
different views. Some devices can't support the additional view
because it requires a large buffer ( > 1 s) for samples.
If the plugin buffer is small, they can still use the popup display
since the plugin is also much smaller in that case.
Slow speed waveform needs some refining so it draws gradually like
a real oscilloscope but I'll stick with what it is, for the moment.
Change-Id: Ieb5b7922a2238264e9b19a58cb437739194eb036
Reviewed-on: http://gerrit.rockbox.org/245
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested-by: Michael Sevakis <jethead71@rockbox.org>
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/export/pcm_mixer.h | 10 | ||||
-rw-r--r-- | firmware/pcm_mixer.c | 22 |
2 files changed, 31 insertions, 1 deletions
diff --git a/firmware/export/pcm_mixer.h b/firmware/export/pcm_mixer.h index 69d2b894df..d424083002 100644 --- a/firmware/export/pcm_mixer.h +++ b/firmware/export/pcm_mixer.h | |||
@@ -106,7 +106,8 @@ enum channel_status mixer_channel_status(enum pcm_mixer_channel channel); | |||
106 | size_t mixer_channel_get_bytes_waiting(enum pcm_mixer_channel channel); | 106 | size_t mixer_channel_get_bytes_waiting(enum pcm_mixer_channel channel); |
107 | 107 | ||
108 | /* Return pointer to channel's playing audio data and the size remaining */ | 108 | /* Return pointer to channel's playing audio data and the size remaining */ |
109 | const void * mixer_channel_get_buffer(enum pcm_mixer_channel channel, int *count); | 109 | const void * mixer_channel_get_buffer(enum pcm_mixer_channel channel, |
110 | int *count); | ||
110 | 111 | ||
111 | /* Calculate peak values for channel */ | 112 | /* Calculate peak values for channel */ |
112 | void mixer_channel_calculate_peaks(enum pcm_mixer_channel channel, | 113 | void mixer_channel_calculate_peaks(enum pcm_mixer_channel channel, |
@@ -116,6 +117,13 @@ void mixer_channel_calculate_peaks(enum pcm_mixer_channel channel, | |||
116 | void mixer_adjust_channel_address(enum pcm_mixer_channel channel, | 117 | void mixer_adjust_channel_address(enum pcm_mixer_channel channel, |
117 | off_t offset); | 118 | off_t offset); |
118 | 119 | ||
120 | /* Set a hook that is called upon getting a new source buffer for a channel | ||
121 | NOTE: Called for each buffer, not each mixer chunk */ | ||
122 | typedef void (*chan_buffer_hook_fn_type)(const void *start, size_t size); | ||
123 | |||
124 | void mixer_channel_set_buffer_hook(enum pcm_mixer_channel channel, | ||
125 | chan_buffer_hook_fn_type fn); | ||
126 | |||
119 | /* Stop ALL channels and PCM and reset state */ | 127 | /* Stop ALL channels and PCM and reset state */ |
120 | void mixer_reset(void); | 128 | void mixer_reset(void); |
121 | 129 | ||
diff --git a/firmware/pcm_mixer.c b/firmware/pcm_mixer.c index cddff431ec..34852e97e9 100644 --- a/firmware/pcm_mixer.c +++ b/firmware/pcm_mixer.c | |||
@@ -45,6 +45,7 @@ struct mixer_channel | |||
45 | pcm_play_callback_type get_more; /* Registered callback */ | 45 | pcm_play_callback_type get_more; /* Registered callback */ |
46 | enum channel_status status; /* Playback status */ | 46 | enum channel_status status; /* Playback status */ |
47 | uint32_t amplitude; /* Amp. factor: 0x0000 = mute, 0x10000 = unity */ | 47 | uint32_t amplitude; /* Amp. factor: 0x0000 = mute, 0x10000 = unity */ |
48 | chan_buffer_hook_fn_type buffer_hook; /* Callback for new buffer */ | ||
48 | }; | 49 | }; |
49 | 50 | ||
50 | /* Forget about boost here for the moment */ | 51 | /* Forget about boost here for the moment */ |
@@ -106,6 +107,12 @@ static void mixer_pcm_callback(const void **addr, size_t *size) | |||
106 | *size = next_size; | 107 | *size = next_size; |
107 | } | 108 | } |
108 | 109 | ||
110 | static inline void chan_call_buffer_hook(struct mixer_channel *chan) | ||
111 | { | ||
112 | if (UNLIKELY(chan->buffer_hook)) | ||
113 | chan->buffer_hook(chan->start, chan->size); | ||
114 | } | ||
115 | |||
109 | /* Buffering callback - calls sub-callbacks and mixes the data for next | 116 | /* Buffering callback - calls sub-callbacks and mixes the data for next |
110 | buffer to be sent from mixer_pcm_callback() */ | 117 | buffer to be sent from mixer_pcm_callback() */ |
111 | static enum pcm_dma_status MIXER_CALLBACK_ICODE | 118 | static enum pcm_dma_status MIXER_CALLBACK_ICODE |
@@ -149,6 +156,8 @@ fill_frame: | |||
149 | channel_stopped(chan); | 156 | channel_stopped(chan); |
150 | continue; | 157 | continue; |
151 | } | 158 | } |
159 | |||
160 | chan_call_buffer_hook(chan); | ||
152 | } | 161 | } |
153 | 162 | ||
154 | /* Channel will play for at least part of this frame */ | 163 | /* Channel will play for at least part of this frame */ |
@@ -298,6 +307,7 @@ void mixer_channel_play_data(enum pcm_mixer_channel channel, | |||
298 | chan->get_more = get_more; | 307 | chan->get_more = get_more; |
299 | 308 | ||
300 | mixer_activate_channel(chan); | 309 | mixer_activate_channel(chan); |
310 | chan_call_buffer_hook(chan); | ||
301 | mixer_start_pcm(); | 311 | mixer_start_pcm(); |
302 | } | 312 | } |
303 | else | 313 | else |
@@ -406,6 +416,18 @@ void mixer_adjust_channel_address(enum pcm_mixer_channel channel, | |||
406 | pcm_play_unlock(); | 416 | pcm_play_unlock(); |
407 | } | 417 | } |
408 | 418 | ||
419 | /* Set a hook that is called upon getting a new source buffer for a channel | ||
420 | NOTE: Called for each buffer, not each mixer chunk */ | ||
421 | void mixer_channel_set_buffer_hook(enum pcm_mixer_channel channel, | ||
422 | chan_buffer_hook_fn_type fn) | ||
423 | { | ||
424 | struct mixer_channel *chan = &channels[channel]; | ||
425 | |||
426 | pcm_play_lock(); | ||
427 | chan->buffer_hook = fn; | ||
428 | pcm_play_unlock(); | ||
429 | } | ||
430 | |||
409 | /* Stop ALL channels and PCM and reset state */ | 431 | /* Stop ALL channels and PCM and reset state */ |
410 | void mixer_reset(void) | 432 | void mixer_reset(void) |
411 | { | 433 | { |