--- gstreamer-ti-0+svnr225-r0/gstreamer_ti/ti_build/ticodecplugin/src/gsttiauddec1.c	2009-06-15 22:27:27.000000000 +0300
+++ gstreamer-ti-0+svnr225-r0/gstreamer_ti/ti_build/ticodecplugin/src/gsttiauddec1_mine.c	2009-07-06 16:13:23.000000000 +0300
@@ -1059,6 +1059,9 @@
             if (!gst_tiauddec1_exit_audio(auddec1)) {
                 return GST_STATE_CHANGE_FAILURE;
             }
+            if (gst_tiauddec1_codec_stop(auddec1) < 0) {
+                GST_ERROR("failed to stop codec\n");
+            }
             break;
 
         case GST_STATE_CHANGE_READY_TO_PAUSED:
@@ -1362,11 +1365,6 @@
         gst_ticircbuffer_data_consumed(auddec1->circBuf, encDataWindow, 0);
     }
 
-    /* Initialize codec engine */
-    if (gst_tiauddec1_codec_stop(auddec1) < 0) {
-        GST_ERROR("failed to stop codec\n");
-    }
-
     /* Notify main thread if it is waiting on decode thread shut-down */
     auddec1->decodeDrained = TRUE;
     Rendezvous_force(auddec1->waitOnDecodeDrain);
--- gstreamer-ti-0+svnr225-r0/gstreamer_ti/ti_build/ticodecplugin/src/gsttiauddec.c	2009-06-15 22:27:27.000000000 +0300
+++ gstreamer-ti-0+svnr225-r0/gstreamer_ti/ti_build/ticodecplugin/src/gsttiauddec_mine.c	2009-07-06 16:15:26.000000000 +0300
@@ -1054,6 +1054,10 @@
             if (!gst_tiauddec_exit_audio(auddec)) {
                 return GST_STATE_CHANGE_FAILURE;
             }
+            /* Stop codec engine */
+            if (gst_tiauddec_codec_stop(auddec) < 0) {
+                GST_ERROR("failed to stop codec\n");
+            }
             break;
 
         case GST_STATE_CHANGE_READY_TO_PAUSED:
@@ -1360,12 +1364,6 @@
         gst_ticircbuffer_data_consumed(auddec->circBuf, encDataWindow, 0);
     }
 
-     /* Initialize codec engine */
-    /* Stop codec engine */
-    if (gst_tiauddec_codec_stop(auddec) < 0) {
-        GST_ERROR("failed to stop codec\n");
-    }
-
     /* Notify main thread if it is waiting on decode thread shut-down */
     auddec->decodeDrained = TRUE;
     Rendezvous_force(auddec->waitOnDecodeDrain);
--- gstreamer-ti-0+svnr225-r0/gstreamer_ti/ti_build/ticodecplugin/src/gsttiimgdec1.c	2009-06-15 22:27:27.000000000 +0300
+++ gstreamer-ti-0+svnr225-r0/gstreamer_ti/ti_build/ticodecplugin/src/gsttiimgdec1_mine.c	2009-07-06 16:17:11.000000000 +0300
@@ -1216,6 +1216,10 @@
             if (!gst_tiimgdec1_exit_image(imgdec1)) {
                 return GST_STATE_CHANGE_FAILURE;
             }
+            /* Stop codec engine */
+            if (gst_tiimgdec1_codec_stop(imgdec1) < 0) {
+                GST_ERROR("failed to stop codec\n");
+            }
             break;
 
         default:
@@ -1539,11 +1543,6 @@
         gst_ticircbuffer_data_consumed(imgdec1->circBuf, encDataWindow, 0);
     }
 
-    /* Stop codec engine */
-    if (gst_tiimgdec1_codec_stop(imgdec1) < 0) {
-        GST_ERROR("failed to stop codec\n");
-    }
-
     imgdec1->decodeDrained = TRUE;
     Rendezvous_force(imgdec1->waitOnDecodeDrain);
 
--- gstreamer-ti-0+svnr225-r0/gstreamer_ti/ti_build/ticodecplugin/src/gsttiimgdec.c	2009-06-15 22:27:27.000000000 +0300
+++ gstreamer-ti-0+svnr225-r0/gstreamer_ti/ti_build/ticodecplugin/src/gsttiimgdec_mine.c	2009-07-06 16:20:09.000000000 +0300
@@ -1216,6 +1216,10 @@
             if (!gst_tiimgdec_exit_image(imgdec)) {
                 return GST_STATE_CHANGE_FAILURE;
             }
+            /* Stop codec engine */
+            if (gst_tiimgdec_codec_stop(imgdec) < 0) {
+                GST_ERROR("failed to stop codec\n");
+            }
             break;
 
         default:
@@ -1538,11 +1542,6 @@
         gst_ticircbuffer_data_consumed(imgdec->circBuf, encDataWindow, 0);
     }
 
-    /* Stop codec engine */
-    if (gst_tiimgdec_codec_stop(imgdec) < 0) {
-        GST_ERROR("failed to stop codec\n");
-    }
-
     imgdec->decodeDrained = TRUE;
     Rendezvous_force(imgdec->waitOnDecodeDrain);
 
--- gstreamer-ti-0+svnr225-r0/gstreamer_ti/ti_build/ticodecplugin/src/gsttiimgenc1.c	2009-06-15 22:27:26.000000000 +0300
+++ gstreamer-ti-0+svnr225-r0/gstreamer_ti/ti_build/ticodecplugin/src/gsttiimgenc1_mine.c	2009-07-06 16:21:36.000000000 +0300
@@ -1519,6 +1519,10 @@
             if (!gst_tiimgenc1_exit_image(imgenc1)) {
                 return GST_STATE_CHANGE_FAILURE;
             }
+            /* Stop codec engine */
+            if (gst_tiimgenc1_codec_stop(imgenc1) < 0) {
+                GST_ERROR("failed to stop codec\n");
+            }
             break;
 
         default:
@@ -1848,11 +1852,6 @@
         gst_ticircbuffer_data_consumed(imgenc1->circBuf, encDataWindow, 0);
     }
 
-    /* Stop codec engine */
-    if (gst_tiimgenc1_codec_stop(imgenc1) < 0) {
-        GST_ERROR("failed to stop codec\n");
-    }
-
     imgenc1->encodeDrained = TRUE;
     Rendezvous_force(imgenc1->waitOnEncodeDrain);
 
--- gstreamer-ti-0+svnr225-r0/gstreamer_ti/ti_build/ticodecplugin/src/gsttiimgenc.c	2009-06-15 22:27:27.000000000 +0300
+++ gstreamer-ti-0+svnr225-r0/gstreamer_ti/ti_build/ticodecplugin/src/gsttiimgenc_mine.c	2009-07-06 16:22:59.000000000 +0300
@@ -1518,6 +1518,10 @@
             if (!gst_tiimgenc_exit_image(imgenc)) {
                 return GST_STATE_CHANGE_FAILURE;
             }
+            /* Stop codec engine */
+            if (gst_tiimgenc_codec_stop(imgenc) < 0) {
+                GST_ERROR("failed to stop codec\n");
+            }
             break;
 
         default:
@@ -1847,11 +1851,6 @@
         gst_ticircbuffer_data_consumed(imgenc->circBuf, encDataWindow, 0);
     }
 
-    /* Stop codec engine */
-    if (gst_tiimgenc_codec_stop(imgenc) < 0) {
-        GST_ERROR("failed to stop codec\n");
-    }
-
     imgenc->encodeDrained = TRUE;
     Rendezvous_force(imgenc->waitOnEncodeDrain);
 
--- gstreamer-ti-0+svnr225-r0/gstreamer_ti/ti_build/ticodecplugin/src/gsttividdec2.c	2009-06-15 22:27:27.000000000 +0300
+++ gstreamer-ti-0+svnr225-r0/gstreamer_ti/ti_build/ticodecplugin/src/gsttividdec2_mine.c	2009-07-06 16:24:54.000000000 +0300
@@ -1112,6 +1112,10 @@
             if (!gst_tividdec2_exit_video(viddec2)) {
                 return GST_STATE_CHANGE_FAILURE;
             }
+            /* stop codec engine */
+            if (gst_tividdec2_codec_stop(viddec2) < 0) {
+                GST_ERROR("failed to stop codec\n");
+            }
             break;
 
         case GST_STATE_CHANGE_READY_TO_PAUSED:
@@ -1496,11 +1500,6 @@
         gst_ticircbuffer_data_consumed(viddec2->circBuf, encDataWindow, 0);
     }
 
-    /* stop codec engine */
-    if (gst_tividdec2_codec_stop(viddec2) < 0) {
-        GST_ERROR("failed to stop codec\n");
-    }
-
     /* Notify main thread if it is waiting on decode thread shut-down */
     viddec2->decodeDrained = TRUE;
     Rendezvous_force(viddec2->waitOnDecodeDrain);
--- gstreamer-ti-0+svnr225-r0/gstreamer_ti/ti_build/ticodecplugin/src/gsttividdec.c	2009-06-15 22:27:27.000000000 +0300
+++ gstreamer-ti-0+svnr225-r0/gstreamer_ti/ti_build/ticodecplugin/src/gsttividdec_mine.c	2009-07-06 16:27:06.000000000 +0300
@@ -1102,6 +1102,10 @@
             if (!gst_tividdec_exit_video(viddec)) {
                 return GST_STATE_CHANGE_FAILURE;
             }
+            /* stop codec engine */
+            if (gst_tividdec_codec_stop(viddec) < 0) {
+                GST_ERROR("failed to stop codec\n");
+            }
             break;
 
         case GST_STATE_CHANGE_READY_TO_PAUSED:
@@ -1437,11 +1441,6 @@
         gst_ticircbuffer_data_consumed(viddec->circBuf, encDataWindow, 0);
     }
 
-    /* stop codec engine */
-    if (gst_tividdec_codec_stop(viddec) < 0) {
-        GST_ERROR("failed to stop codec\n");
-    }
-
     /* Notify main thread if it is waiting on decode thread shut-down */
     viddec->decodeDrained = TRUE;
     Rendezvous_force(viddec->waitOnDecodeDrain);
--- gstreamer-ti-0+svnr225-r0/gstreamer_ti/ti_build/ticodecplugin/src/gsttividenc1.c	2009-06-15 22:27:27.000000000 +0300
+++ gstreamer-ti-0+svnr225-r0/gstreamer_ti/ti_build/ticodecplugin/src/gsttividenc1_mine.c	2009-07-06 16:28:25.000000000 +0300
@@ -1077,6 +1077,10 @@
             if (!gst_tividenc1_exit_video(videnc1)) {
                 return GST_STATE_CHANGE_FAILURE;
             }
+            /* Stop codec engine */
+            if (gst_tividenc1_codec_stop(videnc1) < 0) {
+                GST_ERROR("failed to stop codec\n");
+            }
             break;
 
         default:
@@ -1532,11 +1536,6 @@
         Ccv_delete(hCcv);
     }
 
-    /* Stop codec engine */
-    if (gst_tividenc1_codec_stop(videnc1) < 0) {
-        GST_ERROR("failed to stop codec\n");
-    }
-
     videnc1->encodeDrained = TRUE;
     Rendezvous_force(videnc1->waitOnEncodeDrain);
     Rendezvous_force(videnc1->waitOnQueueThread);
--- gstreamer-ti-0+svnr225-r0/gstreamer_ti/ti_build/ticodecplugin/src/gsttividenc.c	2009-06-15 22:27:27.000000000 +0300
+++ gstreamer-ti-0+svnr225-r0/gstreamer_ti/ti_build/ticodecplugin/src/gsttividenc_mine.c	2009-07-06 16:29:48.000000000 +0300
@@ -1022,6 +1022,10 @@
             if (!gst_tividenc_exit_video(videnc)) {
                 return GST_STATE_CHANGE_FAILURE;
             }
+            /* Stop codec engine */
+            if (gst_tividenc_codec_stop(videnc) < 0) {
+                GST_ERROR("failed to stop codec\n");
+            }
             break;
 
         default:
@@ -1376,11 +1380,6 @@
         gst_ticircbuffer_data_consumed(videnc->circBuf, encDataWindow, 0);
     }
 
-    /* Stop codec engine */
-    if (gst_tividenc_codec_stop(videnc) < 0) {
-        GST_ERROR("failed to stop codec\n");
-    }
-
     /* Notify main thread if it is waiting on decode thread shut-down */
     videnc->encodeDrained = TRUE;
     Rendezvous_force(videnc->waitOnQueueThread);
