1
0
Fork 0
forked from len0rd/rockbox

Now that headphone plug pause/resume should be better behaved, support it in mpegplayer too.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16179 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Michael Sevakis 2008-01-27 21:45:15 +00:00
parent 0efdd7a5f7
commit 3f4fd4d6a0
3 changed files with 71 additions and 1 deletions

View file

@ -234,6 +234,7 @@ enum wvs_bits
WVS_REFRESH_RESUME = 0x0020, /* Resume playback upon timeout */ WVS_REFRESH_RESUME = 0x0020, /* Resume playback upon timeout */
WVS_NODRAW = 0x8000, /* OR bitflag - don't draw anything */ WVS_NODRAW = 0x8000, /* OR bitflag - don't draw anything */
WVS_SHOW = 0x4000, /* OR bitflag - show the WVS */ WVS_SHOW = 0x4000, /* OR bitflag - show the WVS */
WVS_HP_PAUSE = 0x2000,
WVS_HIDE = 0x0000, /* hide the WVS (aid readability) */ WVS_HIDE = 0x0000, /* hide the WVS (aid readability) */
WVS_REFRESH_ALL = 0x000f, /* Only immediate graphical elements */ WVS_REFRESH_ALL = 0x000f, /* Only immediate graphical elements */
}; };
@ -938,7 +939,12 @@ static void wvs_refresh(int hint)
static void wvs_show(unsigned show) static void wvs_show(unsigned show)
{ {
if (((show ^ wvs.flags) & WVS_SHOW) == 0) if (((show ^ wvs.flags) & WVS_SHOW) == 0)
{
if (show & WVS_SHOW) {
wvs.hide_tick = *rb->current_tick + wvs.show_for;
}
return; return;
}
if (show & WVS_SHOW) { if (show & WVS_SHOW) {
/* Clip away the part of video that is covered */ /* Clip away the part of video that is covered */
@ -985,6 +991,12 @@ static void wvs_set_status(int status)
} }
} }
/* Get the current status value */
static int wvs_get_status(void)
{
return wvs.status & WVS_STATUS_MASK;
}
/* Handle Fast-forward/Rewind keys using WPS settings (and some nicked code ;) */ /* Handle Fast-forward/Rewind keys using WPS settings (and some nicked code ;) */
static uint32_t wvs_ff_rw(int btn, unsigned refresh) static uint32_t wvs_ff_rw(int btn, unsigned refresh)
{ {
@ -1145,6 +1157,7 @@ static void wvs_set_volume(int delta)
wvs_refresh(WVS_REFRESH_VOLUME); wvs_refresh(WVS_REFRESH_VOLUME);
} }
/* Begin playback at the specified time */
static int wvs_play(uint32_t time) static int wvs_play(uint32_t time)
{ {
int retval; int retval;
@ -1171,7 +1184,7 @@ static int wvs_halt(void)
/* Coerce to STREAM_PLAYING if paused with a pending resume */ /* Coerce to STREAM_PLAYING if paused with a pending resume */
if (status == STREAM_PAUSED) { if (status == STREAM_PAUSED) {
if (wvs.auto_refresh & WVS_REFRESH_RESUME) if (wvs_get_status() == WVS_STATUS_PLAYING)
status = STREAM_PLAYING; status = STREAM_PLAYING;
} }
@ -1213,6 +1226,7 @@ static void wvs_stop(void)
uint32_t resume_time; uint32_t resume_time;
wvs_cancel_refresh(WVS_REFRESH_VIDEO | WVS_REFRESH_RESUME); wvs_cancel_refresh(WVS_REFRESH_VIDEO | WVS_REFRESH_RESUME);
wvs_set_status(WVS_STATUS_STOPPED | WVS_NODRAW);
wvs_show(WVS_HIDE | WVS_NODRAW); wvs_show(WVS_HIDE | WVS_NODRAW);
stream_stop(); stream_stop();
@ -1254,6 +1268,43 @@ static void wvs_seek(int btn)
stream_seek(time, SEEK_SET); stream_seek(time, SEEK_SET);
} }
#ifdef HAVE_HEADPHONE_DETECTION
/* Handle SYS_PHONE_PLUGGED/UNPLUGGED */
static void wvs_handle_phone_plug(bool inserted)
{
if (rb->global_settings->unplug_mode == 0)
return;
/* Wait for any incomplete state transition to complete first */
stream_wait_status();
int status = wvs_status();
if (inserted) {
if (rb->global_settings->unplug_mode > 1) {
if (status == STREAM_PAUSED) {
backlight_force_on(rb);
wvs_resume();
}
}
} else {
if (status == STREAM_PLAYING) {
wvs_pause();
backlight_use_settings(rb);
if (stream_can_seek() && rb->global_settings->unplug_rw) {
stream_seek(-rb->global_settings->unplug_rw*TS_SECOND,
SEEK_CUR);
wvs_schedule_refresh(WVS_REFRESH_VIDEO);
/* Update time display now */
wvs_update_time();
wvs_refresh(WVS_REFRESH_TIME);
}
}
}
}
#endif
static void button_loop(void) static void button_loop(void)
{ {
rb->lcd_setfont(FONT_SYSFIXED); rb->lcd_setfont(FONT_SYSFIXED);
@ -1406,6 +1457,15 @@ static void button_loop(void)
break; break;
} /* MPEG_RW: MPEG_FF: */ } /* MPEG_RW: MPEG_FF: */
#ifdef HAVE_HEADPHONE_DETECTION
case SYS_PHONE_PLUGGED:
case SYS_PHONE_UNPLUGGED:
{
wvs_handle_phone_plug(button == SYS_PHONE_PLUGGED);
break;
} /* SYS_PHONE_*: */
#endif
default: default:
{ {
rb->default_event_handler(button); rb->default_event_handler(button);

View file

@ -809,6 +809,13 @@ uint32_t stream_get_seek_time(uint32_t *start)
return time; return time;
} }
/* Wait for a state transistion to complete */
void stream_wait_status(void)
{
stream_mgr_lock();
stream_mgr_unlock();
}
/* Returns the smallest file window that includes all active streams' /* Returns the smallest file window that includes all active streams'
* windows */ * windows */
static bool stream_get_window_callback(struct list_item *item, static bool stream_get_window_callback(struct list_item *item,

View file

@ -137,6 +137,9 @@ static inline uint32_t stream_get_ticks(uint32_t *start)
static inline int stream_status(void) static inline int stream_status(void)
{ return stream_mgr.status; } { return stream_mgr.status; }
/* Wait for a state transistion to complete */
void stream_wait_status(void);
/* Returns the playback length of the stream */ /* Returns the playback length of the stream */
static inline uint32_t stream_get_duration(void) static inline uint32_t stream_get_duration(void)
{ return str_parser.duration; } { return str_parser.duration; }