Refine code for seek fix
authorZhao Halley <halley.zhao@intel.com>
Sat, 20 Apr 2013 07:54:16 +0000 (15:54 +0800)
committerZhao Halley <halley.zhao@intel.com>
Mon, 22 Apr 2013 07:51:40 +0000 (15:51 +0800)
1. There are 'try_again' in two level
   The 1st one is (condition wait) wake up when a surface is available,
     in gstvaapidecode.c
   The 2nd one is (potentially) 'try_again' for the first time decode_step()
     when asking for a decoded video surface (gst_vaapi_decoder_get_surface).
     in gstvaapidecoder.c
2. The 1st one pass 'try_again' to the second one, not reverse. So:
   The 1st one needn't pass address of 'try_again' to the 2nd one.
   The 2nd one needn't check GST_VAAPI_DECODER_STATUS_ERROR_NO_SURFACE to
     set 'try_again'. it's the 1st's role and responsibility.

gst-libs/gst/vaapi/gstvaapidecoder.c [changed mode: 0644->0755]
gst-libs/gst/vaapi/gstvaapidecoder.h [changed mode: 0644->0755]
gst/vaapi/gstvaapidecode.c
tests/test-decode.c [changed mode: 0644->0755]
tests/test-subpicture.c [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index dad1e4b..489ae2f
@@ -115,9 +115,6 @@ decode_step(GstVaapiDecoder *decoder, gboolean *try_again)
 
         status = GST_VAAPI_DECODER_GET_CLASS(decoder)->decode(decoder, buffer);
         GST_DEBUG("decode frame (status = %d)", status);
-        if (status == GST_VAAPI_DECODER_STATUS_ERROR_NO_SURFACE) {
-            *try_again = TRUE;
-        }
         if (status != GST_VAAPI_DECODER_STATUS_SUCCESS && GST_BUFFER_IS_EOS(buffer))
             status = GST_VAAPI_DECODER_STATUS_END_OF_STREAM;
         gst_buffer_unref(buffer);
@@ -437,7 +434,7 @@ GstVaapiSurfaceProxy *
 gst_vaapi_decoder_get_surface(
     GstVaapiDecoder       *decoder,
     GstVaapiDecoderStatus *pstatus,
-    gboolean              *try_again
+    gboolean              try_again
 )
 {
     GstVaapiSurfaceProxy *proxy;
@@ -451,7 +448,7 @@ gst_vaapi_decoder_get_surface(
     proxy = pop_surface(decoder);
     if (!proxy) {
         do {
-            status = decode_step(decoder, try_again);
+            status = decode_step(decoder, &try_again);
         } while (status == GST_VAAPI_DECODER_STATUS_SUCCESS);
         proxy = pop_surface(decoder);
     }
old mode 100644 (file)
new mode 100755 (executable)
index d935b1d..0ebb92b
@@ -130,7 +130,7 @@ GstVaapiSurfaceProxy *
 gst_vaapi_decoder_get_surface(
     GstVaapiDecoder       *decoder,
     GstVaapiDecoderStatus *pstatus,
-    gboolean              *try_again
+    gboolean              try_again
 );
 
 void
index e07867b..0f00a53 100755 (executable)
@@ -206,7 +206,7 @@ gst_vaapidecode_step(GstVaapiDecode *decode)
     gboolean try_again = FALSE;
 
     for (;;) {
-        proxy = gst_vaapi_decoder_get_surface(decode->decoder, &status, &try_again);
+        proxy = gst_vaapi_decoder_get_surface(decode->decoder, &status, try_again);
         try_again = FALSE;
         if (!proxy) {
             if (status == GST_VAAPI_DECODER_STATUS_ERROR_NO_SURFACE) {
old mode 100644 (file)
new mode 100755 (executable)
index f3cab9d..e173aaa
@@ -181,8 +181,7 @@ main(int argc, char *argv[])
     if (!gst_vaapi_decoder_put_buffer(decoder, NULL))
         g_error("could not send EOS to the decoder");
 
-    gboolean try_again = FALSE;
-    proxy = gst_vaapi_decoder_get_surface(decoder, &status, &try_again);
+    proxy = gst_vaapi_decoder_get_surface(decoder, &status, FALSE);
     if (!proxy)
         g_error("could not get decoded surface (decoder status %d)", status);
 
old mode 100644 (file)
new mode 100755 (executable)
index 89643d7..b9eae9a
@@ -157,8 +157,7 @@ main(int argc, char *argv[])
     if (!gst_vaapi_decoder_put_buffer(decoder, NULL))
         g_error("could not send EOS to the decoder");
 
-    gboolean try_again = FALSE;
-    proxy = gst_vaapi_decoder_get_surface(decoder, &status, &try_again);
+    proxy = gst_vaapi_decoder_get_surface(decoder, &status, FALSE);
     if (!proxy)
         g_error("could not get decoded surface (decoder status %d)", status);