diff options
Diffstat (limited to 'apps/plugins/video.c')
-rw-r--r-- | apps/plugins/video.c | 73 |
1 files changed, 47 insertions, 26 deletions
diff --git a/apps/plugins/video.c b/apps/plugins/video.c index c1ce149ea3..63d03312b9 100644 --- a/apps/plugins/video.c +++ b/apps/plugins/video.c | |||
@@ -32,6 +32,14 @@ | |||
32 | #ifndef SIMULATOR // not for simulator by now | 32 | #ifndef SIMULATOR // not for simulator by now |
33 | #ifdef HAVE_LCD_BITMAP // and definitely not for the Player, haha | 33 | #ifdef HAVE_LCD_BITMAP // and definitely not for the Player, haha |
34 | 34 | ||
35 | /* variable button definitions */ | ||
36 | #if CONFIG_KEYPAD == RECORDER_PAD | ||
37 | #define VIDEO_STOP_SEEK BUTTON_PLAY | ||
38 | #define VIDEO_RESUME BUTTON_PLAY | ||
39 | #elif CONFIG_KEYPAD == ONDIO_PAD | ||
40 | #define VIDEO_STOP_SEEK BUTTON_MENU | ||
41 | #define VIDEO_RESUME BUTTON_RIGHT | ||
42 | #endif | ||
35 | /****************** constants ******************/ | 43 | /****************** constants ******************/ |
36 | 44 | ||
37 | #define INT_MAX ((int)(~(unsigned)0 >> 1)) | 45 | #define INT_MAX ((int)(~(unsigned)0 >> 1)) |
@@ -274,6 +282,7 @@ void ChangeVolume(int delta) | |||
274 | } | 282 | } |
275 | 283 | ||
276 | 284 | ||
285 | #if CONFIG_KEYPAD == RECORDER_PAD | ||
277 | // helper function to change the LCD contrast by a certain amount, +/- | 286 | // helper function to change the LCD contrast by a certain amount, +/- |
278 | void ChangeContrast(int delta) | 287 | void ChangeContrast(int delta) |
279 | { | 288 | { |
@@ -301,6 +310,7 @@ void ChangeContrast(int delta) | |||
301 | } | 310 | } |
302 | } | 311 | } |
303 | } | 312 | } |
313 | #endif | ||
304 | 314 | ||
305 | 315 | ||
306 | // sync the video to the current audio | 316 | // sync the video to the current audio |
@@ -440,6 +450,7 @@ int WaitForButton(void) | |||
440 | do | 450 | do |
441 | { | 451 | { |
442 | button = rb->button_get(true); | 452 | button = rb->button_get(true); |
453 | rb->default_event_handler(button); | ||
443 | } while ((button & BUTTON_REL) && button != SYS_USB_CONNECTED); | 454 | } while ((button & BUTTON_REL) && button != SYS_USB_CONNECTED); |
444 | 455 | ||
445 | return button; | 456 | return button; |
@@ -459,7 +470,7 @@ bool WantResume(int fd) | |||
459 | rb->lcd_update(); | 470 | rb->lcd_update(); |
460 | 471 | ||
461 | button = WaitForButton(); | 472 | button = WaitForButton(); |
462 | return (button == BUTTON_PLAY); | 473 | return (button == VIDEO_RESUME); |
463 | } | 474 | } |
464 | 475 | ||
465 | 476 | ||
@@ -523,6 +534,23 @@ int SeekTo(int fd, int nPos) | |||
523 | return 0; | 534 | return 0; |
524 | } | 535 | } |
525 | 536 | ||
537 | // called from default_event_handler_ex() or at end of playback | ||
538 | void Cleanup(void *fd) | ||
539 | { | ||
540 | rb->close(*(int*)fd); // close the file | ||
541 | |||
542 | if (gPlay.bHasVideo) | ||
543 | rb->plugin_unregister_timer(); // stop video ISR, now I can use the display again | ||
544 | |||
545 | if (gPlay.bHasAudio) | ||
546 | rb->mp3_play_stop(); // stop audio ISR | ||
547 | |||
548 | // restore normal backlight setting | ||
549 | rb->backlight_set_timeout(rb->global_settings->backlight_timeout); | ||
550 | |||
551 | // restore normal contrast | ||
552 | rb->lcd_set_contrast(rb->global_settings->contrast); | ||
553 | } | ||
526 | 554 | ||
527 | // returns >0 if continue, =0 to stop, <0 to abort (USB) | 555 | // returns >0 if continue, =0 to stop, <0 to abort (USB) |
528 | int PlayTick(int fd) | 556 | int PlayTick(int fd) |
@@ -631,6 +659,11 @@ int PlayTick(int fd) | |||
631 | filepos -= Available(gBuf.pReadVideo); // take video position | 659 | filepos -= Available(gBuf.pReadVideo); // take video position |
632 | else | 660 | else |
633 | filepos -= Available(gBuf.pReadAudio); // else audio | 661 | filepos -= Available(gBuf.pReadAudio); // else audio |
662 | |||
663 | if (rb->default_event_handler_ex(button, Cleanup, &fd) | ||
664 | == SYS_USB_CONNECTED) | ||
665 | retval = -1; // signal "aborted" to caller | ||
666 | // SYS_USB_CONNECTED won't be catched again by the switch() | ||
634 | 667 | ||
635 | switch (button) | 668 | switch (button) |
636 | { // set exit conditions | 669 | { // set exit conditions |
@@ -642,12 +675,10 @@ int PlayTick(int fd) | |||
642 | rb->lseek(fd, 0, SEEK_SET); // save resume position | 675 | rb->lseek(fd, 0, SEEK_SET); // save resume position |
643 | rb->write(fd, &gFileHdr, sizeof(gFileHdr)); | 676 | rb->write(fd, &gFileHdr, sizeof(gFileHdr)); |
644 | } | 677 | } |
645 | retval = 0; // signal "stop" to caller | 678 | Cleanup(&fd); |
646 | break; | 679 | retval = 0; // signal "stopped" to caller |
647 | case SYS_USB_CONNECTED: | ||
648 | retval = -1; // signal "abort" to caller | ||
649 | break; | 680 | break; |
650 | case BUTTON_PLAY: | 681 | case VIDEO_STOP_SEEK: |
651 | if (gPlay.bSeeking) | 682 | if (gPlay.bSeeking) |
652 | { | 683 | { |
653 | gPlay.bSeeking = false; | 684 | gPlay.bSeeking = false; |
@@ -714,6 +745,7 @@ int PlayTick(int fd) | |||
714 | else | 745 | else |
715 | gPlay.nSeekAcc++; | 746 | gPlay.nSeekAcc++; |
716 | break; | 747 | break; |
748 | #if CONFIG_KEYPAD == RECORDER_PAD | ||
717 | case BUTTON_F1: // debug key | 749 | case BUTTON_F1: // debug key |
718 | case BUTTON_F1 | BUTTON_REPEAT: | 750 | case BUTTON_F1 | BUTTON_REPEAT: |
719 | DrawBuf(); // show buffer status | 751 | DrawBuf(); // show buffer status |
@@ -730,6 +762,7 @@ int PlayTick(int fd) | |||
730 | if (gPlay.bHasVideo) | 762 | if (gPlay.bHasVideo) |
731 | ChangeContrast(1); | 763 | ChangeContrast(1); |
732 | break; | 764 | break; |
765 | #endif | ||
733 | } | 766 | } |
734 | } /* if (button != BUTTON_NONE) */ | 767 | } /* if (button != BUTTON_NONE) */ |
735 | 768 | ||
@@ -832,7 +865,13 @@ int main(char* filename) | |||
832 | gFileHdr.video_frametime = FREQ / FPS; | 865 | gFileHdr.video_frametime = FREQ / FPS; |
833 | gFileHdr.bps_peak = gFileHdr.bps_average = LCD_WIDTH * LCD_HEIGHT * FPS; | 866 | gFileHdr.bps_peak = gFileHdr.bps_average = LCD_WIDTH * LCD_HEIGHT * FPS; |
834 | } | 867 | } |
835 | 868 | #if FREQ == 12000000 | |
869 | /* temporary sync fix for Ondio, as .rvf is tailored to the recorder CPU freq | ||
870 | * 625 / 576 == 12000000 / 11059200 */ | ||
871 | else | ||
872 | gFileHdr.video_frametime = (gFileHdr.video_frametime * 625) / 576; | ||
873 | #endif | ||
874 | |||
836 | // continue buffer init: align the end, calc low water, read sizes | 875 | // continue buffer init: align the end, calc low water, read sizes |
837 | gBuf.granularity = gFileHdr.blocksize; | 876 | gBuf.granularity = gFileHdr.blocksize; |
838 | while (gBuf.granularity % 512) // common multiple of sector size | 877 | while (gBuf.granularity % 512) // common multiple of sector size |
@@ -877,20 +916,6 @@ int main(char* filename) | |||
877 | retval = PlayTick(fd); | 916 | retval = PlayTick(fd); |
878 | } while (retval > 0); | 917 | } while (retval > 0); |
879 | 918 | ||
880 | rb->close(fd); // close the file | ||
881 | |||
882 | if (gPlay.bHasVideo) | ||
883 | rb->plugin_unregister_timer(); // stop video ISR, now I can use the display again | ||
884 | |||
885 | if (gPlay.bHasAudio) | ||
886 | rb->mp3_play_stop(); // stop audio ISR | ||
887 | |||
888 | // restore normal backlight setting | ||
889 | rb->backlight_set_timeout(rb->global_settings->backlight_timeout); | ||
890 | |||
891 | // restore normal contrast | ||
892 | rb->lcd_set_contrast(rb->global_settings->contrast); | ||
893 | |||
894 | if (retval < 0) // aborted? | 919 | if (retval < 0) // aborted? |
895 | { | 920 | { |
896 | return PLUGIN_USB_CONNECTED; | 921 | return PLUGIN_USB_CONNECTED; |
@@ -930,7 +955,6 @@ int main(char* filename) | |||
930 | 955 | ||
931 | enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | 956 | enum plugin_status plugin_start(struct plugin_api* api, void* parameter) |
932 | { | 957 | { |
933 | int ret; | ||
934 | /* this macro should be called as the first thing you do in the plugin. | 958 | /* this macro should be called as the first thing you do in the plugin. |
935 | it test that the api version and model the plugin was compiled for | 959 | it test that the api version and model the plugin was compiled for |
936 | matches the machine it is running on */ | 960 | matches the machine it is running on */ |
@@ -945,10 +969,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
945 | } | 969 | } |
946 | 970 | ||
947 | // now go ahead and have fun! | 971 | // now go ahead and have fun! |
948 | ret = main((char*) parameter); | 972 | return main((char*) parameter); |
949 | if (ret==PLUGIN_USB_CONNECTED) | ||
950 | rb->usb_screen(); | ||
951 | return ret; | ||
952 | } | 973 | } |
953 | 974 | ||
954 | #endif // #ifdef HAVE_LCD_BITMAP | 975 | #endif // #ifdef HAVE_LCD_BITMAP |