summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/plugins/mpegplayer/mpegplayer.c62
-rw-r--r--apps/plugins/mpegplayer/stream_mgr.c7
-rw-r--r--apps/plugins/mpegplayer/stream_mgr.h3
3 files changed, 71 insertions, 1 deletions
diff --git a/apps/plugins/mpegplayer/mpegplayer.c b/apps/plugins/mpegplayer/mpegplayer.c
index ba5fd26742..80b43660a5 100644
--- a/apps/plugins/mpegplayer/mpegplayer.c
+++ b/apps/plugins/mpegplayer/mpegplayer.c
@@ -234,6 +234,7 @@ enum wvs_bits
234 WVS_REFRESH_RESUME = 0x0020, /* Resume playback upon timeout */ 234 WVS_REFRESH_RESUME = 0x0020, /* Resume playback upon timeout */
235 WVS_NODRAW = 0x8000, /* OR bitflag - don't draw anything */ 235 WVS_NODRAW = 0x8000, /* OR bitflag - don't draw anything */
236 WVS_SHOW = 0x4000, /* OR bitflag - show the WVS */ 236 WVS_SHOW = 0x4000, /* OR bitflag - show the WVS */
237 WVS_HP_PAUSE = 0x2000,
237 WVS_HIDE = 0x0000, /* hide the WVS (aid readability) */ 238 WVS_HIDE = 0x0000, /* hide the WVS (aid readability) */
238 WVS_REFRESH_ALL = 0x000f, /* Only immediate graphical elements */ 239 WVS_REFRESH_ALL = 0x000f, /* Only immediate graphical elements */
239}; 240};
@@ -938,7 +939,12 @@ static void wvs_refresh(int hint)
938static void wvs_show(unsigned show) 939static void wvs_show(unsigned show)
939{ 940{
940 if (((show ^ wvs.flags) & WVS_SHOW) == 0) 941 if (((show ^ wvs.flags) & WVS_SHOW) == 0)
942 {
943 if (show & WVS_SHOW) {
944 wvs.hide_tick = *rb->current_tick + wvs.show_for;
945 }
941 return; 946 return;
947 }
942 948
943 if (show & WVS_SHOW) { 949 if (show & WVS_SHOW) {
944 /* Clip away the part of video that is covered */ 950 /* Clip away the part of video that is covered */
@@ -985,6 +991,12 @@ static void wvs_set_status(int status)
985 } 991 }
986} 992}
987 993
994/* Get the current status value */
995static int wvs_get_status(void)
996{
997 return wvs.status & WVS_STATUS_MASK;
998}
999
988/* Handle Fast-forward/Rewind keys using WPS settings (and some nicked code ;) */ 1000/* Handle Fast-forward/Rewind keys using WPS settings (and some nicked code ;) */
989static uint32_t wvs_ff_rw(int btn, unsigned refresh) 1001static uint32_t wvs_ff_rw(int btn, unsigned refresh)
990{ 1002{
@@ -1145,6 +1157,7 @@ static void wvs_set_volume(int delta)
1145 wvs_refresh(WVS_REFRESH_VOLUME); 1157 wvs_refresh(WVS_REFRESH_VOLUME);
1146} 1158}
1147 1159
1160/* Begin playback at the specified time */
1148static int wvs_play(uint32_t time) 1161static int wvs_play(uint32_t time)
1149{ 1162{
1150 int retval; 1163 int retval;
@@ -1171,7 +1184,7 @@ static int wvs_halt(void)
1171 1184
1172 /* Coerce to STREAM_PLAYING if paused with a pending resume */ 1185 /* Coerce to STREAM_PLAYING if paused with a pending resume */
1173 if (status == STREAM_PAUSED) { 1186 if (status == STREAM_PAUSED) {
1174 if (wvs.auto_refresh & WVS_REFRESH_RESUME) 1187 if (wvs_get_status() == WVS_STATUS_PLAYING)
1175 status = STREAM_PLAYING; 1188 status = STREAM_PLAYING;
1176 } 1189 }
1177 1190
@@ -1213,6 +1226,7 @@ static void wvs_stop(void)
1213 uint32_t resume_time; 1226 uint32_t resume_time;
1214 1227
1215 wvs_cancel_refresh(WVS_REFRESH_VIDEO | WVS_REFRESH_RESUME); 1228 wvs_cancel_refresh(WVS_REFRESH_VIDEO | WVS_REFRESH_RESUME);
1229 wvs_set_status(WVS_STATUS_STOPPED | WVS_NODRAW);
1216 wvs_show(WVS_HIDE | WVS_NODRAW); 1230 wvs_show(WVS_HIDE | WVS_NODRAW);
1217 1231
1218 stream_stop(); 1232 stream_stop();
@@ -1254,6 +1268,43 @@ static void wvs_seek(int btn)
1254 stream_seek(time, SEEK_SET); 1268 stream_seek(time, SEEK_SET);
1255} 1269}
1256 1270
1271#ifdef HAVE_HEADPHONE_DETECTION
1272/* Handle SYS_PHONE_PLUGGED/UNPLUGGED */
1273static void wvs_handle_phone_plug(bool inserted)
1274{
1275 if (rb->global_settings->unplug_mode == 0)
1276 return;
1277
1278 /* Wait for any incomplete state transition to complete first */
1279 stream_wait_status();
1280
1281 int status = wvs_status();
1282
1283 if (inserted) {
1284 if (rb->global_settings->unplug_mode > 1) {
1285 if (status == STREAM_PAUSED) {
1286 backlight_force_on(rb);
1287 wvs_resume();
1288 }
1289 }
1290 } else {
1291 if (status == STREAM_PLAYING) {
1292 wvs_pause();
1293 backlight_use_settings(rb);
1294
1295 if (stream_can_seek() && rb->global_settings->unplug_rw) {
1296 stream_seek(-rb->global_settings->unplug_rw*TS_SECOND,
1297 SEEK_CUR);
1298 wvs_schedule_refresh(WVS_REFRESH_VIDEO);
1299 /* Update time display now */
1300 wvs_update_time();
1301 wvs_refresh(WVS_REFRESH_TIME);
1302 }
1303 }
1304 }
1305}
1306#endif
1307
1257static void button_loop(void) 1308static void button_loop(void)
1258{ 1309{
1259 rb->lcd_setfont(FONT_SYSFIXED); 1310 rb->lcd_setfont(FONT_SYSFIXED);
@@ -1406,6 +1457,15 @@ static void button_loop(void)
1406 break; 1457 break;
1407 } /* MPEG_RW: MPEG_FF: */ 1458 } /* MPEG_RW: MPEG_FF: */
1408 1459
1460#ifdef HAVE_HEADPHONE_DETECTION
1461 case SYS_PHONE_PLUGGED:
1462 case SYS_PHONE_UNPLUGGED:
1463 {
1464 wvs_handle_phone_plug(button == SYS_PHONE_PLUGGED);
1465 break;
1466 } /* SYS_PHONE_*: */
1467#endif
1468
1409 default: 1469 default:
1410 { 1470 {
1411 rb->default_event_handler(button); 1471 rb->default_event_handler(button);
diff --git a/apps/plugins/mpegplayer/stream_mgr.c b/apps/plugins/mpegplayer/stream_mgr.c
index ad1df6f31a..e79c5fd595 100644
--- a/apps/plugins/mpegplayer/stream_mgr.c
+++ b/apps/plugins/mpegplayer/stream_mgr.c
@@ -809,6 +809,13 @@ uint32_t stream_get_seek_time(uint32_t *start)
809 return time; 809 return time;
810} 810}
811 811
812/* Wait for a state transistion to complete */
813void stream_wait_status(void)
814{
815 stream_mgr_lock();
816 stream_mgr_unlock();
817}
818
812/* Returns the smallest file window that includes all active streams' 819/* Returns the smallest file window that includes all active streams'
813 * windows */ 820 * windows */
814static bool stream_get_window_callback(struct list_item *item, 821static bool stream_get_window_callback(struct list_item *item,
diff --git a/apps/plugins/mpegplayer/stream_mgr.h b/apps/plugins/mpegplayer/stream_mgr.h
index c987181343..339af17182 100644
--- a/apps/plugins/mpegplayer/stream_mgr.h
+++ b/apps/plugins/mpegplayer/stream_mgr.h
@@ -137,6 +137,9 @@ static inline uint32_t stream_get_ticks(uint32_t *start)
137static inline int stream_status(void) 137static inline int stream_status(void)
138 { return stream_mgr.status; } 138 { return stream_mgr.status; }
139 139
140/* Wait for a state transistion to complete */
141void stream_wait_status(void);
142
140/* Returns the playback length of the stream */ 143/* Returns the playback length of the stream */
141static inline uint32_t stream_get_duration(void) 144static inline uint32_t stream_get_duration(void)
142 { return str_parser.duration; } 145 { return str_parser.duration; }