]> git.sesse.net Git - vlc/commitdiff
libavutil callback cannot assume it has a VLC object
authorRémi Denis-Courmont <remi@remlab.net>
Thu, 12 Mar 2009 14:49:37 +0000 (16:49 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Thu, 12 Mar 2009 14:57:10 +0000 (16:57 +0200)
This fixes a crash from the avformat (de)mux.

modules/codec/avcodec/avutil.h

index 08b11567d89ddfb5b248e204e030c1b3898a7f95..48a5222b26eda3891569f84326f5cdc0a01623c3 100644 (file)
 static inline void LibavutilCallback( void *p_opaque, int i_level,
                         const char *psz_format, va_list va )
 {
-    int i_vlc_level;
     AVCodecContext *p_avctx = (AVCodecContext *)p_opaque;
     const AVClass *p_avc;
-    vlc_object_t *p_this;
-    char *psz_new_format;
-    const char *psz_item_name;
 
     p_avc = p_avctx ? p_avctx->av_class : 0;
 
@@ -48,33 +44,17 @@ static inline void LibavutilCallback( void *p_opaque, int i_level,
     }
 #undef cln
 
-    p_this = (vlc_object_t *)p_avctx->opaque;
-
     switch( i_level )
     {
-    case AV_LOG_QUIET:
-        i_vlc_level = VLC_MSG_ERR;
-        break;
-    case AV_LOG_ERROR:
-        i_vlc_level = VLC_MSG_WARN;
-        break;
-    case AV_LOG_INFO:
-        i_vlc_level = VLC_MSG_DBG;
-        break;
     case AV_LOG_DEBUG:
+    case AV_LOG_INFO:
         /* Print debug messages if they were requested */
-        if( p_avctx->debug ) vfprintf( stderr, psz_format, va );
-        return;
-    default:
-        return;
-    }
+        if( !p_avctx->debug )
+            break;
 
-    psz_item_name = p_avc->item_name(p_opaque);
-    psz_new_format = malloc( strlen(psz_format) + strlen(psz_item_name)
-                              + 18 + 5 );
-    snprintf( psz_new_format, strlen(psz_format) + strlen(psz_item_name)
-              + 18 + 5, "%s (%s@%p)", psz_format, p_avc->item_name(p_opaque), p_opaque );
-    msg_GenericVa( p_this, i_vlc_level,
-                    MODULE_STRING, psz_new_format, va );
-    free( psz_new_format );
+    case AV_LOG_ERROR:
+    case AV_LOG_QUIET:
+        vfprintf( stderr, psz_format, va );
+        break;
+    }
 }