]> git.sesse.net Git - vlc/commitdiff
* fixed stupid bug in stupid ConvertPrintfFormatString() function
authorGildas Bazin <gbazin@videolan.org>
Wed, 20 Mar 2002 23:00:16 +0000 (23:00 +0000)
committerGildas Bazin <gbazin@videolan.org>
Wed, 20 Mar 2002 23:00:16 +0000 (23:00 +0000)
* fixed the "waveout not closing" bug. We need to reset the waveout device
    before closing it.

BUGS
plugins/win32/waveout.c
src/interface/intf_msg.c

diff --git a/BUGS b/BUGS
index 6f8af78c43d02c636f2e5c2474e4bdb12d262c7b..fe82cd21205bdd622c977b632c6f3391bef7f924 100644 (file)
--- a/BUGS
+++ b/BUGS
@@ -1,4 +1,4 @@
-List of known vlc bugs $Id: BUGS,v 1.8 2002/03/20 03:12:20 ipkiss Exp $
+List of known vlc bugs $Id: BUGS,v 1.9 2002/03/20 23:00:16 gbazin Exp $
 
    Please try to keep this file up to date. Also, grep for FIXME in the
 source files for more and more bugs to fix.
@@ -30,8 +30,6 @@ Audio output:
   * Audio output stutters on some audio cards. For instance kwyxz's SB
   128 with an es1371 chip.
 
-  * WaveOut doesn't close correctly under Windows 98.
-
 
 Video output:
 
index 87133da889e4f8e51f3b8cdfb828e4afe85de8ae..4f75097a48e70a8c078be4494b7739513e24f274 100644 (file)
@@ -2,7 +2,7 @@
  * waveout.c : Windows waveOut plugin for vlc
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: waveout.c,v 1.5 2002/03/19 12:48:01 gbazin Exp $
+ * $Id: waveout.c,v 1.6 2002/03/20 23:00:16 gbazin Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *      
@@ -155,6 +155,9 @@ static int aout_SetFormat( aout_thread_t *p_aout )
     if( (p_aout->p_sys->waveformat.nChannels != p_aout->i_channels) ||
         (p_aout->p_sys->waveformat.nSamplesPerSec != p_aout->i_rate) )
     {
+        /* Before calling waveOutClose we must reset the device */
+        waveOutReset( p_aout->p_sys->h_waveout );
+
         if( waveOutClose( p_aout->p_sys->h_waveout ) != MMSYSERR_NOERROR )
         {
             intf_ErrMsg( "aout error: waveOutClose failed" );
@@ -251,6 +254,9 @@ static void aout_Close( aout_thread_t *p_aout )
 
     intf_WarnMsg( 3, "aout: waveOut aout_Close ");
 
+    /* Before calling waveOutClose we must reset the device */
+    waveOutReset( p_aout->p_sys->h_waveout );
+
     /* Close the device */
     if( waveOutClose( p_aout->p_sys->h_waveout ) != MMSYSERR_NOERROR )
     {
index 7eeb72b2c001616b63ebb82fc192bc9c4d2fa685..7be9155daaf3d26445d903a4c9a1fb7cbd00117e 100644 (file)
@@ -4,7 +4,7 @@
  * interface, such as message output. See config.h for output configuration.
  *****************************************************************************
  * Copyright (C) 1998-2001 VideoLAN
- * $Id: intf_msg.c,v 1.46 2002/02/23 21:31:44 gbazin Exp $
+ * $Id: intf_msg.c,v 1.47 2002/03/20 23:00:15 gbazin Exp $
  *
  * Authors: Vincent Seguin <seguin@via.ecp.fr>
  *
@@ -325,6 +325,11 @@ static void QueueMsg( int i_type, int i_level, char *psz_format, va_list ap )
 #ifndef HAVE_VASPRINTF
 #   ifdef WIN32
     psz_temp = ConvertPrintfFormatString(psz_format);
+    if( !psz_temp )
+    {
+        fprintf(stderr, "intf warning: couldn't print message");
+        return;
+    }
     vsprintf( psz_str, psz_temp, ap );
     free( psz_temp );
 #   else
@@ -409,7 +414,7 @@ static void FlushMsg ( void )
  * ConvertPrintfFormatString: replace all occurrences of %ll with %I64 in the
  *                            printf format string.
  *****************************************************************************
- * Win32 doesn't recognize the "%lld" format in a printf string, so we have
+ * Win32 doesn't recognize the "%ll" format in a printf string, so we have
  * to convert this string to something that win32 can handle.
  * This is a REALLY UGLY HACK which won't even work in every situation,
  * but hey I don't want to put an ifdef WIN32 each time I use printf with
@@ -426,7 +431,10 @@ static char *ConvertPrintfFormatString( char *psz_format )
    * psz_format string. Once we'll know that we'll be able to malloc the
    * destination string */
 
-  for( i=0; i <= (strlen(psz_format) - 4); i++ )
+  if( strlen( psz_format ) <= 3 )
+      return strdup( psz_format );
+
+  for( i=0; i <= (strlen(psz_format) - 3); i++ )
   {
       if( !strncmp( (char *)(psz_format + i), "%ll", 3 ) )
       {
@@ -439,12 +447,12 @@ static char *ConvertPrintfFormatString( char *psz_format )
   if( psz_dest == NULL )
   {
       fprintf( stderr, "intf warning: ConvertPrintfFormatString failed\n");
-      exit (errno);
+      return NULL;
   }
 
   /* Now build the modified string */
   i_counter = 0;
-  for( i=0; i <= (strlen(psz_format) - 4); i++ )
+  for( i=0; i <= (strlen(psz_format) - 3); i++ )
   {
       if( !strncmp( (char *)(psz_format + i), "%ll", 3 ) )
       {