@@ -186,6 +186,7 @@ OMX_MediaProcessor::OMX_MediaProcessor(OMX_EGLBufferProviderSh provider) :
186
186
m_buffer_empty(true ),
187
187
m_pendingStop(false ),
188
188
m_pendingPause(false ),
189
+ m_pendingSeek(false ),
189
190
m_subtitle_index(0 ),
190
191
m_audio_index(0 ),
191
192
m_streamLength(0 ),
@@ -509,6 +510,7 @@ bool OMX_MediaProcessor::playInt()
509
510
return false ;
510
511
}
511
512
513
+ log_info (" Play command received." );
512
514
if (m_av_clock->OMXPlaySpeed () != DVD_PLAYSPEED_NORMAL && m_av_clock->OMXPlaySpeed () != DVD_PLAYSPEED_PAUSE) {
513
515
LOG_VERBOSE (LOG_TAG, " resume\n " );
514
516
m_playspeedCurrent = playspeed_normal;
@@ -573,6 +575,7 @@ bool OMX_MediaProcessor::stopInt()
573
575
return false ;
574
576
}
575
577
578
+ log_info (" Stop command received." );
576
579
m_pendingStop = true ;
577
580
578
581
// Wait for command completion.
@@ -622,33 +625,43 @@ bool OMX_MediaProcessor::pauseInt()
622
625
m_player_subtitles.Pause ();
623
626
#endif
624
627
628
+ log_info (" Pause command received" );
625
629
setSpeed (playspeeds[m_playspeedCurrent]);
626
630
m_av_clock->OMXPause ();
627
631
628
632
// Wait for command completion.
629
633
m_mutexPending.lock ();
630
634
if (m_pendingPause) {
631
- LOG_VERBOSE (LOG_TAG, " Waiting for the pause command to finish. " );
635
+ LOG_VERBOSE (LOG_TAG, " Waiting for the pause command to finish" );
632
636
m_waitPendingCommand.wait (&m_mutexPending);
633
637
}
634
638
m_mutexPending.unlock ();
635
639
636
640
setState (STATE_PAUSED);
637
641
638
- log_verbose (" Pause command issued. " );
642
+ log_verbose (" Pause command completed " );
639
643
return true ;
640
644
}
641
645
642
646
/* ------------------------------------------------------------------------------
643
647
| OMX_MediaProcessor::seek
644
648
+-----------------------------------------------------------------------------*/
645
649
bool OMX_MediaProcessor::seek (qint64 position)
650
+ {
651
+ return INVOKE (" seekInt" ,
652
+ INVOKE_CONN,
653
+ Q_ARG (qint64, position));
654
+ }
655
+
656
+ /* ------------------------------------------------------------------------------
657
+ | OMX_MediaProcessor::seekInt
658
+ +-----------------------------------------------------------------------------*/
659
+ bool OMX_MediaProcessor::seekInt (qint64 position)
646
660
{
647
661
QMutexLocker locker (&m_sendCmd);
648
662
649
- LOG_VERBOSE (LOG_TAG, " Seek %lldms." , position);
650
663
if (!m_av_clock)
651
- return false ;
664
+ return false ;
652
665
653
666
// Get current position in ms.
654
667
qint64 currentMs = m_av_clock->OMXMediaTime (false )*1E-3 ;
@@ -658,8 +671,19 @@ bool OMX_MediaProcessor::seek(qint64 position)
658
671
if (!incrementMs)
659
672
return true ;
660
673
674
+ log_info (" Seek command to %lldms received" , position);
661
675
m_incrMs = incrementMs;
676
+ m_pendingSeek = true ;
677
+
678
+ // Wait for command completion.
679
+ m_mutexPending.lock ();
680
+ if (m_pendingSeek) {
681
+ log_verbose (" Waiting for the seek command to finish." );
682
+ m_waitPendingCommand.wait (&m_mutexPending);
683
+ }
684
+ m_mutexPending.unlock ();
662
685
686
+ log_verbose (" Seek command completed" );
663
687
return true ;
664
688
}
665
689
@@ -830,16 +854,20 @@ void OMX_MediaProcessor::mediaDecoding()
830
854
831
855
if (m_omx_reader->SeekTime ((int )seek_pos, m_incrMs < 0 .0f , &startpts)) {
832
856
unsigned t = (unsigned )(startpts*1e-6 );
833
- log_info ( " Seek to: %02d:%02d:%02d" , (t/3600 ), (t/60 )%60 , t%60 );
857
+ log_verbose ( " Seeked to: %02d:%02d:%02d" , (t/3600 ), (t/60 )%60 , t%60 );
834
858
flushStreams (startpts);
859
+ log_debug (" Streams flushed" );
835
860
}
836
861
837
862
sentStarted = false ;
838
863
839
- if (m_omx_reader->IsEof ())
864
+ if (m_omx_reader->IsEof ()) {
865
+ log_debug (" EOF" );
840
866
break ;
867
+ }
841
868
842
869
if (m_has_video && !m_player_video->Reset ()) {
870
+ log_debug (" RESET failed on seek" );
843
871
m_incrMs = 0 ;
844
872
break ;
845
873
}
@@ -861,6 +889,13 @@ void OMX_MediaProcessor::mediaDecoding()
861
889
m_packetAfterSeek = false ;
862
890
m_seekFlush = false ;
863
891
m_incrMs = 0 ;
892
+
893
+ m_mutexPending.lock ();
894
+ if (UNLIKELY (m_pendingSeek)) {
895
+ m_waitPendingCommand.wakeAll ();
896
+ m_pendingSeek = false ;
897
+ }
898
+ m_mutexPending.unlock ();
864
899
}
865
900
else if (UNLIKELY (m_packetAfterSeek && TRICKPLAY (m_av_clock->OMXPlaySpeed ()))) {
866
901
double seek_pos = 0 ;
@@ -969,11 +1004,12 @@ void OMX_MediaProcessor::mediaDecoding()
969
1004
// Enable this to enable pause for buffering.
970
1005
if (m_state != STATE_PAUSED && (m_omx_reader->IsEof () || m_omx_pkt || TRICKPLAY (m_av_clock->OMXPlaySpeed ()) || (audio_fifo_high && video_fifo_high))) {
971
1006
if (m_av_clock->OMXIsPaused ()) {
972
- log_verbose (" Resume %.2f,%.2f (%d,%d,%d,%d) EOF:%d PKT:%p\n " ,
1007
+ log_verbose (" Resume %.2f,%.2f (%d,%d,%d,%d) EOF:%d PKT:%p" ,
973
1008
audio_fifo, video_fifo, audio_fifo_low, video_fifo_low, audio_fifo_high, video_fifo_high, m_omx_reader->IsEof (), m_omx_pkt);
974
1009
975
1010
setMediaStatus (OMX_MediaStatus::MEDIA_STATUS_BUFFERED);
976
1011
m_av_clock->OMXResume ();
1012
+ log_debug (" Resume completed" );
977
1013
}
978
1014
}
979
1015
else if (m_state == STATE_PAUSED || audio_fifo_low || video_fifo_low)
@@ -1139,29 +1175,40 @@ void OMX_MediaProcessor::setSpeed(int iSpeed)
1139
1175
+-----------------------------------------------------------------------------*/
1140
1176
void OMX_MediaProcessor::flushStreams (double pts)
1141
1177
{
1178
+ log_debug (" Stopping av_clock" );
1142
1179
m_av_clock->OMXStop ();
1180
+
1181
+ log_debug (" Pausing av_clock" );
1143
1182
m_av_clock->OMXPause ();
1144
1183
1145
1184
if (m_has_video) {
1185
+ log_verbose (" Flushing" );
1146
1186
m_player_video->Flush ();
1147
1187
m_provider->flush ();
1148
1188
}
1149
1189
1150
- if (m_has_audio)
1190
+ if (m_has_audio) {
1191
+ log_debug (" Flushing audio" );
1151
1192
m_player_audio->Flush ();
1193
+ }
1152
1194
1153
- if (pts != DVD_NOPTS_VALUE)
1195
+ if (pts != DVD_NOPTS_VALUE) {
1196
+ log_debug (" Set media time in flushStreams" );
1154
1197
m_av_clock->OMXMediaTime (pts);
1198
+ }
1155
1199
1156
1200
#ifdef ENABLE_SUBTITLES
1157
1201
if (m_has_subtitle)
1158
1202
m_player_subtitles->Flush ();
1159
1203
#endif
1160
1204
1161
1205
if (m_omx_pkt) {
1206
+ log_debug (" Freeing packet in flushStreams" );
1162
1207
m_omx_reader->FreePacket (m_omx_pkt);
1163
1208
m_omx_pkt = NULL ;
1164
1209
}
1210
+
1211
+ log_debug (" flushStreams finished" );
1165
1212
}
1166
1213
1167
1214
/* ------------------------------------------------------------------------------
0 commit comments