fixup: qsvvpp: Make check for initialization failures

Message ID 20180902112311.3272-1-lu_zero@gentoo.org
State New
Headers show
Series
  • fixup: qsvvpp: Make check for initialization failures
Related show

Commit Message

Luca Barbato Sept. 2, 2018, 11:23 a.m.
---

I'd squash this on top of this patch and push it in a bit.

 libavutil/hwcontext_qsv.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

--
2.13.3

Patch

diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index 36a30c5c35..0cfcc01fe8 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -760,21 +760,21 @@  static int qsv_transfer_data_from(AVHWFramesContext *ctx, AVFrame *dst,

     mfxSyncPoint sync = NULL;
     mfxStatus err;
+    int ret = 0;

-    while (!s->session_download_init && !s->session_download) {
+    while (!s->session_download_init && !s->session_download && !ret) {
 #if HAVE_PTHREADS
 	if (pthread_mutex_trylock(&s->session_lock) == 0) {
 #endif
             if (!s->session_download_init) {
-                qsv_init_internal_session(ctx, &s->session_download, 0);
+                ret = qsv_init_internal_session(ctx, &s->session_download, 0);
                 if (s->session_download)
                     s->session_download_init = 1;
             }
 #if HAVE_PTHREADS
             pthread_mutex_unlock(&s->session_lock);
             pthread_cond_signal(&s->session_cond);
-        }
-	else {
+        } else {
             pthread_mutex_lock(&s->session_lock);
             while (!s->session_download_init && !s->session_download) {
                 pthread_cond_wait(&s->session_cond, &s->session_lock);
@@ -784,6 +784,9 @@  static int qsv_transfer_data_from(AVHWFramesContext *ctx, AVFrame *dst,
 #endif
     }

+    if (ret < 0)
+        return ret;
+
     if (!s->session_download) {
         if (s->child_frames_ref)
             return qsv_transfer_data_child(ctx, dst, src);
@@ -830,21 +833,21 @@  static int qsv_transfer_data_to(AVHWFramesContext *ctx, AVFrame *dst,

     mfxSyncPoint sync = NULL;
     mfxStatus err;
+    int ret;

-    while (!s->session_upload_init && !s->session_upload) {
+    while (!s->session_upload_init && !s->session_upload && !ret) {
 #if HAVE_PTHREADS
 	if (pthread_mutex_trylock(&s->session_lock) == 0) {
 #endif
             if (!s->session_upload_init) {
-                qsv_init_internal_session(ctx, &s->session_upload, 1);
+                ret = qsv_init_internal_session(ctx, &s->session_upload, 1);
                 if (s->session_upload)
                     s->session_upload_init = 1;
             }
 #if HAVE_PTHREADS
             pthread_mutex_unlock(&s->session_lock);
             pthread_cond_signal(&s->session_cond);
-        }
-	else {
+        } else {
             pthread_mutex_lock(&s->session_lock);
             while (!s->session_upload_init && !s->session_upload) {
                 pthread_cond_wait(&s->session_cond, &s->session_lock);
@@ -853,6 +856,8 @@  static int qsv_transfer_data_to(AVHWFramesContext *ctx, AVFrame *dst,
         }
 #endif
     }
+    if (ret < 0)
+        return ret;

     if (!s->session_upload) {
         if (s->child_frames_ref)