]> git.vomp.tv Git - vompclient.git/commitdiff
Fix some thread lookups,Fix deinitilitions of video omx stuff, add messages for debugging
authorMarten Richter <marten.richter@freenet.de>
Mon, 3 Sep 2012 06:40:15 +0000 (08:40 +0200)
committerMarten Richter <marten.richter@freenet.de>
Mon, 3 Sep 2012 06:40:15 +0000 (08:40 +0200)
afeed.cc
audioomx.cc
videoomx.cc

index ba24e5281ca0a31398b758f0daf363699e7f2198..ee0b55b43fbd57e4907432dc6d1980151af8476f 100644 (file)
--- a/afeed.cc
+++ b/afeed.cc
@@ -60,7 +60,9 @@ int AFeed::start()
 \r
 void AFeed::stop()\r
 {\r
+       Log::getInstance()->log("AFeed", Log::DEBUG, "Stop1");\r
   threadCancel();\r
+       Log::getInstance()->log("AFeed", Log::DEBUG, "Stop2");\r
 }\r
 \r
 void AFeed::threadMethod()\r
index 87a82d2505489e820a28420d26c0356c1bbabba5..2d8ec88ad10c6a9ac01408898b4368cec637d2d7 100644 (file)
@@ -952,24 +952,29 @@ int AudioOMX::DeAllocateCodecsOMX()
 
 
    video->LockClock();
+   Log::getInstance()->log("Audio", Log::DEBUG, "deallocatecodecsomx mark 1");
    if (cur_input_buf_omx) {
                cur_input_buf_omx->nFlags|=OMX_BUFFERFLAG_EOS;
                OMX_ERRORTYPE error=OMX_EmptyThisBuffer(omx_aud_rend/*dec*/,cur_input_buf_omx);
                if (error!=OMX_ErrorNone) {
-                       Log::getInstance()->log("Audio", Log::DEBUG, "OMX_EmptyThisBuffer failed %x", error);
+                       Log::getInstance()->log("Audio", Log::DEBUG, "OMX_EmptyThisBuffer failed %x", error);
                }
 
                cur_input_buf_omx=NULL;//write out old data
        }
+   Log::getInstance()->log("Audio", Log::DEBUG, "deallocatecodecsomx mark 2");
 
        if (omx_aud_rend/*dec*/) {
                // first stop the omx elements
        /*      if (!video->ChangeComponentState(omx_aud_dec,OMX_StateIdle)) {
                        Log::getInstance()->log("Audio", Log::DEBUG, "aud_dec ChangeComponentState");
                }*/
+                Log::getInstance()->log("Audio", Log::DEBUG, "deallocatecodecsomx mark 3");
 
                video->UnlockClock();
+               Log::getInstance()->log("Audio", Log::DEBUG, "deallocatecodecsomx mark 4");
                video->idleClock();
+               Log::getInstance()->log("Audio", Log::DEBUG, "deallocatecodecsomx mark 5");
                 video->LockClock();
 
                if (!video->ChangeComponentState(omx_aud_rend,OMX_StateIdle)) {
@@ -1009,6 +1014,7 @@ int AudioOMX::DeAllocateCodecsOMX()
                        Log::getInstance()->log("Audio", Log::DEBUG, "OMX_Flush rend clock failed %x", error);
 
                }
+               Log::getInstance()->log("Audio", Log::DEBUG, "deallocatecodecsomx mark 6");
 
                if (!video->CommandFinished(omx_clock,OMX_CommandFlush,omx_clock_output_port) ||
                        !video->CommandFinished(omx_aud_rend,OMX_CommandFlush,omx_rend_clock_port)) {
@@ -1016,7 +1022,9 @@ int AudioOMX::DeAllocateCodecsOMX()
                }
 
                DestroyInputBufsOMX(); //We have to make sure that no buffers are in use
+               Log::getInstance()->log("Audio", Log::DEBUG, "deallocatecodecsomx mark 6a");
                DeinitDecoderLibAV();
+               Log::getInstance()->log("Audio", Log::DEBUG, "deallocatecodecsomx mark 7");
 
                //todo flushing
                if (!video->DisablePort(omx_aud_rend,omx_rend_input_port,true)) {
@@ -1067,6 +1075,7 @@ int AudioOMX::DeAllocateCodecsOMX()
                        Log::getInstance()->log("Audio", Log::DEBUG, "OMX_Setup tunnel teardown failed %x", error);
 
                }
+               Log::getInstance()->log("Audio", Log::DEBUG, "deallocatecodecsomx mark 8");
 
 
                //error=OMX_FreeHandle(omx_aud_dec);
@@ -1294,7 +1303,7 @@ UINT AudioOMX::DeliverMediaPacket(MediaPacket packet, const UCHAR* buffer,
                                        cur_input_buf_omx);
                        if (error != OMX_ErrorNone) {
                                Log::getInstance()->log("Audio", Log::DEBUG,
-                                               "OMX_EmptyThisBuffer failed %x", error);
+                                               "OMX_EmptyThisBuffer failed %x", error);
                        }
                        cur_input_buf_omx = NULL;
                }
@@ -1310,7 +1319,7 @@ UINT AudioOMX::DeliverMediaPacket(MediaPacket packet, const UCHAR* buffer,
                                        cur_input_buf_omx);
                        if (error != OMX_ErrorNone) {
                                Log::getInstance()->log("Audio", Log::DEBUG,
-                                               "OMX_EmptyThisBuffer failed %x", error);
+                                               "OMX_EmptyThisBuffer failed %x", error);
                        }
                        cur_input_buf_omx = NULL;
                }
@@ -1334,7 +1343,7 @@ UINT AudioOMX::DeliverMediaPacket(MediaPacket packet, const UCHAR* buffer,
                                                cur_input_buf_omx);
                                if (error != OMX_ErrorNone) {
                                        Log::getInstance()->log("Audio", Log::DEBUG,
-                                                       "OMX_EmptyThisBuffer failed %x", error);
+                                                       "OMX_EmptyThisBuffer failed %x", error);
                                }
                                //FrameWaitforDisplay(lastreftimeOMX);
                                 vw->AdjustAudioPTS(correctAudioLatency(lastreftimeOMX,cur_input_buf_omx->nFilledLen/(2*2),48000));
@@ -1429,21 +1438,34 @@ UINT AudioOMX::DeliverMediaPacket(MediaPacket packet, const UCHAR* buffer,
                while (haveToCopy> 0 && errcount<2) {
 
                        //Log::getInstance()->log("Audio", Log::DEBUG,"libav in %d %d",framesize,current_context->frame_size);
+                       //Log::getInstance()->log("Audio", Log::DEBUG, "libav in %d %d",
+                               //      framesize, current_context->frame_size);
+                       int oldcancelstate;
+                       int oldcanceltype;
+                       pthread_testcancel();
+                       pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldcancelstate);
+                       pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldcanceltype);
                        libav_mutex.Lock();
-                       if (!omx_running || !mp23codec_context_libav || !ac3codec_context_libav) {
+                       if (!omx_running || !mp23codec_context_libav
+                                       || !ac3codec_context_libav) {
                                libav_mutex.Unlock();
-                               return 0;
+                               return *samplepos;
                        }
-                       Log::getInstance()->log("Audio", Log::DEBUG,"libav in %d %d",framesize,current_context->frame_size);
+                       libav_mutex.Unlock();
+                       //      Log::getInstance()->log("Audio", Log::DEBUG,"libav out");
                        len = avcodec_decode_audio4(current_context, decode_frame_libav,
                                        &gotta, &incoming_paket_libav);
-                       Log::getInstance()->log("Audio", Log::DEBUG,"libav out");
+                       //Log::getInstance()->log("Audio", Log::DEBUG, "libav out1");
+                       pthread_setcancelstate(oldcancelstate, NULL);
+                       pthread_setcanceltype(oldcanceltype, NULL);
+                       pthread_testcancel();
+
+                       //Log::getInstance()->log("Audio", Log::DEBUG, "libav out2");
                        if (!omx_running) {
                                libav_mutex.Unlock();
-                               return 0;
+                               return *samplepos;
                        }
-                       libav_mutex.Unlock();
-               //      Log::getInstance()->log("Audio", Log::DEBUG,"libav out");
+
                        if (len>0) {
                                incoming_paket_libav.data += len;
                                haveToCopy -= len;
@@ -1472,7 +1494,7 @@ UINT AudioOMX::DeliverMediaPacket(MediaPacket packet, const UCHAR* buffer,
                                                        cur_input_buf_omx);
                                        if (error != OMX_ErrorNone) {
                                                Log::getInstance()->log("Audio", Log::DEBUG,
-                                                               "OMX_EmptyThisBuffer failed %x", error);
+                                                               "OMX_EmptyThisBuffer failed %x", error);
                                        }
                                        cur_input_buf_omx = NULL;
 
@@ -1486,7 +1508,7 @@ UINT AudioOMX::DeliverMediaPacket(MediaPacket packet, const UCHAR* buffer,
                                                                Log::getInstance()->log("Audio", Log::DEBUG,
                                                                                "Deliver MediaPacket no free sample");
                                                                MILLISLEEP(5);
-                                                               if (!omx_running) return 0;
+                                                               if (!omx_running) return *samplepos;
                                                                continue;
                                                        }
                                                        cur_input_buf_omx = input_bufs_omx_free.front();
@@ -1521,7 +1543,7 @@ UINT AudioOMX::DeliverMediaPacket(MediaPacket packet, const UCHAR* buffer,
                error = OMX_EmptyThisBuffer(omx_aud_rend/*dec*/, cur_input_buf_omx);
                if (error != OMX_ErrorNone) {
                        Log::getInstance()->log("Audio", Log::DEBUG,
-                                       "OMX_EmptyThisBuffer failed %x", error);
+                                       "OMX_EmptyThisBuffer failed %x", error);
                }
                if (packet.synched) vw->AdjustAudioPTS(correctAudioLatency(lastreftimeOMX,cur_input_buf_omx->nFilledLen/(2*2),48000));
                cur_input_buf_omx = NULL;
index 3a049168c71473d630115676bd606e9f7aed9480..f15779b3096ac34109684cef4eca643339ee26f4 100644 (file)
@@ -1232,36 +1232,72 @@ int VideoOMX::DeAllocateCodecsOMX()
         // TODO proper deinit sequence
                // first flush all buffers
 
-               error=OMX_SendCommand(omx_vid_rend,OMX_CommandFlush, omx_rend_input_port, NULL);
-               if (error!=OMX_ErrorNone) {
-                       Log::getInstance()->log("Video", Log::DEBUG, "OMX_Flush rend in failed %x", error);
+
+               error = OMX_SendCommand(omx_vid_dec, OMX_CommandFlush,
+                               omx_codec_output_port, NULL);
+               if (error != OMX_ErrorNone) {
+                       Log::getInstance()->log("Video", Log::DEBUG,
+                                       "OMX_Flush codec out failed %x", error);
 
                }
 
-               if (!CommandFinished(omx_vid_rend,OMX_CommandFlush,omx_rend_input_port)) {
-                       Log::getInstance()->log("Video", Log::DEBUG, "flush cmd shed rend failed");
+               error = OMX_SendCommand(omx_vid_sched, OMX_CommandFlush,
+                               omx_shed_input_port, NULL);
+               if (error != OMX_ErrorNone) {
+                       Log::getInstance()->log("Video", Log::DEBUG,
+                                       "OMX_Flush shed in failed %x", error);
+
                }
 
-               error=OMX_SendCommand(omx_vid_dec,OMX_CommandFlush, omx_codec_input_port, NULL);
-               if (error!=OMX_ErrorNone){
-                       Log::getInstance()->log("Video", Log::DEBUG, "OMX_Flush codec out failed %x", error);
+               if (!CommandFinished(omx_vid_dec, OMX_CommandFlush,
+                               omx_codec_output_port)) {
+                       Log::getInstance()->log("Video", Log::DEBUG,
+                                       "flush cmd codec  failed");
+               }
 
+               if (!CommandFinished(omx_vid_sched, OMX_CommandFlush,
+                               omx_shed_input_port)) {
+                       Log::getInstance()->log("Video", Log::DEBUG,
+                                       "flush cmd  shed failed");
                }
 
 
 
-               error=OMX_SendCommand(omx_vid_sched,OMX_CommandFlush, omx_shed_input_port, NULL);
-               if (error!=OMX_ErrorNone){
-                       Log::getInstance()->log("Video", Log::DEBUG, "OMX_Flush shed in failed %x", error);
+
+               error = OMX_SendCommand(omx_vid_rend, OMX_CommandFlush,
+                               omx_rend_input_port, NULL);
+               if (error != OMX_ErrorNone) {
+                       Log::getInstance()->log("Video", Log::DEBUG,
+                                       "OMX_Flush rend in failed %x", error);
 
                }
 
-               if (!CommandFinished(omx_vid_dec,OMX_CommandFlush,omx_codec_output_port) ||
-                               !CommandFinished(omx_vid_sched,OMX_CommandFlush,omx_shed_input_port)) {
-                       Log::getInstance()->log("Video", Log::DEBUG, "flush cmd codec shed failed");
+               error = OMX_SendCommand(omx_vid_sched, OMX_CommandFlush,
+                               omx_shed_output_port, NULL);
+               if (error != OMX_ErrorNone) {
+                       Log::getInstance()->log("Video", Log::DEBUG,
+                                       "OMX_Flush shed out failed %x", error);
+
                }
 
 
+
+               if (!CommandFinished(omx_vid_rend, OMX_CommandFlush,
+                               omx_rend_input_port)) {
+                       Log::getInstance()->log("Video", Log::DEBUG,
+                                       "flush cmd shed rend failed");
+               }
+
+               if (!CommandFinished(omx_vid_sched, OMX_CommandFlush,
+                               omx_shed_output_port)) {
+                       Log::getInstance()->log("Video", Log::DEBUG,
+                                       "flush cmd shed rend failed");
+               }
+
+
+
+
+
                error=OMX_SendCommand(omx_clock,OMX_CommandFlush, omx_clock_output_port, NULL);
                if (error!=OMX_ErrorNone){
                        Log::getInstance()->log("Video", Log::DEBUG, "OMX_Flush clock out failed %x", error);
@@ -1279,23 +1315,20 @@ int VideoOMX::DeAllocateCodecsOMX()
                                Log::getInstance()->log("Video", Log::DEBUG, "flush cmd clock shed failed");
                }
 
-               error=OMX_SendCommand(omx_vid_sched,OMX_CommandFlush, omx_shed_output_port, NULL);
-               if (error!=OMX_ErrorNone) {
-                       Log::getInstance()->log("Video", Log::DEBUG, "OMX_Flush shed out failed %x", error);
 
-               }
 
 
+               error = OMX_SendCommand(omx_vid_dec, OMX_CommandFlush,
+                               omx_codec_input_port, NULL);
+               if (error != OMX_ErrorNone) {
+                       Log::getInstance()->log("Video", Log::DEBUG,
+                                       "OMX_Flush codec out failed %x", error);
 
-               if (!CommandFinished(omx_vid_sched,OMX_CommandFlush,omx_shed_output_port) ) {
-                       Log::getInstance()->log("Video", Log::DEBUG, "flush cmd shed rend failed");
                }
 
 
 
 
-
-
                DestroyInputBufsOMX();
 
                //todo flushing