summaryrefslogtreecommitdiff
path: root/apps/plugins/mpegplayer/stream_mgr.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/mpegplayer/stream_mgr.c')
-rw-r--r--apps/plugins/mpegplayer/stream_mgr.c133
1 files changed, 109 insertions, 24 deletions
diff --git a/apps/plugins/mpegplayer/stream_mgr.c b/apps/plugins/mpegplayer/stream_mgr.c
index 06f269ca31..1baa2032ec 100644
--- a/apps/plugins/mpegplayer/stream_mgr.c
+++ b/apps/plugins/mpegplayer/stream_mgr.c
@@ -251,6 +251,7 @@ static void set_stream_clock(uint32_t time)
251static uint32_t time_from_whence(uint32_t time, int whence) 251static uint32_t time_from_whence(uint32_t time, int whence)
252{ 252{
253 int64_t currtime; 253 int64_t currtime;
254 uint32_t start;
254 255
255 switch (whence) 256 switch (whence)
256 { 257 {
@@ -262,12 +263,8 @@ static uint32_t time_from_whence(uint32_t time, int whence)
262 case SEEK_CUR: 263 case SEEK_CUR:
263 /* Seek forward or backward from the current time 264 /* Seek forward or backward from the current time
264 * (time = signed offset from current) */ 265 * (time = signed offset from current) */
265 if (stream_mgr.seeked) 266 currtime = stream_get_seek_time(&start);
266 currtime = str_parser.last_seek_time; 267 currtime -= start;
267 else
268 currtime = TICKS_TO_TS(pcm_output_get_clock());
269
270 currtime -= str_parser.start_pts;
271 currtime += (int32_t)time; 268 currtime += (int32_t)time;
272 269
273 if (currtime < 0) 270 if (currtime < 0)
@@ -525,27 +522,28 @@ static void stream_on_stop(bool reply)
525 522
526 if (status != STREAM_STOPPED) 523 if (status != STREAM_STOPPED)
527 { 524 {
528 /* Not stopped = paused or playing */
529 stream_mgr.seeked = false;
530
531 /* Pause the clock */ 525 /* Pause the clock */
532 pcm_output_play_pause(false); 526 pcm_output_play_pause(false);
533 527
528 /* Assume invalidity */
529 stream_mgr.resume_time = 0;
530
534 if (stream_can_seek()) 531 if (stream_can_seek())
535 { 532 {
536 /* Read the current stream time */ 533 /* Read the current stream time or the last seeked position */
537 uint32_t time = TICKS_TO_TS(pcm_output_get_clock()); 534 uint32_t start;
538 535 uint32_t time = stream_get_seek_time(&start);
539 /* Assume invalidity */
540 stream_mgr.resume_time = 0;
541 536
542 if (time >= str_parser.start_pts && time < str_parser.end_pts) 537 if (time >= str_parser.start_pts && time < str_parser.end_pts)
543 { 538 {
544 /* Save the current stream time */ 539 /* Save the current stream time */
545 stream_mgr.resume_time = time - str_parser.start_pts; 540 stream_mgr.resume_time = time - start;
546 } 541 }
547 } 542 }
548 543
544 /* Not stopped = paused or playing */
545 stream_mgr.seeked = false;
546
549 /* Stop buffering */ 547 /* Stop buffering */
550 disk_buf_send_msg(STREAM_STOP, 0); 548 disk_buf_send_msg(STREAM_STOP, 0);
551 549
@@ -578,10 +576,10 @@ static void stream_on_seek(struct stream_seek_data *skd)
578 if (stream_mgr.filename == NULL) 576 if (stream_mgr.filename == NULL)
579 break; 577 break;
580 578
581 stream_mgr_reply_msg(STREAM_OK);
582
583 stream_keep_disk_active(); 579 stream_keep_disk_active();
584 580
581 stream_mgr_reply_msg(STREAM_OK);
582
585 stream_mgr_lock(); 583 stream_mgr_lock();
586 584
587 if (!stream_can_seek()) 585 if (!stream_can_seek())
@@ -705,9 +703,11 @@ bool stream_show_vo(bool show)
705 703
706 vis = parser_send_video_msg(VIDEO_DISPLAY_SHOW, show); 704 vis = parser_send_video_msg(VIDEO_DISPLAY_SHOW, show);
707#ifndef HAVE_LCD_COLOR 705#ifndef HAVE_LCD_COLOR
708 GRAY_VIDEO_FLUSH_ICACHE(); 706 GRAY_VIDEO_INVALIDATE_ICACHE();
709 GRAY_INVALIDATE_ICACHE(); 707 GRAY_INVALIDATE_ICACHE();
708
710 gray_show(show); 709 gray_show(show);
710
711 GRAY_FLUSH_ICACHE(); 711 GRAY_FLUSH_ICACHE();
712#endif 712#endif
713 stream_mgr_unlock(); 713 stream_mgr_unlock();
@@ -743,6 +743,32 @@ bool stream_vo_get_size(struct vo_ext *sz)
743 return retval; 743 return retval;
744} 744}
745 745
746void stream_vo_set_clip(const struct vo_rect *rc)
747{
748 stream_mgr_lock();
749
750 if (rc)
751 {
752 stream_mgr.parms.rc = *rc;
753 rc = &stream_mgr.parms.rc;
754 }
755#ifndef HAVE_LCD_COLOR
756 else
757 {
758 vo_rect_set_ext(&stream_mgr.parms.rc, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
759 rc = &stream_mgr.parms.rc;
760 }
761#endif
762
763 parser_send_video_msg(VIDEO_SET_CLIP_RECT, (intptr_t)rc);
764
765#ifndef HAVE_LCD_COLOR
766 stream_set_gray_rect(rc);
767#endif
768
769 stream_mgr_unlock();
770}
771
746#ifndef HAVE_LCD_COLOR 772#ifndef HAVE_LCD_COLOR
747/* Set the rectangle for the gray video overlay - clipped to screen */ 773/* Set the rectangle for the gray video overlay - clipped to screen */
748bool stream_set_gray_rect(const struct vo_rect *rc) 774bool stream_set_gray_rect(const struct vo_rect *rc)
@@ -756,21 +782,38 @@ bool stream_set_gray_rect(const struct vo_rect *rc)
756 782
757 if (vo_rect_intersect(&rc_gray, &rc_gray, rc)) 783 if (vo_rect_intersect(&rc_gray, &rc_gray, rc))
758 { 784 {
759 bool vo_vis = stream_show_vo(false); 785 bool vis = parser_send_video_msg(VIDEO_DISPLAY_SHOW, false);
760 786
761 GRAY_VIDEO_FLUSH_ICACHE(); 787 /* The impudence! Keeps the image from disappearing anyway. */
788#ifdef SIMULATOR
789 rb->sim_lcd_ex_init(0, NULL);
790#else
791 rb->timer_unregister();
792#endif
793 GRAY_VIDEO_INVALIDATE_ICACHE();
762 GRAY_INVALIDATE_ICACHE(); 794 GRAY_INVALIDATE_ICACHE();
763 795
796 vo_lock();
797
764 gray_init(rb, stream_mgr.graymem, stream_mgr.graysize, 798 gray_init(rb, stream_mgr.graymem, stream_mgr.graysize,
765 false, rc_gray.r - rc_gray.l, rc_gray.b - rc_gray.t, 799 false, rc_gray.r - rc_gray.l, rc_gray.b - rc_gray.t,
766 32, 2<<8, NULL); 800 32, 2<<8, NULL);
767 801
768 gray_set_position(rc_gray.l, rc_gray.t); 802 gray_set_position(rc_gray.l, rc_gray.t);
769 GRAY_FLUSH_ICACHE();
770 803
771 if (vo_vis) 804 vo_unlock();
805
806 GRAY_INVALIDATE_ICACHE();
807
808 if (stream_mgr.status != STREAM_PLAYING)
809 parser_send_video_msg(VIDEO_PRINT_FRAME, true);
810
811 GRAY_VIDEO_FLUSH_ICACHE();
812
813 if (vis)
772 { 814 {
773 stream_show_vo(true); 815 gray_show(true);
816 parser_send_video_msg(VIDEO_DISPLAY_SHOW, true);
774 } 817 }
775 } 818 }
776 819
@@ -784,9 +827,11 @@ void stream_gray_show(bool show)
784{ 827{
785 stream_mgr_lock(); 828 stream_mgr_lock();
786 829
787 GRAY_VIDEO_FLUSH_ICACHE(); 830 GRAY_VIDEO_INVALIDATE_ICACHE();
788 GRAY_INVALIDATE_ICACHE(); 831 GRAY_INVALIDATE_ICACHE();
832
789 gray_show(show); 833 gray_show(show);
834
790 GRAY_FLUSH_ICACHE(); 835 GRAY_FLUSH_ICACHE();
791 836
792 stream_mgr_unlock(); 837 stream_mgr_unlock();
@@ -803,11 +848,32 @@ bool stream_display_thumb(const struct vo_rect *rc)
803 848
804 stream_mgr_lock(); 849 stream_mgr_lock();
805 850
851 GRAY_INVALIDATE_ICACHE();
852
806 stream_mgr.parms.rc = *rc; 853 stream_mgr.parms.rc = *rc;
807 retval = parser_send_video_msg(VIDEO_PRINT_THUMBNAIL, 854 retval = parser_send_video_msg(VIDEO_PRINT_THUMBNAIL,
808 (intptr_t)&stream_mgr.parms.rc); 855 (intptr_t)&stream_mgr.parms.rc);
809 856
857 GRAY_VIDEO_FLUSH_ICACHE();
858
810 stream_mgr_unlock(); 859 stream_mgr_unlock();
860
861 return retval;
862}
863
864bool stream_draw_frame(bool no_prepare)
865{
866 bool retval;
867 stream_mgr_lock();
868
869 GRAY_INVALIDATE_ICACHE();
870
871 retval = parser_send_video_msg(VIDEO_PRINT_FRAME, no_prepare);
872
873 GRAY_VIDEO_FLUSH_ICACHE();
874
875 stream_mgr_unlock();
876
811 return retval; 877 return retval;
812} 878}
813 879
@@ -826,6 +892,25 @@ uint32_t stream_get_resume_time(void)
826 return resume_time; 892 return resume_time;
827} 893}
828 894
895uint32_t stream_get_seek_time(uint32_t *start)
896{
897 uint32_t time;
898
899 stream_mgr_lock();
900
901 if (stream_mgr.seeked)
902 time = str_parser.last_seek_time;
903 else
904 time = TICKS_TO_TS(pcm_output_get_clock());
905
906 if (start != NULL)
907 *start = str_parser.start_pts;
908
909 stream_mgr_unlock();
910
911 return time;
912}
913
829/* Returns the smallest file window that includes all active streams' 914/* Returns the smallest file window that includes all active streams'
830 * windows */ 915 * windows */
831static bool stream_get_window_callback(struct list_item *item, 916static bool stream_get_window_callback(struct list_item *item,