diff options
Diffstat (limited to 'apps/plugins/mpegplayer/mpegplayer.c')
-rw-r--r-- | apps/plugins/mpegplayer/mpegplayer.c | 64 |
1 files changed, 49 insertions, 15 deletions
diff --git a/apps/plugins/mpegplayer/mpegplayer.c b/apps/plugins/mpegplayer/mpegplayer.c index 82703ca840..5b92ccced1 100644 --- a/apps/plugins/mpegplayer/mpegplayer.c +++ b/apps/plugins/mpegplayer/mpegplayer.c | |||
@@ -587,6 +587,30 @@ static void draw_putsxy_oriented(int x, int y, const char *str) | |||
587 | } | 587 | } |
588 | #endif /* LCD_PORTRAIT */ | 588 | #endif /* LCD_PORTRAIT */ |
589 | 589 | ||
590 | static void wvs_backlight_on_video_mode(bool video_on) | ||
591 | { | ||
592 | if (video_on) { | ||
593 | /* Turn off backlight timeout */ | ||
594 | /* backlight control in lib/helper.c */ | ||
595 | backlight_force_on(rb); | ||
596 | } else { | ||
597 | /* Revert to user's backlight settings */ | ||
598 | backlight_use_settings(rb); | ||
599 | } | ||
600 | } | ||
601 | |||
602 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS | ||
603 | static void wvs_backlight_brightness_video_mode(bool video_on) | ||
604 | { | ||
605 | if (settings.backlight_brightness < 0) | ||
606 | return; | ||
607 | |||
608 | mpeg_backlight_update_brightness( | ||
609 | video_on ? settings.backlight_brightness : -1); | ||
610 | } | ||
611 | #else | ||
612 | #define wvs_backlight_brightness_video_mode(video_on) | ||
613 | #endif /* HAVE_BACKLIGHT_BRIGHTNESS */ | ||
590 | 614 | ||
591 | static void wvs_text_init(void) | 615 | static void wvs_text_init(void) |
592 | { | 616 | { |
@@ -1012,6 +1036,11 @@ static void wvs_show(unsigned show) | |||
1012 | 1036 | ||
1013 | wvs.flags |= WVS_SHOW; | 1037 | wvs.flags |= WVS_SHOW; |
1014 | 1038 | ||
1039 | if (wvs.status != WVS_STATUS_PLAYING) { | ||
1040 | /* Not playing - set brightness to mpegplayer setting */ | ||
1041 | wvs_backlight_brightness_video_mode(true); | ||
1042 | } | ||
1043 | |||
1015 | stream_vo_set_clip(&rc); | 1044 | stream_vo_set_clip(&rc); |
1016 | 1045 | ||
1017 | if (!(show & WVS_NODRAW)) | 1046 | if (!(show & WVS_NODRAW)) |
@@ -1032,6 +1061,11 @@ static void wvs_show(unsigned show) | |||
1032 | } else { | 1061 | } else { |
1033 | stream_vo_set_clip(NULL); | 1062 | stream_vo_set_clip(NULL); |
1034 | } | 1063 | } |
1064 | |||
1065 | if (wvs.status != WVS_STATUS_PLAYING) { | ||
1066 | /* Not playing - restore backlight brightness */ | ||
1067 | wvs_backlight_brightness_video_mode(false); | ||
1068 | } | ||
1035 | } | 1069 | } |
1036 | } | 1070 | } |
1037 | 1071 | ||
@@ -1227,6 +1261,8 @@ static int wvs_play(uint32_t time) | |||
1227 | retval = stream_seek(time, SEEK_SET); | 1261 | retval = stream_seek(time, SEEK_SET); |
1228 | 1262 | ||
1229 | if (retval >= STREAM_OK) { | 1263 | if (retval >= STREAM_OK) { |
1264 | wvs_backlight_on_video_mode(true); | ||
1265 | wvs_backlight_brightness_video_mode(true); | ||
1230 | stream_show_vo(true); | 1266 | stream_show_vo(true); |
1231 | retval = stream_play(); | 1267 | retval = stream_play(); |
1232 | 1268 | ||
@@ -1251,6 +1287,8 @@ static int wvs_halt(void) | |||
1251 | /* Cancel some auto refreshes - caller will restart them if desired */ | 1287 | /* Cancel some auto refreshes - caller will restart them if desired */ |
1252 | wvs_cancel_refresh(WVS_REFRESH_VIDEO | WVS_REFRESH_RESUME); | 1288 | wvs_cancel_refresh(WVS_REFRESH_VIDEO | WVS_REFRESH_RESUME); |
1253 | 1289 | ||
1290 | /* No backlight fiddling here - callers does the right thing */ | ||
1291 | |||
1254 | return status; | 1292 | return status; |
1255 | } | 1293 | } |
1256 | 1294 | ||
@@ -1267,14 +1305,19 @@ static int wvs_pause(void) | |||
1267 | 1305 | ||
1268 | wvs_set_status(WVS_STATUS_PAUSED); | 1306 | wvs_set_status(WVS_STATUS_PAUSED); |
1269 | 1307 | ||
1308 | wvs_backlight_on_video_mode(false); | ||
1309 | /* Leave brightness alone and restore it when WVS is hidden */ | ||
1310 | |||
1270 | return status; | 1311 | return status; |
1271 | } | 1312 | } |
1272 | 1313 | ||
1273 | /* Resume playback if halted or paused */ | 1314 | /* Resume playback if halted or paused */ |
1274 | static void wvs_resume(void) | 1315 | static void wvs_resume(void) |
1275 | { | 1316 | { |
1276 | /* Cancel video and resume auto refresh - the resyc when starting playback | 1317 | /* Cancel video and resume auto refresh - the resyc when starting |
1277 | * will perform those tasks */ | 1318 | * playback will perform those tasks */ |
1319 | wvs_backlight_on_video_mode(true); | ||
1320 | wvs_backlight_brightness_video_mode(true); | ||
1278 | wvs_cancel_refresh(WVS_REFRESH_VIDEO | WVS_REFRESH_RESUME); | 1321 | wvs_cancel_refresh(WVS_REFRESH_VIDEO | WVS_REFRESH_RESUME); |
1279 | wvs_set_status(WVS_STATUS_PLAYING); | 1322 | wvs_set_status(WVS_STATUS_PLAYING); |
1280 | stream_resume(); | 1323 | stream_resume(); |
@@ -1295,6 +1338,9 @@ static void wvs_stop(void) | |||
1295 | 1338 | ||
1296 | if (resume_time != INVALID_TIMESTAMP) | 1339 | if (resume_time != INVALID_TIMESTAMP) |
1297 | settings.resume_time = resume_time; | 1340 | settings.resume_time = resume_time; |
1341 | |||
1342 | wvs_backlight_on_video_mode(false); | ||
1343 | wvs_backlight_brightness_video_mode(false); | ||
1298 | } | 1344 | } |
1299 | 1345 | ||
1300 | /* Perform a seek if seeking is possible for this stream - if playing, a delay | 1346 | /* Perform a seek if seeking is possible for this stream - if playing, a delay |
@@ -1343,14 +1389,12 @@ static void wvs_handle_phone_plug(bool inserted) | |||
1343 | if (inserted) { | 1389 | if (inserted) { |
1344 | if (rb->global_settings->unplug_mode > 1) { | 1390 | if (rb->global_settings->unplug_mode > 1) { |
1345 | if (status == STREAM_PAUSED) { | 1391 | if (status == STREAM_PAUSED) { |
1346 | backlight_force_on(rb); | ||
1347 | wvs_resume(); | 1392 | wvs_resume(); |
1348 | } | 1393 | } |
1349 | } | 1394 | } |
1350 | } else { | 1395 | } else { |
1351 | if (status == STREAM_PLAYING) { | 1396 | if (status == STREAM_PLAYING) { |
1352 | wvs_pause(); | 1397 | wvs_pause(); |
1353 | backlight_use_settings(rb); | ||
1354 | 1398 | ||
1355 | if (stream_can_seek() && rb->global_settings->unplug_rw) { | 1399 | if (stream_can_seek() && rb->global_settings->unplug_rw) { |
1356 | stream_seek(-rb->global_settings->unplug_rw*TS_SECOND, | 1400 | stream_seek(-rb->global_settings->unplug_rw*TS_SECOND, |
@@ -1371,10 +1415,6 @@ static void button_loop(void) | |||
1371 | rb->lcd_clear_display(); | 1415 | rb->lcd_clear_display(); |
1372 | rb->lcd_update(); | 1416 | rb->lcd_update(); |
1373 | 1417 | ||
1374 | /* Turn off backlight timeout */ | ||
1375 | /* backlight control in lib/helper.c */ | ||
1376 | backlight_force_on(rb); | ||
1377 | |||
1378 | wvs_init(); | 1418 | wvs_init(); |
1379 | 1419 | ||
1380 | /* Start playback at the specified starting time */ | 1420 | /* Start playback at the specified starting time */ |
@@ -1442,7 +1482,7 @@ static void button_loop(void) | |||
1442 | /* Hide video output */ | 1482 | /* Hide video output */ |
1443 | wvs_show(WVS_HIDE | WVS_NODRAW); | 1483 | wvs_show(WVS_HIDE | WVS_NODRAW); |
1444 | stream_show_vo(false); | 1484 | stream_show_vo(false); |
1445 | backlight_use_settings(rb); | 1485 | wvs_backlight_brightness_video_mode(false); |
1446 | 1486 | ||
1447 | result = mpeg_menu(0); | 1487 | result = mpeg_menu(0); |
1448 | 1488 | ||
@@ -1464,7 +1504,6 @@ static void button_loop(void) | |||
1464 | 1504 | ||
1465 | /* If stream was playing, restart it */ | 1505 | /* If stream was playing, restart it */ |
1466 | if (state == STREAM_PLAYING) { | 1506 | if (state == STREAM_PLAYING) { |
1467 | backlight_force_on(rb); | ||
1468 | wvs_resume(); | 1507 | wvs_resume(); |
1469 | } | 1508 | } |
1470 | break; | 1509 | break; |
@@ -1495,11 +1534,9 @@ static void button_loop(void) | |||
1495 | if (status == STREAM_PLAYING) { | 1534 | if (status == STREAM_PLAYING) { |
1496 | /* Playing => Paused */ | 1535 | /* Playing => Paused */ |
1497 | wvs_pause(); | 1536 | wvs_pause(); |
1498 | backlight_use_settings(rb); | ||
1499 | } | 1537 | } |
1500 | else if (status == STREAM_PAUSED) { | 1538 | else if (status == STREAM_PAUSED) { |
1501 | /* Paused => Playing */ | 1539 | /* Paused => Playing */ |
1502 | backlight_force_on(rb); | ||
1503 | wvs_resume(); | 1540 | wvs_resume(); |
1504 | } | 1541 | } |
1505 | 1542 | ||
@@ -1539,9 +1576,6 @@ static void button_loop(void) | |||
1539 | wvs_stop(); | 1576 | wvs_stop(); |
1540 | 1577 | ||
1541 | rb->lcd_setfont(FONT_UI); | 1578 | rb->lcd_setfont(FONT_UI); |
1542 | |||
1543 | /* Turn on backlight timeout (revert to settings) */ | ||
1544 | backlight_use_settings(rb); | ||
1545 | } | 1579 | } |
1546 | 1580 | ||
1547 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 1581 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) |