Commit 5b49dba8 authored by Gildas Bazin's avatar Gildas Bazin

Win32 changes only:

 - defined off_t as a long long. This allows DVD navigation to work.
   This change is to be implemented on a compiler by compiler basis. For
   now, it works on mingw32 (tested) and should work on MSVC (not tested).

 - Implemented a quick and dirty hack in intf_msg.c to be able to display
   long long integers with printf on Win32. This change is also necessary
   to avoid segfaults when debug is enabled in vlc on Win32.

 - few minor changes in the directx plugins.

 - defined snprintf in common.h and removed a few #ifdef WIN32
parent 52add4b0
...@@ -195,7 +195,7 @@ CFLAGS += -traditional-cpp ...@@ -195,7 +195,7 @@ CFLAGS += -traditional-cpp
endif endif
ifneq (,$(findstring mingw32,$(SYS))) ifneq (,$(findstring mingw32,$(SYS)))
CFLAGS += -fnative-struct CFLAGS += -fnative-struct -D_OFF_T_ -D_off_t=long
endif endif
# Optimizations : don't compile debug versions with them # Optimizations : don't compile debug versions with them
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* Collection of useful common types and macros definitions * Collection of useful common types and macros definitions
***************************************************************************** *****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN * Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: common.h,v 1.35 2001/06/03 12:47:21 sam Exp $ * $Id: common.h,v 1.36 2001/07/08 17:45:51 gbazin Exp $
* *
* Authors: Samuel Hocevar <sam@via.ecp.fr> * Authors: Samuel Hocevar <sam@via.ecp.fr>
* Vincent Seguin <seguin@via.ecp.fr> * Vincent Seguin <seguin@via.ecp.fr>
...@@ -193,7 +193,6 @@ struct pgrm_descriptor_s; ...@@ -193,7 +193,6 @@ struct pgrm_descriptor_s;
/* win32, cl and icl support */ /* win32, cl and icl support */
#if defined( _MSC_VER ) #if defined( _MSC_VER )
typedef long off_t;
# define __attribute__(x) # define __attribute__(x)
# define __inline__ __inline # define __inline__ __inline
# define strncasecmp strnicmp # define strncasecmp strnicmp
...@@ -207,3 +206,14 @@ typedef long off_t; ...@@ -207,3 +206,14 @@ typedef long off_t;
# define I64C(x) x##LL # define I64C(x) x##LL
#endif #endif
#if defined( WIN32 )
typedef __int64 off_t;
#ifndef snprintf
#define snprintf _snprintf /* snprintf not defined in mingw32 (bug?) */
#endif
#endif
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* aout_directx.c: Windows DirectX audio output method * aout_directx.c: Windows DirectX audio output method
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: aout_directx.c,v 1.3 2001/06/14 01:49:44 sam Exp $ * $Id: aout_directx.c,v 1.4 2001/07/08 17:45:52 gbazin Exp $
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -97,7 +97,7 @@ static void aout_Play ( aout_thread_t *p_aout, ...@@ -97,7 +97,7 @@ static void aout_Play ( aout_thread_t *p_aout,
byte_t *buffer, int i_size ); byte_t *buffer, int i_size );
static void aout_Close ( aout_thread_t *p_aout ); static void aout_Close ( aout_thread_t *p_aout );
/* local function */ /* local functions */
static int DirectxCreateSecondaryBuffer( aout_thread_t *p_aout ); static int DirectxCreateSecondaryBuffer( aout_thread_t *p_aout );
static int DirectxInitDSound( aout_thread_t *p_aout ); static int DirectxInitDSound( aout_thread_t *p_aout );
...@@ -209,6 +209,7 @@ static int aout_Open( aout_thread_t *p_aout ) ...@@ -209,6 +209,7 @@ static int aout_Open( aout_thread_t *p_aout )
intf_WarnMsg( 3, "aout: can't set primary buffer format"); intf_WarnMsg( 3, "aout: can't set primary buffer format");
} }
#if 0
/* ensure the primary buffer is playing. We won't actually hear anything /* ensure the primary buffer is playing. We won't actually hear anything
* until the secondary buffer is playing */ * until the secondary buffer is playing */
dsresult = IDirectSoundBuffer_Play( p_aout->p_sys->p_dsbuffer_primary, dsresult = IDirectSoundBuffer_Play( p_aout->p_sys->p_dsbuffer_primary,
...@@ -224,6 +225,7 @@ static int aout_Open( aout_thread_t *p_aout ) ...@@ -224,6 +225,7 @@ static int aout_Open( aout_thread_t *p_aout )
p_aout->p_sys->p_dsbuffer_primary = NULL; p_aout->p_sys->p_dsbuffer_primary = NULL;
return( 1 ); return( 1 );
} }
#endif
return( 0 ); return( 0 );
} }
...@@ -286,6 +288,7 @@ static long aout_GetBufInfo( aout_thread_t *p_aout, long l_buffer_limit ) ...@@ -286,6 +288,7 @@ static long aout_GetBufInfo( aout_thread_t *p_aout, long l_buffer_limit )
return( l_buffer_limit ); return( l_buffer_limit );
} }
#if 0
/* temporary hack. When you start playing a new file, the play position /* temporary hack. When you start playing a new file, the play position
* doesn't start changing immediatly, even though sound is already * doesn't start changing immediatly, even though sound is already
* playing from the sound card */ * playing from the sound card */
...@@ -294,6 +297,7 @@ static long aout_GetBufInfo( aout_thread_t *p_aout, long l_buffer_limit ) ...@@ -294,6 +297,7 @@ static long aout_GetBufInfo( aout_thread_t *p_aout, long l_buffer_limit )
intf_WarnMsg( 5, "aout: DirectX aout_GetBufInfo: %li", l_buffer_limit); intf_WarnMsg( 5, "aout: DirectX aout_GetBufInfo: %li", l_buffer_limit);
return( l_buffer_limit ); return( l_buffer_limit );
} }
#endif
l_result = (p_aout->p_sys->l_write_position >= l_play_position) ? l_result = (p_aout->p_sys->l_write_position >= l_play_position) ?
(p_aout->p_sys->l_write_position - l_play_position) /2 (p_aout->p_sys->l_write_position - l_play_position) /2
...@@ -334,6 +338,7 @@ static void aout_Play( aout_thread_t *p_aout, byte_t *buffer, int i_size ) ...@@ -334,6 +338,7 @@ static void aout_Play( aout_thread_t *p_aout, byte_t *buffer, int i_size )
intf_WarnMsg( 3, "aout: DirectX aout_Play can'get buffer position"); intf_WarnMsg( 3, "aout: DirectX aout_Play can'get buffer position");
} }
#if 1
/* check that we are not overflowing the circular buffer (everything should /* check that we are not overflowing the circular buffer (everything should
* be alright but just in case) */ * be alright but just in case) */
l_buffer_free_length = l_play_position - p_aout->p_sys->l_write_position; l_buffer_free_length = l_play_position - p_aout->p_sys->l_write_position;
...@@ -352,11 +357,13 @@ static void aout_Play( aout_thread_t *p_aout, byte_t *buffer, int i_size ) ...@@ -352,11 +357,13 @@ static void aout_Play( aout_thread_t *p_aout, byte_t *buffer, int i_size )
} }
else else
{ {
#if 0
intf_WarnMsg( 4, "aout: DirectX aout_Play buffer: size %i, free %i !!!" intf_WarnMsg( 4, "aout: DirectX aout_Play buffer: size %i, free %i !!!"
, i_size, l_buffer_free_length); , i_size, l_buffer_free_length);
intf_WarnMsg( 4, "aout: DirectX aout_Play buffer: writepos %i, readpos %i !!!", p_aout->p_sys->l_write_position, l_play_position); intf_WarnMsg( 4, "aout: DirectX aout_Play buffer: writepos %i, readpos %i !!!", p_aout->p_sys->l_write_position, l_play_position);
#endif
} }
#endif
/* Before copying anything, we have to lock the buffer */ /* Before copying anything, we have to lock the buffer */
dsresult = IDirectSoundBuffer_Lock( p_aout->p_sys->p_dsbuffer, dsresult = IDirectSoundBuffer_Lock( p_aout->p_sys->p_dsbuffer,
...@@ -389,7 +396,9 @@ static void aout_Play( aout_thread_t *p_aout, byte_t *buffer, int i_size ) ...@@ -389,7 +396,9 @@ static void aout_Play( aout_thread_t *p_aout, byte_t *buffer, int i_size )
/* Now do the actual memcopy (two memcpy because the buffer is circular) */ /* Now do the actual memcopy (two memcpy because the buffer is circular) */
memcpy( p_write_position, buffer, l_bytes1 ); memcpy( p_write_position, buffer, l_bytes1 );
if( p_start_buffer != NULL ) if( p_start_buffer != NULL )
{
memcpy( p_start_buffer, buffer + l_bytes1, l_bytes2 ); memcpy( p_start_buffer, buffer + l_bytes1, l_bytes2 );
}
/* Now the data has been copied, unlock the buffer */ /* Now the data has been copied, unlock the buffer */
IDirectSoundBuffer_Unlock( p_aout->p_sys->p_dsbuffer, IDirectSoundBuffer_Unlock( p_aout->p_sys->p_dsbuffer,
...@@ -543,7 +552,6 @@ static int DirectxCreateSecondaryBuffer( aout_thread_t *p_aout ) ...@@ -543,7 +552,6 @@ static int DirectxCreateSecondaryBuffer( aout_thread_t *p_aout )
WAVEFORMATEX waveformat; WAVEFORMATEX waveformat;
DSBUFFERDESC dsbdesc; DSBUFFERDESC dsbdesc;
DSBCAPS dsbcaps; DSBCAPS dsbcaps;
HRESULT dsresult;
/* First set the buffer format */ /* First set the buffer format */
memset(&waveformat, 0, sizeof(WAVEFORMATEX)); memset(&waveformat, 0, sizeof(WAVEFORMATEX));
...@@ -561,7 +569,7 @@ static int DirectxCreateSecondaryBuffer( aout_thread_t *p_aout ) ...@@ -561,7 +569,7 @@ static int DirectxCreateSecondaryBuffer( aout_thread_t *p_aout )
dsbdesc.dwSize = sizeof(DSBUFFERDESC); dsbdesc.dwSize = sizeof(DSBUFFERDESC);
dsbdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2/* Better position accuracy */ dsbdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2/* Better position accuracy */
| DSBCAPS_GLOBALFOCUS; /* Allows background playing */ | DSBCAPS_GLOBALFOCUS; /* Allows background playing */
dsbdesc.dwBufferBytes = waveformat.nAvgBytesPerSec * 4; /* 4 sec buffer */ dsbdesc.dwBufferBytes = waveformat.nAvgBytesPerSec * 2; /* 2 sec buffer */
dsbdesc.lpwfxFormat = &waveformat; dsbdesc.lpwfxFormat = &waveformat;
if( IDirectSound_CreateSoundBuffer( p_aout->p_sys->p_dsobject, if( IDirectSound_CreateSoundBuffer( p_aout->p_sys->p_dsobject,
......
This diff is collapsed.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* gtk_menu.c : functions to handle menu items. * gtk_menu.c : functions to handle menu items.
***************************************************************************** *****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN * Copyright (C) 2000, 2001 VideoLAN
* $Id: gtk_menu.c,v 1.11 2001/06/29 11:34:28 stef Exp $ * $Id: gtk_menu.c,v 1.12 2001/07/08 17:45:52 gbazin Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* Stphane Borel <stef@via.ecp.fr> * Stphane Borel <stef@via.ecp.fr>
...@@ -59,12 +59,6 @@ ...@@ -59,12 +59,6 @@
#include "modules_export.h" #include "modules_export.h"
#ifdef WIN32
#ifndef snprintf
#define snprintf _snprintf
#endif
#endif
/* /*
* Local Prototypes * Local Prototypes
*/ */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* input_ext-intf.c: services to the interface * input_ext-intf.c: services to the interface
***************************************************************************** *****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN * Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: input_ext-intf.c,v 1.24 2001/05/19 00:39:30 stef Exp $ * $Id: input_ext-intf.c,v 1.25 2001/07/08 17:45:52 gbazin Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -29,10 +29,6 @@ ...@@ -29,10 +29,6 @@
#include <string.h> /* memcpy(), memset() */ #include <string.h> /* memcpy(), memset() */
#include <sys/types.h> /* off_t */ #include <sys/types.h> /* off_t */
#ifdef WIN32
#define snprintf _snprintf
#endif
#include "config.h" #include "config.h"
#include "common.h" #include "common.h"
#include "threads.h" #include "threads.h"
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* interface, such as message output. See config.h for output configuration. * interface, such as message output. See config.h for output configuration.
***************************************************************************** *****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN * Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: intf_msg.c,v 1.36 2001/06/02 01:09:03 sam Exp $ * $Id: intf_msg.c,v 1.37 2001/07/08 17:45:52 gbazin Exp $
* *
* Authors: Vincent Seguin <seguin@via.ecp.fr> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* *
...@@ -49,12 +49,6 @@ ...@@ -49,12 +49,6 @@
#include "main.h" #include "main.h"
#ifdef WIN32
#ifndef snprintf
#define snprintf _snprintf /* snprintf not defined in mingw32 (bug?) */
#endif
#endif
/***************************************************************************** /*****************************************************************************
* intf_msg_item_t * intf_msg_item_t
***************************************************************************** *****************************************************************************
...@@ -128,6 +122,9 @@ static void QueueDbgMsg ( intf_msg_t *p_msg, char *psz_file, ...@@ -128,6 +122,9 @@ static void QueueDbgMsg ( intf_msg_t *p_msg, char *psz_file,
static void FlushLockedMsg ( intf_msg_t *p_msg ); static void FlushLockedMsg ( intf_msg_t *p_msg );
#endif #endif
#if defined( WIN32 )
static char *ConvertPrintfFormatString ( char *psz_format );
#endif
/***************************************************************************** /*****************************************************************************
* intf_MsgCreate: initialize messages interface (ok ?) * intf_MsgCreate: initialize messages interface (ok ?)
...@@ -404,6 +401,9 @@ static void QueueMsg( intf_msg_t *p_msg, int i_type, char *psz_format, va_list a ...@@ -404,6 +401,9 @@ static void QueueMsg( intf_msg_t *p_msg, int i_type, char *psz_format, va_list a
{ {
char * psz_str; /* formatted message string */ char * psz_str; /* formatted message string */
intf_msg_item_t * p_msg_item; /* pointer to message */ intf_msg_item_t * p_msg_item; /* pointer to message */
#ifdef WIN32
char * psz_temp;
#endif
#ifndef INTF_MSG_QUEUE /*................................... instant mode ...*/ #ifndef INTF_MSG_QUEUE /*................................... instant mode ...*/
intf_msg_item_t msg_item; /* message */ intf_msg_item_t msg_item; /* message */
...@@ -413,6 +413,7 @@ static void QueueMsg( intf_msg_t *p_msg, int i_type, char *psz_format, va_list a ...@@ -413,6 +413,7 @@ static void QueueMsg( intf_msg_t *p_msg, int i_type, char *psz_format, va_list a
/* /*
* Convert message to string * Convert message to string
*/ */
#ifdef HAVE_VASPRINTF #ifdef HAVE_VASPRINTF
vasprintf( &psz_str, psz_format, ap ); vasprintf( &psz_str, psz_format, ap );
#else #else
...@@ -426,10 +427,15 @@ static void QueueMsg( intf_msg_t *p_msg, int i_type, char *psz_format, va_list a ...@@ -426,10 +427,15 @@ static void QueueMsg( intf_msg_t *p_msg, int i_type, char *psz_format, va_list a
fprintf(stderr, "\n" ); fprintf(stderr, "\n" );
exit( errno ); exit( errno );
} }
#ifdef HAVE_VASPRINTF #ifndef HAVE_VASPRINTF
#ifdef WIN32
psz_temp = ConvertPrintfFormatString(psz_format);
vsprintf( psz_str, psz_temp, ap );
free( psz_temp );
#else #else
vsprintf( psz_str, psz_format, ap ); vsprintf( psz_str, psz_format, ap );
#endif #endif /* WIN32 */
#endif /* HAVE_VASPRINTF */
#ifdef INTF_MSG_QUEUE /*...................................... queue mode ...*/ #ifdef INTF_MSG_QUEUE /*...................................... queue mode ...*/
vlc_mutex_lock( &p_msg->lock ); /* get lock */ vlc_mutex_lock( &p_msg->lock ); /* get lock */
...@@ -472,6 +478,9 @@ static void QueueDbgMsg(intf_msg_t *p_msg, char *psz_file, char *psz_function, ...@@ -472,6 +478,9 @@ static void QueueDbgMsg(intf_msg_t *p_msg, char *psz_file, char *psz_function,
{ {
char * psz_str; /* formatted message string */ char * psz_str; /* formatted message string */
intf_msg_item_t * p_msg_item; /* pointer to message */ intf_msg_item_t * p_msg_item; /* pointer to message */
#ifdef WIN32
char * psz_temp;
#endif
#ifndef INTF_MSG_QUEUE /*................................... instant mode ...*/ #ifndef INTF_MSG_QUEUE /*................................... instant mode ...*/
intf_msg_item_t msg_item; /* message */ intf_msg_item_t msg_item; /* message */
...@@ -485,7 +494,6 @@ static void QueueDbgMsg(intf_msg_t *p_msg, char *psz_file, char *psz_function, ...@@ -485,7 +494,6 @@ static void QueueDbgMsg(intf_msg_t *p_msg, char *psz_file, char *psz_function,
vasprintf( &psz_str, psz_format, ap ); vasprintf( &psz_str, psz_format, ap );
#else #else
psz_str = (char*) malloc( INTF_MAX_MSG_SIZE ); psz_str = (char*) malloc( INTF_MAX_MSG_SIZE );
vsprintf( psz_str, psz_format, ap );
#endif #endif
if( psz_str == NULL ) if( psz_str == NULL )
{ {
...@@ -496,6 +504,15 @@ static void QueueDbgMsg(intf_msg_t *p_msg, char *psz_file, char *psz_function, ...@@ -496,6 +504,15 @@ static void QueueDbgMsg(intf_msg_t *p_msg, char *psz_file, char *psz_function,
fprintf(stderr, "\n" ); fprintf(stderr, "\n" );
exit( errno ); exit( errno );
} }
#ifndef HAVE_VASPRINTF
#ifdef WIN32
psz_temp = ConvertPrintfFormatString(psz_format);
vsprintf( psz_str, psz_temp, ap );
free( psz_temp );
#else
vsprintf( psz_str, psz_format, ap );
#endif /* WIN32 */
#endif /* HAVE_VASPRINTF */
#ifdef INTF_MSG_QUEUE /*...................................... queue mode ...*/ #ifdef INTF_MSG_QUEUE /*...................................... queue mode ...*/
vlc_mutex_lock( &p_msg->lock ); /* get lock */ vlc_mutex_lock( &p_msg->lock ); /* get lock */
...@@ -651,3 +668,58 @@ static void PrintMsg( intf_msg_item_t *p_msg ) ...@@ -651,3 +668,58 @@ static void PrintMsg( intf_msg_item_t *p_msg )
#endif #endif
#if defined( WIN32 )
/*****************************************************************************
* 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
* 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
* a "long long" type!!!
* By the way, if we don't do this we can sometimes end up with segfaults.
*****************************************************************************/
static char *ConvertPrintfFormatString( char *psz_format )
{
int i, i_counter=0, i_pos=0;
char *psz_dest;
/* We first need to check how many occurences of %ll there are in the
* 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( !strncmp( (char *)(psz_format + i), "%ll", 3 ) )
i_counter++;
}
/* malloc the destination string */
psz_dest = malloc( strlen(psz_format) + i_counter + 1 );
if( psz_dest == NULL )
{
fprintf(stderr, "warning: malloc failed in ConvertPrintfFormatString\n");
exit (errno);
}
/* Now build the modified string */
i_counter = 0;
for( i=0; i <= (strlen(psz_format) - 4); i++ )
{
if( !strncmp( (char *)(psz_format + i), "%ll", 3 ) )
{
memcpy( psz_dest+i_pos+i_counter, psz_format+i_pos, i-i_pos+1);
*(psz_dest+i+i_counter+1)='I';
*(psz_dest+i+i_counter+2)='6';
*(psz_dest+i+i_counter+3)='4';
i_pos = i+3;
i_counter++;
}
}
strcpy( psz_dest+i_pos+i_counter, psz_format+i_pos );
return psz_dest;
}
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment