diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2011-07-08 22:31:15 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2011-07-08 22:31:15 +0000 |
commit | 5663e1cd0afc62e212c43c8fb374c791d554fb1b (patch) | |
tree | 488e7cc83aaf2ee61184fad46a3b4891a95b0f13 /apps/plugins/mpegplayer/pcm_output.c | |
parent | f1a5a25dac4c61bf178ee5361998d205bb71b2d1 (diff) | |
download | rockbox-5663e1cd0afc62e212c43c8fb374c791d554fb1b.tar.gz rockbox-5663e1cd0afc62e212c43c8fb374c791d554fb1b.zip |
Have mpegplayer use the mixer (the playback channel, since it's mutually exclusive to audio playback) so the clicks and skip beep can be used according to user settings. Introduce some system sound functions to make easier playing event sounds from various places and convert files calling 'beep_play' to use 'system_sound_play' and 'keyclick_click'. Event sound could be become themeable.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30130 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/mpegplayer/pcm_output.c')
-rw-r--r-- | apps/plugins/mpegplayer/pcm_output.c | 65 |
1 files changed, 35 insertions, 30 deletions
diff --git a/apps/plugins/mpegplayer/pcm_output.c b/apps/plugins/mpegplayer/pcm_output.c index fb7ff434aa..8db9531049 100644 --- a/apps/plugins/mpegplayer/pcm_output.c +++ b/apps/plugins/mpegplayer/pcm_output.c | |||
@@ -23,6 +23,9 @@ | |||
23 | #include "plugin.h" | 23 | #include "plugin.h" |
24 | #include "mpegplayer.h" | 24 | #include "mpegplayer.h" |
25 | 25 | ||
26 | /* PCM channel we're using */ | ||
27 | #define MPEG_PCM_CHANNEL PCM_MIXER_CHAN_PLAYBACK | ||
28 | |||
26 | /* Pointers */ | 29 | /* Pointers */ |
27 | 30 | ||
28 | /* Start of buffer */ | 31 | /* Start of buffer */ |
@@ -217,24 +220,22 @@ bool pcm_output_empty(void) | |||
217 | /* Flushes the buffer - clock keeps counting */ | 220 | /* Flushes the buffer - clock keeps counting */ |
218 | void pcm_output_flush(void) | 221 | void pcm_output_flush(void) |
219 | { | 222 | { |
220 | bool playing, paused; | ||
221 | |||
222 | rb->pcm_play_lock(); | 223 | rb->pcm_play_lock(); |
223 | 224 | ||
224 | playing = rb->pcm_is_playing(); | 225 | enum channel_status status = rb->mixer_channel_status(MPEG_PCM_CHANNEL); |
225 | paused = rb->pcm_is_paused(); | ||
226 | 226 | ||
227 | /* Stop PCM to clear current buffer */ | 227 | /* Stop PCM to clear current buffer */ |
228 | if (playing) | 228 | if (status != CHANNEL_STOPPED) |
229 | rb->pcm_play_stop(); | 229 | rb->mixer_channel_stop(MPEG_PCM_CHANNEL); |
230 | |||
231 | rb->pcm_play_unlock(); | ||
230 | 232 | ||
231 | pcm_reset_buffer(); | 233 | pcm_reset_buffer(); |
232 | 234 | ||
233 | /* Restart if playing state was current */ | 235 | /* Restart if playing state was current */ |
234 | if (playing && !paused) | 236 | if (status == CHANNEL_PLAYING) |
235 | rb->pcm_play_data(get_more, NULL, 0); | 237 | rb->mixer_channel_play_data(MPEG_PCM_CHANNEL, |
236 | 238 | get_more, NULL, 0); | |
237 | rb->pcm_play_unlock(); | ||
238 | } | 239 | } |
239 | 240 | ||
240 | /* Seek the reference clock to the specified time - next audio data ready to | 241 | /* Seek the reference clock to the specified time - next audio data ready to |
@@ -264,10 +265,12 @@ uint32_t pcm_output_get_clock(void) | |||
264 | do | 265 | do |
265 | { | 266 | { |
266 | time = clock_time; | 267 | time = clock_time; |
267 | rem = rb->pcm_get_bytes_waiting() >> 2; | 268 | rem = rb->mixer_channel_get_bytes_waiting(MPEG_PCM_CHANNEL) >> 2; |
268 | } | 269 | } |
269 | while (UNLIKELY(time != clock_time || | 270 | while (UNLIKELY(time != clock_time || |
270 | (rem == 0 && rb->pcm_is_playing() && !rb->pcm_is_paused()))); | 271 | (rem == 0 && |
272 | rb->mixer_channel_status(MPEG_PCM_CHANNEL) == CHANNEL_PLAYING)) | ||
273 | ); | ||
271 | 274 | ||
272 | return time - rem; | 275 | return time - rem; |
273 | 276 | ||
@@ -283,10 +286,12 @@ uint32_t pcm_output_get_ticks(uint32_t *start) | |||
283 | do | 286 | do |
284 | { | 287 | { |
285 | tick = clock_tick; | 288 | tick = clock_tick; |
286 | rem = rb->pcm_get_bytes_waiting() >> 2; | 289 | rem = rb->mixer_channel_get_bytes_waiting(MPEG_PCM_CHANNEL) >> 2; |
287 | } | 290 | } |
288 | while (UNLIKELY(tick != clock_tick || | 291 | while (UNLIKELY(tick != clock_tick || |
289 | (rem == 0 && rb->pcm_is_playing() && !rb->pcm_is_paused()))); | 292 | (rem == 0 && |
293 | rb->mixer_channel_status(MPEG_PCM_CHANNEL) == CHANNEL_PLAYING)) | ||
294 | ); | ||
290 | 295 | ||
291 | if (start) | 296 | if (start) |
292 | *start = clock_start; | 297 | *start = clock_start; |
@@ -299,16 +304,22 @@ void pcm_output_play_pause(bool play) | |||
299 | { | 304 | { |
300 | rb->pcm_play_lock(); | 305 | rb->pcm_play_lock(); |
301 | 306 | ||
302 | if (rb->pcm_is_playing()) | 307 | if (rb->mixer_channel_status(MPEG_PCM_CHANNEL) != CHANNEL_STOPPED) |
303 | { | 308 | { |
304 | rb->pcm_play_pause(play); | 309 | rb->mixer_channel_play_pause(MPEG_PCM_CHANNEL, play); |
310 | rb->pcm_play_unlock(); | ||
305 | } | 311 | } |
306 | else if (play) | 312 | else |
307 | { | 313 | { |
308 | rb->pcm_play_data(get_more, NULL, 0); | 314 | rb->pcm_play_unlock(); |
309 | } | ||
310 | 315 | ||
311 | rb->pcm_play_unlock(); | 316 | if (play) |
317 | { | ||
318 | rb->mixer_channel_set_amplitude(MPEG_PCM_CHANNEL, MIX_AMP_UNITY); | ||
319 | rb->mixer_channel_play_data(MPEG_PCM_CHANNEL, | ||
320 | get_more, NULL, 0); | ||
321 | } | ||
322 | } | ||
312 | } | 323 | } |
313 | 324 | ||
314 | /* Stops all playback and resets the clock */ | 325 | /* Stops all playback and resets the clock */ |
@@ -316,13 +327,13 @@ void pcm_output_stop(void) | |||
316 | { | 327 | { |
317 | rb->pcm_play_lock(); | 328 | rb->pcm_play_lock(); |
318 | 329 | ||
319 | if (rb->pcm_is_playing()) | 330 | if (rb->mixer_channel_status(MPEG_PCM_CHANNEL) != CHANNEL_STOPPED) |
320 | rb->pcm_play_stop(); | 331 | rb->mixer_channel_stop(MPEG_PCM_CHANNEL); |
332 | |||
333 | rb->pcm_play_unlock(); | ||
321 | 334 | ||
322 | pcm_output_flush(); | 335 | pcm_output_flush(); |
323 | pcm_output_set_clock(0); | 336 | pcm_output_set_clock(0); |
324 | |||
325 | rb->pcm_play_unlock(); | ||
326 | } | 337 | } |
327 | 338 | ||
328 | /* Drains any data if the start threshold hasn't been reached */ | 339 | /* Drains any data if the start threshold hasn't been reached */ |
@@ -343,11 +354,6 @@ bool pcm_output_init(void) | |||
343 | 354 | ||
344 | pcm_reset_buffer(); | 355 | pcm_reset_buffer(); |
345 | 356 | ||
346 | /* Some targets could play at the movie frequency without resampling but | ||
347 | * as of now DSP assumes a certain frequency (always 44100Hz) so | ||
348 | * resampling will be needed for other movie audio rates. */ | ||
349 | rb->pcm_set_frequency(NATIVE_FREQUENCY); | ||
350 | |||
351 | #if INPUT_SRC_CAPS != 0 | 357 | #if INPUT_SRC_CAPS != 0 |
352 | /* Select playback */ | 358 | /* Select playback */ |
353 | rb->audio_set_input_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK); | 359 | rb->audio_set_input_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK); |
@@ -379,5 +385,4 @@ bool pcm_output_init(void) | |||
379 | 385 | ||
380 | void pcm_output_exit(void) | 386 | void pcm_output_exit(void) |
381 | { | 387 | { |
382 | rb->pcm_set_frequency(HW_SAMPR_DEFAULT); | ||
383 | } | 388 | } |