summaryrefslogtreecommitdiffstats
path: root/apps/plugins
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2011-07-08 22:31:15 +0000
committerMichael Sevakis <jethead71@rockbox.org>2011-07-08 22:31:15 +0000
commit5663e1cd0afc62e212c43c8fb374c791d554fb1b (patch)
tree488e7cc83aaf2ee61184fad46a3b4891a95b0f13 /apps/plugins
parentf1a5a25dac4c61bf178ee5361998d205bb71b2d1 (diff)
downloadrockbox-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')
-rw-r--r--apps/plugins/mpegplayer/mpeg_misc.c4
-rw-r--r--apps/plugins/mpegplayer/mpegplayer.c26
-rw-r--r--apps/plugins/mpegplayer/pcm_output.c65
3 files changed, 60 insertions, 35 deletions
diff --git a/apps/plugins/mpegplayer/mpeg_misc.c b/apps/plugins/mpegplayer/mpeg_misc.c
index d9e033322e..895fbe04a9 100644
--- a/apps/plugins/mpegplayer/mpeg_misc.c
+++ b/apps/plugins/mpegplayer/mpeg_misc.c
@@ -214,6 +214,10 @@ int mpeg_button_get(int timeout)
mpeg_sysevent_clear();
button = timeout == TIMEOUT_BLOCK ? rb->button_get(true) :
rb->button_get_w_tmo(timeout);
+
+ /* Produce keyclick */
+ rb->keyclick_click(button);
+
return mpeg_sysevent_callback(button, NULL);
}
diff --git a/apps/plugins/mpegplayer/mpegplayer.c b/apps/plugins/mpegplayer/mpegplayer.c
index 41f6b2e868..c6e1f4dded 100644
--- a/apps/plugins/mpegplayer/mpegplayer.c
+++ b/apps/plugins/mpegplayer/mpegplayer.c
@@ -386,6 +386,7 @@ enum video_action
VIDEO_STOP = 0,
VIDEO_PREV,
VIDEO_NEXT,
+ VIDEO_ACTION_MANUAL = 0x8000, /* Flag that says user did it */
};
/* OSD status - same order as icon array */
@@ -2139,7 +2140,7 @@ static int button_loop(void)
/* Release within 3 seconds of start: skip to previous
* file */
osd_stop();
- next_action = VIDEO_PREV;
+ next_action = VIDEO_PREV | VIDEO_ACTION_MANUAL;
}
}
else if ((button & ~BUTTON_REPEAT) == old_button) {
@@ -2169,7 +2170,7 @@ static int button_loop(void)
if ((old_button | BUTTON_REL) == button) {
/* If button has been released: skip to next file */
osd_stop();
- next_action = VIDEO_NEXT;
+ next_action = VIDEO_NEXT | VIDEO_ACTION_MANUAL;
}
else if ((button & ~BUTTON_REPEAT) == old_button) {
button = osd_seek_btn(old_button);
@@ -2251,11 +2252,10 @@ enum plugin_status plugin_start(const void* parameter)
while (!quit)
{
- int result;
-
init_settings(videofile);
- result = stream_open(videofile);
+ int result = stream_open(videofile);
+ bool manual_skip = false;
if (result >= STREAM_OK) {
/* start menu */
@@ -2267,6 +2267,8 @@ enum plugin_status plugin_start(const void* parameter)
if (result != MPEG_START_QUIT) {
/* Enter button loop and process UI */
next_action = button_loop();
+ manual_skip = next_action & VIDEO_ACTION_MANUAL;
+ next_action &= ~VIDEO_ACTION_MANUAL;
}
stream_close();
@@ -2341,6 +2343,13 @@ enum plugin_status plugin_start(const void* parameter)
sizeof(videofile));
/* quit after finished the last videofile */
quit = !get_videofile_says;
+
+ if (manual_skip)
+ {
+ rb->system_sound_play(get_videofile_says ?
+ SOUND_TRACK_SKIP : SOUND_TRACK_NO_MORE);
+ }
+
break;
}
case VIDEO_PREV:
@@ -2348,6 +2357,13 @@ enum plugin_status plugin_start(const void* parameter)
get_videofile_says = get_videofile(VIDEO_PREV, videofile,
sizeof(videofile));
/* if there is no previous file, play the same videofile */
+
+ if (manual_skip)
+ {
+ rb->system_sound_play(get_videofile_says ?
+ SOUND_TRACK_SKIP : SOUND_TRACK_NO_MORE);
+ }
+
break;
}
case VIDEO_STOP:
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 @@
#include "plugin.h"
#include "mpegplayer.h"
+/* PCM channel we're using */
+#define MPEG_PCM_CHANNEL PCM_MIXER_CHAN_PLAYBACK
+
/* Pointers */
/* Start of buffer */
@@ -217,24 +220,22 @@ bool pcm_output_empty(void)
/* Flushes the buffer - clock keeps counting */
void pcm_output_flush(void)
{
- bool playing, paused;
-
rb->pcm_play_lock();
- playing = rb->pcm_is_playing();
- paused = rb->pcm_is_paused();
+ enum channel_status status = rb->mixer_channel_status(MPEG_PCM_CHANNEL);
/* Stop PCM to clear current buffer */
- if (playing)
- rb->pcm_play_stop();
+ if (status != CHANNEL_STOPPED)
+ rb->mixer_channel_stop(MPEG_PCM_CHANNEL);
+
+ rb->pcm_play_unlock();
pcm_reset_buffer();
/* Restart if playing state was current */
- if (playing && !paused)
- rb->pcm_play_data(get_more, NULL, 0);
-
- rb->pcm_play_unlock();
+ if (status == CHANNEL_PLAYING)
+ rb->mixer_channel_play_data(MPEG_PCM_CHANNEL,
+ get_more, NULL, 0);
}
/* Seek the reference clock to the specified time - next audio data ready to
@@ -264,10 +265,12 @@ uint32_t pcm_output_get_clock(void)
do
{
time = clock_time;
- rem = rb->pcm_get_bytes_waiting() >> 2;
+ rem = rb->mixer_channel_get_bytes_waiting(MPEG_PCM_CHANNEL) >> 2;
}
while (UNLIKELY(time != clock_time ||
- (rem == 0 && rb->pcm_is_playing() && !rb->pcm_is_paused())));
+ (rem == 0 &&
+ rb->mixer_channel_status(MPEG_PCM_CHANNEL) == CHANNEL_PLAYING))
+ );
return time - rem;
@@ -283,10 +286,12 @@ uint32_t pcm_output_get_ticks(uint32_t *start)
do
{
tick = clock_tick;
- rem = rb->pcm_get_bytes_waiting() >> 2;
+ rem = rb->mixer_channel_get_bytes_waiting(MPEG_PCM_CHANNEL) >> 2;
}
while (UNLIKELY(tick != clock_tick ||
- (rem == 0 && rb->pcm_is_playing() && !rb->pcm_is_paused())));
+ (rem == 0 &&
+ rb->mixer_channel_status(MPEG_PCM_CHANNEL) == CHANNEL_PLAYING))
+ );
if (start)
*start = clock_start;
@@ -299,16 +304,22 @@ void pcm_output_play_pause(bool play)
{
rb->pcm_play_lock();
- if (rb->pcm_is_playing())
+ if (rb->mixer_channel_status(MPEG_PCM_CHANNEL) != CHANNEL_STOPPED)
{
- rb->pcm_play_pause(play);
+ rb->mixer_channel_play_pause(MPEG_PCM_CHANNEL, play);
+ rb->pcm_play_unlock();
}
- else if (play)
+ else
{
- rb->pcm_play_data(get_more, NULL, 0);
- }
+ rb->pcm_play_unlock();
- rb->pcm_play_unlock();
+ if (play)
+ {
+ rb->mixer_channel_set_amplitude(MPEG_PCM_CHANNEL, MIX_AMP_UNITY);
+ rb->mixer_channel_play_data(MPEG_PCM_CHANNEL,
+ get_more, NULL, 0);
+ }
+ }
}
/* Stops all playback and resets the clock */
@@ -316,13 +327,13 @@ void pcm_output_stop(void)
{
rb->pcm_play_lock();
- if (rb->pcm_is_playing())
- rb->pcm_play_stop();
+ if (rb->mixer_channel_status(MPEG_PCM_CHANNEL) != CHANNEL_STOPPED)
+ rb->mixer_channel_stop(MPEG_PCM_CHANNEL);
+
+ rb->pcm_play_unlock();
pcm_output_flush();
pcm_output_set_clock(0);
-
- rb->pcm_play_unlock();
}
/* Drains any data if the start threshold hasn't been reached */
@@ -343,11 +354,6 @@ bool pcm_output_init(void)
pcm_reset_buffer();
- /* Some targets could play at the movie frequency without resampling but
- * as of now DSP assumes a certain frequency (always 44100Hz) so
- * resampling will be needed for other movie audio rates. */
- rb->pcm_set_frequency(NATIVE_FREQUENCY);
-
#if INPUT_SRC_CAPS != 0
/* Select playback */
rb->audio_set_input_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK);
@@ -379,5 +385,4 @@ bool pcm_output_init(void)
void pcm_output_exit(void)
{
- rb->pcm_set_frequency(HW_SAMPR_DEFAULT);
}