]> git.sesse.net Git - vlc/blobdiff - src/misc/messages.c
* - This should fix the "crash upon quit" issue with VLC Mac OS X.
[vlc] / src / misc / messages.c
index 3e32998ebfbba31253566b92d491906105f7898f..b86e6a7a68ff33d73e047c38ab380cbe1f7184e9 100644 (file)
@@ -3,7 +3,7 @@
  * This library provides an interface to the message queue to be used by other
  * modules, especially intf modules. See config.h for output configuration.
  *****************************************************************************
- * Copyright (C) 1998-2004 VideoLAN
+ * Copyright (C) 1998-2005 the VideoLAN team
  * $Id$
  *
  * Authors: Vincent Seguin <seguin@via.ecp.fr>
@@ -38,9 +38,7 @@
 #   include <fcntl.h>                  /* O_CREAT, O_TRUNC, O_WRONLY, O_SYNC */
 #endif
 
-#ifdef HAVE_ERRNO_H
-#   include <errno.h>                                               /* errno */
-#endif
+#include <errno.h>                                                  /* errno */
 
 #ifdef HAVE_UNISTD_H
 #   include <unistd.h>                                   /* close(), write() */
@@ -101,18 +99,19 @@ void __msg_Create( vlc_object_t *p_this )
  */
 void __msg_Flush( vlc_object_t *p_this )
 {
-    int i_index;
-
     vlc_mutex_lock( &p_this->p_libvlc->msg_bank.lock );
 
     p_this->p_libvlc->msg_bank.b_configured = VLC_TRUE;
 
+#if 0
+    /* Some messages remain in the queue, dont rewrite them */
     for( i_index = p_this->p_libvlc->msg_bank.i_start;
          i_index != p_this->p_libvlc->msg_bank.i_stop;
          i_index = (i_index+1) % VLC_MSG_QSIZE )
     {
         PrintMsg( p_this, &p_this->p_libvlc->msg_bank.msg[i_index] );
     }
+#endif
 
     FlushMsg( &p_this->p_libvlc->msg_bank );
 
@@ -211,6 +210,7 @@ void __msg_Unsubscribe( vlc_object_t *p_this, msg_subscription_t *p_sub )
     /* Remove this subscription */
     REMOVE_ELEM( p_bank->pp_sub, p_bank->i_sub, i_index );
 
+    if( p_sub ) free( p_sub );
     vlc_mutex_unlock( &p_bank->lock );
 }
 
@@ -299,12 +299,8 @@ static void QueueMsg( vlc_object_t *p_this, int i_type, const char *psz_module,
 
     if( psz_str == NULL )
     {
-#ifdef HAVE_ERRNO_H
         fprintf( stderr, "main warning: can't store message (%s): ",
                  strerror(errno) );
-#else
-        fprintf( stderr, "main warning: can't store message: " );
-#endif
         vlc_va_copy( args, _args );
         vfprintf( stderr, psz_format, args );
         va_end( args );
@@ -381,8 +377,10 @@ static void QueueMsg( vlc_object_t *p_this, int i_type, const char *psz_module,
 
     if( p_bank->b_overflow )
     {
-        free( p_item->psz_module );
-        free( p_item->psz_msg );
+        if( p_item->psz_module )
+            free( p_item->psz_module );
+        if( p_item->psz_msg )
+            free( p_item->psz_msg );
     }
 
     vlc_mutex_unlock( &p_bank->lock );
@@ -430,8 +428,10 @@ static void FlushMsg ( msg_bank_t *p_bank )
          i_index != i_stop;
          i_index = (i_index+1) % VLC_MSG_QSIZE )
     {
-        free( p_bank->msg[i_index].psz_msg );
-        free( p_bank->msg[i_index].psz_module );
+        if( p_bank->msg[i_index].psz_msg )
+            free( p_bank->msg[i_index].psz_msg );
+        if( p_bank->msg[i_index].psz_module )
+            free( p_bank->msg[i_index].psz_module );
     }
 
     /* Update the new start value */
@@ -496,6 +496,7 @@ static void PrintMsg ( vlc_object_t * p_this, msg_item_t * p_item )
         case VLC_OBJECT_VLM: psz_object = "vlm"; break;
         case VLC_OBJECT_ANNOUNCE: psz_object = "announce handler"; break;
         case VLC_OBJECT_DEMUX: psz_object = "demuxer"; break;
+        case VLC_OBJECT_ACCESS: psz_object = "access"; break;
     }
 
 #ifdef UNDER_CE