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

 * dvdcss_readv optimisations for Win32. We now send only one read command
   to the DVD drive for the whole iovec.
 * Fixed _win32_dvdcss_aread to work around the WinASPI32 64kb transfer
   size restriction.
 * New and theoretically better Win32 pthread implementation which fixes a
   problem I was having when changing title on a DVD (netlist related).
   vlc_cond_multicast may or may not work.
 * Fixed the "quit" event handling in directx/vout_events.c.
 * dvd_ifo.c now takes into account error messages from UDFFindFile.
 * Temporarily disabled aout_Probe() in aout_SDL (this function
   is creating an awful lot of problems - libSDL bug ).
parent 1977c0ab
...@@ -3,7 +3,13 @@ ...@@ -3,7 +3,13 @@
#===================# #===================#
HEAD HEAD
* dvdcss_readv() optimisations for Win32.
* Fixed _win32_dvdcss_aread() to work around the WinASPI32 64kb transfer
size restriction.
* New and theoretically better Win32 pthread implementation.
* dvd_ifo.c now takes into account error messages from UDFFindFile.
* Fixed the "quit" event handling in directx/vout_events.c.
* Temporarily disabled aout_Probe() in aout_SDL (libSDL bug).
* libdvdcss segfault fixes. * libdvdcss segfault fixes.
* Tuned constants, since it seems to make people happy. * Tuned constants, since it seems to make people happy.
* Fixed the "paused movie won't restart" bug. * Fixed the "paused movie won't restart" bug.
...@@ -22,10 +28,11 @@ HEAD ...@@ -22,10 +28,11 @@ HEAD
* Fixed 2 Win32 bugs in libdvdcss (in _win32_dvdcss_readv), one of them * Fixed 2 Win32 bugs in libdvdcss (in _win32_dvdcss_readv), one of them
should have prevented the Win9x dvd input from working. should have prevented the Win9x dvd input from working.
* Moved the "if(Win2k)" out of the loop in _win32_dvdcss_readv. * Moved the "if(Win2k)" out of the loop in _win32_dvdcss_readv.
* Put a readv() function in input_iovec.h, the input_es now compiles. * Put a readv() function in input_iovec.h, the input_es plugin now compiles
* Modified input_ts to use this function. (Win32).
* Modified input_ts to use readv() in input_iovec.h (Win32).
* Fixed an initialisation bug in vout_directx.c. * Fixed an initialisation bug in vout_directx.c.
* Right clicking on the mouse now displays the navigation menu. * Right clicking on the mouse displays the navigation menu (DirectX plugin).
* Fixed audio/video synchro bug with esd, should fix buggy sound due * Fixed audio/video synchro bug with esd, should fix buggy sound due
to 44100-48000 Hz conversions. to 44100-48000 Hz conversions.
* The Win32 GetMessage function has been isolated in a thread. This has * The Win32 GetMessage function has been isolated in a thread. This has
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* libdvdcss.c: DVD reading library. * libdvdcss.c: DVD reading library.
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2001 VideoLAN * Copyright (C) 1998-2001 VideoLAN
* $Id: libdvdcss.c,v 1.8 2001/07/25 00:23:40 sam Exp $ * $Id: libdvdcss.c,v 1.9 2001/07/25 08:41:21 gbazin Exp $
* *
* Authors: Stphane Borel <stef@via.ecp.fr> * Authors: Stphane Borel <stef@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -65,7 +65,7 @@ static int _dvdcss_readv ( dvdcss_handle, struct iovec *p_iovec, int i_blocks ); ...@@ -65,7 +65,7 @@ static int _dvdcss_readv ( dvdcss_handle, struct iovec *p_iovec, int i_blocks );
*****************************************************************************/ *****************************************************************************/
#if defined( WIN32 ) #if defined( WIN32 )
static int _win32_dvdcss_readv ( int i_fd, struct iovec *p_iovec, static int _win32_dvdcss_readv ( int i_fd, struct iovec *p_iovec,
int i_num_buffers ); int i_num_buffers, char *p_tmp_buffer );
static int _win32_dvdcss_aopen ( char c_drive, dvdcss_handle dvdcss ); static int _win32_dvdcss_aopen ( char c_drive, dvdcss_handle dvdcss );
static int _win32_dvdcss_aclose ( int i_fd ); static int _win32_dvdcss_aclose ( int i_fd );
static int _win32_dvdcss_aseek ( int i_fd, int i_blocks, int i_method ); static int _win32_dvdcss_aseek ( int i_fd, int i_blocks, int i_method );
...@@ -403,6 +403,10 @@ static int _dvdcss_open ( dvdcss_handle dvdcss, char *psz_target ) ...@@ -403,6 +403,10 @@ static int _dvdcss_open ( dvdcss_handle dvdcss, char *psz_target )
} }
} }
/* initialise readv temporary buffer */
dvdcss->p_readv_buffer = NULL;
dvdcss->i_readv_buf_size = 0;
#else #else
dvdcss->i_fd = open( psz_target, 0 ); dvdcss->i_fd = open( psz_target, 0 );
...@@ -428,8 +432,18 @@ static int _dvdcss_close ( dvdcss_handle dvdcss ) ...@@ -428,8 +432,18 @@ static int _dvdcss_close ( dvdcss_handle dvdcss )
{ {
_win32_dvdcss_aclose( dvdcss->i_fd ); _win32_dvdcss_aclose( dvdcss->i_fd );
} }
/* Free readv temporary buffer */
if( dvdcss->p_readv_buffer )
{
free( dvdcss->p_readv_buffer );
dvdcss->p_readv_buffer = NULL;
dvdcss->i_readv_buf_size = 0;
}
#else #else
close( dvdcss->i_fd ); close( dvdcss->i_fd );
#endif #endif
return 0; return 0;
...@@ -513,14 +527,36 @@ static int _dvdcss_readv ( dvdcss_handle dvdcss, struct iovec *p_iovec, ...@@ -513,14 +527,36 @@ static int _dvdcss_readv ( dvdcss_handle dvdcss, struct iovec *p_iovec,
int i_read; int i_read;
#if defined( WIN32 ) #if defined( WIN32 )
i_read = _win32_dvdcss_readv( dvdcss->i_fd, p_iovec, i_blocks ); /* Check the size of the readv temp buffer, just in case we need to
* realloc something bigger */
if( dvdcss->i_readv_buf_size < i_blocks * DVDCSS_BLOCK_SIZE )
{
dvdcss->i_readv_buf_size = i_blocks * DVDCSS_BLOCK_SIZE;
if( dvdcss->p_readv_buffer ) free( dvdcss->p_readv_buffer );
/* Allocate a buffer which will be used as a temporary storage
* for readv */
dvdcss->p_readv_buffer = malloc( dvdcss->i_readv_buf_size );
if( !dvdcss->p_readv_buffer )
{
_dvdcss_error( dvdcss, " failed (readv)" );
return -1;
}
}
i_read = _win32_dvdcss_readv( dvdcss->i_fd, p_iovec, i_blocks,
dvdcss->p_readv_buffer );
return i_read; return i_read;
#else #else
i_read = readv( dvdcss->i_fd, p_iovec, i_blocks ); i_read = readv( dvdcss->i_fd, p_iovec, i_blocks );
return i_read / DVDCSS_BLOCK_SIZE; return i_read / DVDCSS_BLOCK_SIZE;
#endif #endif
} }
#if defined( WIN32 ) #if defined( WIN32 )
/***************************************************************************** /*****************************************************************************
...@@ -528,75 +564,58 @@ static int _dvdcss_readv ( dvdcss_handle dvdcss, struct iovec *p_iovec, ...@@ -528,75 +564,58 @@ static int _dvdcss_readv ( dvdcss_handle dvdcss, struct iovec *p_iovec,
* _win32_dvdcss_aread for win9x * _win32_dvdcss_aread for win9x
*****************************************************************************/ *****************************************************************************/
static int _win32_dvdcss_readv( int i_fd, struct iovec *p_iovec, static int _win32_dvdcss_readv( int i_fd, struct iovec *p_iovec,
int i_num_buffers ) int i_num_buffers, char *p_tmp_buffer )
{ {
int i_index, i_len, i_total = 0; int i_index;
unsigned char *p_base; int i_blocks, i_blocks_total = 0;
int i_blocks;
if( WIN2K ) for( i_index = i_num_buffers; i_index; i_index-- )
{ {
for( i_index = i_num_buffers; i_index; i_index-- ) i_blocks_total += p_iovec[i_index-1].iov_len;
{ }
i_len = p_iovec->iov_len;
p_base = p_iovec->iov_base;
if( i_len > 0 ) if( i_blocks_total <= 0 ) return 0;
{
unsigned long int i_bytes;
if( !ReadFile( (HANDLE) i_fd, p_base, i_len, &i_bytes, NULL ) )
{
return -1;
/* One of the reads failed, too bad.
We won't even bother returning the reads that went well,
and like in the posix spec the file postition is left
unspecified after a failure */
}
i_blocks = i_bytes / DVDCSS_BLOCK_SIZE;
i_total += i_blocks;
if( i_blocks != (i_len / DVDCSS_BLOCK_SIZE) )
{
/* we reached the end of the file */
return i_total;
}
} i_blocks_total /= DVDCSS_BLOCK_SIZE;
p_iovec++; if( WIN2K )
{
unsigned long int i_bytes;
if( !ReadFile( (HANDLE)i_fd, p_tmp_buffer,
i_blocks_total * DVDCSS_BLOCK_SIZE, &i_bytes, NULL ) )
{
return -1;
/* The read failed... too bad.
As in the posix spec the file postition is left
unspecified after a failure */
} }
i_blocks = i_bytes / DVDCSS_BLOCK_SIZE;
} }
else /* Win9x */ else /* Win9x */
{ {
for( i_index = i_num_buffers; i_index; i_index-- ) i_blocks = _win32_dvdcss_aread( i_fd, p_tmp_buffer, i_blocks_total );
if( i_blocks < 0 )
{ {
i_len = p_iovec->iov_len / DVDCSS_BLOCK_SIZE; return -1; /* idem */
p_base = p_iovec->iov_base;
if( i_len > 0 )
{
i_blocks = _win32_dvdcss_aread( i_fd, p_base, i_len );
if( i_blocks < 0 )
{
return -1; /* idem */
}
i_total += i_blocks;
if( i_blocks != i_len )
{
/* we reached the end of the file or a signal interrupted
the read */
return i_total;
}
}
p_iovec++;
} }
} }
return i_total; /* We just have to copy the content of the temp buffer into the iovecs */
i_index = 0;
i_blocks_total = i_blocks;
while( i_blocks_total > 0 )
{
memcpy( p_iovec[i_index].iov_base,
&p_tmp_buffer[(i_blocks - i_blocks_total) * DVDCSS_BLOCK_SIZE],
p_iovec[i_index].iov_len );
/* if we read less blocks than asked, we'll just end up copying
garbage, this isn't an issue as we return the number of
blocks actually read */
i_blocks_total -= ( p_iovec[i_index].iov_len / DVDCSS_BLOCK_SIZE );
i_index++;
}
return i_blocks;
} }
/***************************************************************************** /*****************************************************************************
...@@ -611,7 +630,7 @@ static int _win32_dvdcss_aopen( char c_drive, dvdcss_handle dvdcss ) ...@@ -611,7 +630,7 @@ static int _win32_dvdcss_aopen( char c_drive, dvdcss_handle dvdcss )
int i, j, i_hostadapters; int i, j, i_hostadapters;
long (*lpGetSupport)( void ); long (*lpGetSupport)( void );
long (*lpSendCommand)( void* ); long (*lpSendCommand)( void* );
hASPI = LoadLibrary( "wnaspi32.dll" ); hASPI = LoadLibrary( "wnaspi32.dll" );
if( hASPI == NULL ) if( hASPI == NULL )
{ {
...@@ -621,7 +640,7 @@ static int _win32_dvdcss_aopen( char c_drive, dvdcss_handle dvdcss ) ...@@ -621,7 +640,7 @@ static int _win32_dvdcss_aopen( char c_drive, dvdcss_handle dvdcss )
(FARPROC) lpGetSupport = GetProcAddress( hASPI, "GetASPI32SupportInfo" ); (FARPROC) lpGetSupport = GetProcAddress( hASPI, "GetASPI32SupportInfo" );
(FARPROC) lpSendCommand = GetProcAddress( hASPI, "SendASPI32Command" ); (FARPROC) lpSendCommand = GetProcAddress( hASPI, "SendASPI32Command" );
if(lpGetSupport == NULL || lpSendCommand == NULL ) if(lpGetSupport == NULL || lpSendCommand == NULL )
{ {
_dvdcss_debug( dvdcss, "unable to get aspi function pointers" ); _dvdcss_debug( dvdcss, "unable to get aspi function pointers" );
...@@ -680,8 +699,8 @@ static int _win32_dvdcss_aopen( char c_drive, dvdcss_handle dvdcss ) ...@@ -680,8 +699,8 @@ static int _win32_dvdcss_aopen( char c_drive, dvdcss_handle dvdcss )
lpSendCommand( (void*) &srbDiskInfo ); lpSendCommand( (void*) &srbDiskInfo );
if( srbDiskInfo.SRB_Status == SS_COMP && if( (srbDiskInfo.SRB_Status == SS_COMP) &&
srbDiskInfo.SRB_Int13HDriveInfo == c_drive ) (srbDiskInfo.SRB_Int13HDriveInfo == c_drive) )
{ {
fd->i_sid = MAKEWORD( i, j ); fd->i_sid = MAKEWORD( i, j );
return (int) fd; return (int) fd;
...@@ -692,8 +711,7 @@ static int _win32_dvdcss_aopen( char c_drive, dvdcss_handle dvdcss ) ...@@ -692,8 +711,7 @@ static int _win32_dvdcss_aopen( char c_drive, dvdcss_handle dvdcss )
free( (void*) fd ); free( (void*) fd );
FreeLibrary( hASPI ); FreeLibrary( hASPI );
_dvdcss_debug( dvdcss, "unable to get haid and target (aspi)" ); _dvdcss_debug( dvdcss, "unable to get haid and target (aspi)" );
return( -1 );
return( -1 );
} }
/***************************************************************************** /*****************************************************************************
...@@ -743,56 +761,78 @@ static int _win32_dvdcss_aseek( int i_fd, int i_blocks, int i_method ) ...@@ -743,56 +761,78 @@ static int _win32_dvdcss_aseek( int i_fd, int i_blocks, int i_method )
static int _win32_dvdcss_aread( int i_fd, void *p_data, int i_blocks ) static int _win32_dvdcss_aread( int i_fd, void *p_data, int i_blocks )
{ {
HANDLE hEvent; HANDLE hEvent;
DWORD dwStart, dwLen;
struct SRB_ExecSCSICmd ssc; struct SRB_ExecSCSICmd ssc;
struct w32_aspidev *fd = (struct w32_aspidev *) i_fd; struct w32_aspidev *fd = (struct w32_aspidev *) i_fd;
memset( &ssc, 0, sizeof( ssc ) ); /* Create the transfer completion event */
dwStart = fd->i_blocks;
dwLen = i_blocks;
hEvent = CreateEvent( NULL, TRUE, FALSE, NULL ); hEvent = CreateEvent( NULL, TRUE, FALSE, NULL );
if( hEvent == NULL ) if( hEvent == NULL )
{ {
return -1; return -1;
} }
memset( &ssc, 0, sizeof( ssc ) );
ssc.SRB_Cmd = SC_EXEC_SCSI_CMD; ssc.SRB_Cmd = SC_EXEC_SCSI_CMD;
ssc.SRB_Flags = SRB_DIR_IN | SRB_EVENT_NOTIFY; ssc.SRB_Flags = SRB_DIR_IN | SRB_EVENT_NOTIFY;
ssc.SRB_HaId = LOBYTE( fd->i_sid ); ssc.SRB_HaId = LOBYTE( fd->i_sid );
ssc.SRB_Target = HIBYTE( fd->i_sid ); ssc.SRB_Target = HIBYTE( fd->i_sid );
ssc.SRB_SenseLen = SENSE_LEN; ssc.SRB_SenseLen = SENSE_LEN;
ssc.SRB_PostProc = (LPVOID) hEvent;
ssc.SRB_PostProc = (LPVOID) hEvent;
ssc.SRB_BufLen = dwLen * DVDCSS_BLOCK_SIZE;
ssc.SRB_BufPointer = p_data; ssc.SRB_BufPointer = p_data;
ssc.SRB_CDBLen = 12; ssc.SRB_CDBLen = 12;
ssc.CDBByte[0] = 0xA8; /* RAW */ ssc.CDBByte[0] = 0xA8; /* RAW */
ssc.CDBByte[2] = (UCHAR) dwStart >> 24; ssc.CDBByte[2] = (UCHAR) (fd->i_blocks >> 24);
ssc.CDBByte[3] = (UCHAR) (dwStart >> 16) & 0xff; ssc.CDBByte[3] = (UCHAR) (fd->i_blocks >> 16) & 0xff;
ssc.CDBByte[4] = (UCHAR) (dwStart >> 8) & 0xff; ssc.CDBByte[4] = (UCHAR) (fd->i_blocks >> 8) & 0xff;
ssc.CDBByte[5] = (UCHAR) (dwStart) & 0xff; ssc.CDBByte[5] = (UCHAR) (fd->i_blocks) & 0xff;
ssc.CDBByte[6] = (UCHAR) dwLen >> 24;
ssc.CDBByte[7] = (UCHAR) (dwLen >> 16) & 0xff; /* We have to break down the reads into 64kb pieces (ASPI restriction) */
ssc.CDBByte[8] = (UCHAR) (dwLen >> 8) & 0xff; if( i_blocks > 32 )
ssc.CDBByte[9] = (UCHAR) (dwLen) & 0xff;
ResetEvent( hEvent );
if( fd->lpSendCommand( (void*) &ssc ) == SS_PENDING )
{ {
WaitForSingleObject( hEvent, INFINITE ); ssc.SRB_BufLen = 32 * DVDCSS_BLOCK_SIZE;
ssc.CDBByte[9] = 32;
fd->i_blocks += 32;
/* Initiate transfer */
ResetEvent( hEvent );
fd->lpSendCommand( (void*) &ssc );
/* transfer the next 64kb (_win32_dvdcss_aread is called recursively)
* We need to check the status of the read on return */
if( _win32_dvdcss_aread( i_fd, p_data + 32 * DVDCSS_BLOCK_SIZE,
i_blocks - 32) < 0 )
{
return -1;
}
} }
else
{
/* This is the last transfer */
ssc.SRB_BufLen = i_blocks * DVDCSS_BLOCK_SIZE;
ssc.CDBByte[9] = (UCHAR) i_blocks;
fd->i_blocks += i_blocks;
/* Initiate transfer */
ResetEvent( hEvent );
fd->lpSendCommand( (void*) &ssc );
}
/* If the command has still not been processed, wait until it's finished */
if( ssc.SRB_Status == SS_PENDING )
{
WaitForSingleObject( hEvent, INFINITE );
}
CloseHandle( hEvent ); CloseHandle( hEvent );
/* check that the transfer went as planned */
if( ssc.SRB_Status != SS_COMP ) if( ssc.SRB_Status != SS_COMP )
{ {
return -1; return -1;
} }
fd->i_blocks += i_blocks;
return i_blocks; return i_blocks;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* private.h: private DVD reading library data * private.h: private DVD reading library data
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2001 VideoLAN * Copyright (C) 1998-2001 VideoLAN
* $Id: libdvdcss.h,v 1.5 2001/07/25 00:23:40 sam Exp $ * $Id: libdvdcss.h,v 1.6 2001/07/25 08:41:21 gbazin Exp $
* *
* Authors: Stphane Borel <stef@via.ecp.fr> * Authors: Stphane Borel <stef@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -46,6 +46,10 @@ struct dvdcss_s ...@@ -46,6 +46,10 @@ struct dvdcss_s
boolean_t b_errors; boolean_t b_errors;
boolean_t b_debug; boolean_t b_debug;
#if defined( WIN32 )
char *p_readv_buffer;
int i_readv_buf_size;
#endif
}; };
/***************************************************************************** /*****************************************************************************
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* This header provides a portable threads implementation. * This header provides a portable threads implementation.
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: threads.h,v 1.20 2001/07/18 14:21:00 massiot Exp $ * $Id: threads.h,v 1.21 2001/07/25 08:41:21 gbazin Exp $
* *
* Authors: Jean-Marc Dressler <polux@via.ecp.fr> * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@via.ecp.fr> * Samuel Hocevar <sam@via.ecp.fr>
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
# include <kernel/scheduler.h> # include <kernel/scheduler.h>
# include <byteorder.h> # include <byteorder.h>
#elif defined( WIN32 ) /* Win32 with MinGW32 compiler */ #elif defined( WIN32 )
# include <windows.h> # include <windows.h>
# include <process.h> # include <process.h>
...@@ -134,9 +134,15 @@ typedef struct ...@@ -134,9 +134,15 @@ typedef struct
} vlc_cond_t; } vlc_cond_t;
#elif defined( WIN32 ) #elif defined( WIN32 )
typedef HANDLE vlc_thread_t; typedef HANDLE vlc_thread_t;
typedef HANDLE vlc_mutex_t; typedef CRITICAL_SECTION vlc_mutex_t;
typedef HANDLE vlc_cond_t;
typedef struct
{
int i_waiting_threads;
HANDLE signal;
} vlc_cond_t;
typedef unsigned (__stdcall *PTHREAD_START) (void *); typedef unsigned (__stdcall *PTHREAD_START) (void *);
#endif #endif
...@@ -188,7 +194,23 @@ typedef struct wrapper_s ...@@ -188,7 +194,23 @@ typedef struct wrapper_s
struct itimerval itimer; struct itimerval itimer;
} wrapper_t; } wrapper_t;
#endif
#ifdef WIN32
struct itimerval
{
struct timeval it_value;
struct timeval it_interval;
};
int setitimer(int kind, const struct itimerval* itnew,
struct itimerval* itold);
#define ITIMER_REAL 1
#define ITIMER_PROF 2
#endif /* WIN32 */
#endif /* PROFILING */
/***************************************************************************** /*****************************************************************************
* vlc_threads_init: initialize threads system * vlc_threads_init: initialize threads system
...@@ -274,8 +296,8 @@ static __inline__ int vlc_mutex_init( vlc_mutex_t *p_mutex ) ...@@ -274,8 +296,8 @@ static __inline__ int vlc_mutex_init( vlc_mutex_t *p_mutex )
return B_OK; return B_OK;
#elif defined( WIN32 ) #elif defined( WIN32 )
*p_mutex = CreateMutex(0,FALSE,0); InitializeCriticalSection( p_mutex );
return (*p_mutex?0:1); return 0;
#endif #endif
} }
...@@ -312,7 +334,7 @@ static __inline__ int vlc_mutex_lock( vlc_mutex_t *p_mutex ) ...@@ -312,7 +334,7 @@ static __inline__ int vlc_mutex_lock( vlc_mutex_t *p_mutex )
return err; return err;
#elif defined( WIN32 ) #elif defined( WIN32 )
WaitForSingleObject( *p_mutex, INFINITE ); EnterCriticalSection( p_mutex );
return 0; return 0;
#endif #endif
...@@ -348,7 +370,7 @@ static __inline__ int vlc_mutex_unlock( vlc_mutex_t *p_mutex ) ...@@ -348,7 +370,7 @@ static __inline__ int vlc_mutex_unlock( vlc_mutex_t *p_mutex )
return B_OK; return B_OK;
#elif defined( WIN32 ) #elif defined( WIN32 )
ReleaseMutex( *p_mutex ); LeaveCriticalSection( p_mutex );
return 0; return 0;
#endif #endif
...@@ -375,7 +397,7 @@ static __inline__ int vlc_mutex_destroy( vlc_mutex_t *p_mutex ) ...@@ -375,7 +397,7 @@ static __inline__ int vlc_mutex_destroy( vlc_mutex_t *p_mutex )
return B_OK; return B_OK;
#elif defined( WIN32 ) #elif defined( WIN32 )
CloseHandle(*p_mutex); DeleteCriticalSection( p_mutex );
return 0; return 0;
#endif #endif
...@@ -417,13 +439,16 @@ static __inline__ int vlc_cond_init( vlc_cond_t *p_condvar ) ...@@ -417,13 +439,16 @@ static __inline__ int vlc_cond_init( vlc_cond_t *p_condvar )
return 0; return 0;
#elif defined( WIN32 ) #elif defined( WIN32 )
/* initialise counter */
p_condvar->i_waiting_threads = 0;
/* Create an auto-reset event. */ /* Create an auto-reset event. */
*p_condvar = CreateEvent( NULL, /* no security */ p_condvar->signal = CreateEvent( NULL, /* no security */
FALSE, /* auto-reset event */ FALSE, /* auto-reset event */
FALSE, /* non-signaled initially */ FALSE, /* non-signaled initially */
NULL ); /* unnamed */ NULL ); /* unnamed */
return( *p_condvar ? 0 : 1 ); return( !p_condvar->signal );
#endif #endif
} }
...@@ -484,8 +509,14 @@ static __inline__ int vlc_cond_signal( vlc_cond_t *p_condvar ) ...@@ -484,8 +509,14 @@ static __inline__ int vlc_cond_signal( vlc_cond_t *p_condvar )
return 0; return 0;
#elif defined( WIN32 ) #elif defined( WIN32 )
/* Try to release one waiting thread. */ /* Release one waiting thread if one is available. */
PulseEvent ( *p_condvar ); /* For this trick to work properly, the vlc_cond_signal must be surrounded
* by a mutex. This will prevent another thread from stealing the signal */
while( p_condvar->i_waiting_threads )
{
PulseEvent( p_condvar->signal );
Sleep( 0 ); /* deschedule the current thread */
}
return 0; return 0;
#endif #endif
...@@ -552,8 +583,14 @@ static __inline__ int vlc_cond_broadcast( vlc_cond_t *p_condvar ) ...@@ -552,8 +583,14 @@ static __inline__ int vlc_cond_broadcast( vlc_cond_t *p_condvar )
return 0; return 0;
#elif defined( WIN32 ) #elif defined( WIN32 )
/* Try to release one waiting thread. */ /* Release all waiting threads. */
PulseEvent ( *p_condvar ); /* For this trick to work properly, the vlc_cond_signal must be surrounded
* by a mutex. This will prevent another thread from stealing the signal */
while( p_condvar->i_waiting_threads )
{
PulseEvent( p_condvar->signal );
Sleep( 0 ); /* deschedule the current thread */
}
return 0; return 0;
#endif #endif
...@@ -602,16 +639,31 @@ static __inline__ int vlc_cond_wait( vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex ...@@ -602,16 +639,31 @@ static __inline__ int vlc_cond_wait( vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex
return 0; return 0;
#elif defined( WIN32 ) #elif defined( WIN32 )
/* Release the <external_mutex> here and wait for the event /* The ideal would be to use a function which atomically releases the
* to become signaled, due to <pthread_cond_signal> being * mutex and initiate the waiting.
* called. */ * Unfortunately only the SignalObjectAndWait function does this and it's
* only supported on WinNT/2K, furthermore it cannot take multiple
* events as parameters.
*
* The solution we use should however fulfill all our needs (even though
* it is not a correct pthreads implementation)
*/
int i_result;
p_condvar->i_waiting_threads ++;
/* Release the mutex */
vlc_mutex_unlock( p_mutex ); vlc_mutex_unlock( p_mutex );
WaitForSingleObject( *p_condvar, INFINITE ); i_result = WaitForSingleObject( p_condvar->signal, INFINITE);
/* maybe we should protect this with a mutex ? */
p_condvar->i_waiting_threads --;
/* Reacquire the mutex before returning. */ /* Reacquire the mutex before returning. */
vlc_mutex_lock( p_mutex ); vlc_mutex_lock( p_mutex );
return 0;
return( i_result == WAIT_FAILED );
#endif #endif
} }
...@@ -632,8 +684,7 @@ static __inline__ int vlc_cond_destroy( vlc_cond_t *p_condvar ) ...@@ -632,8 +684,7 @@ static __inline__ int vlc_cond_destroy( vlc_cond_t *p_condvar )
return 0; return 0;
#elif defined( WIN32 ) #elif defined( WIN32 )
CloseHandle( *p_condvar ); return( !CloseHandle( p_condvar->signal ) );
return 0;
#endif #endif
} }
...@@ -642,7 +693,8 @@ static __inline__ int vlc_cond_destroy( vlc_cond_t *p_condvar ) ...@@ -642,7 +693,8 @@ static __inline__ int vlc_cond_destroy( vlc_cond_t *p_condvar )
* vlc_thread_create: create a thread * vlc_thread_create: create a thread
*****************************************************************************/ *****************************************************************************/
static __inline__ int vlc_thread_create( vlc_thread_t *p_thread, static __inline__ int vlc_thread_create( vlc_thread_t *p_thread,
char *psz_name, vlc_thread_func_t func, char *psz_name,
vlc_thread_func_t func,
void *p_data ) void *p_data )
{ {
int i_ret; int i_ret;
...@@ -785,4 +837,3 @@ static void *vlc_thread_wrapper( void *p_wrapper ) ...@@ -785,4 +837,3 @@ static void *vlc_thread_wrapper( void *p_wrapper )
return func( p_data ); return func( p_data );
} }
#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.5 2001/07/12 20:44:52 reno Exp $ * $Id: aout_directx.c,v 1.6 2001/07/25 08:41:21 gbazin Exp $
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -306,7 +306,9 @@ static long aout_GetBufInfo( aout_thread_t *p_aout, long l_buffer_limit ) ...@@ -306,7 +306,9 @@ static long aout_GetBufInfo( aout_thread_t *p_aout, long l_buffer_limit )
: (p_aout->p_sys->l_buffer_size - l_play_position : (p_aout->p_sys->l_buffer_size - l_play_position
+ p_aout->p_sys->l_write_position) /2 ; + p_aout->p_sys->l_write_position) /2 ;
#if 0
intf_WarnMsg( 5, "aout: DirectX aout_GetBufInfo: %li", l_result); intf_WarnMsg( 5, "aout: DirectX aout_GetBufInfo: %li", l_result);
#endif
return l_result; return l_result;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vout_events.c: Windows DirectX video output events handler * vout_events.c: Windows DirectX video output events handler
***************************************************************************** *****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN * Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: vout_events.c,v 1.2 2001/07/12 23:06:54 gbazin Exp $ * $Id: vout_events.c,v 1.3 2001/07/25 08:41:21 gbazin Exp $
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -179,7 +179,6 @@ void DirectXEventThread( vout_thread_t *p_vout ) ...@@ -179,7 +179,6 @@ void DirectXEventThread( vout_thread_t *p_vout )
case WM_RBUTTONUP: case WM_RBUTTONUP:
intf_WarnMsg( 4, "vout: vout_Manage WM_RBUTTONUP" ); intf_WarnMsg( 4, "vout: vout_Manage WM_RBUTTONUP" );
/* FIXME: need locking ! */
p_main->p_intf->b_menu_change = 1; p_main->p_intf->b_menu_change = 1;
break; break;
...@@ -192,7 +191,7 @@ void DirectXEventThread( vout_thread_t *p_vout ) ...@@ -192,7 +191,7 @@ void DirectXEventThread( vout_thread_t *p_vout )
{ {
case VK_ESCAPE: case VK_ESCAPE:
case VK_F12: case VK_F12:
p_main->p_intf->b_die = 1; PostQuitMessage( 0 );
break; break;
} }
TranslateMessage(&msg); TranslateMessage(&msg);
...@@ -205,7 +204,7 @@ void DirectXEventThread( vout_thread_t *p_vout ) ...@@ -205,7 +204,7 @@ void DirectXEventThread( vout_thread_t *p_vout )
{ {
case 'q': case 'q':
case 'Q': case 'Q':
p_main->p_intf->b_die = 1; PostQuitMessage( 0 );
break; break;
case 'f': /* switch to fullscreen */ case 'f': /* switch to fullscreen */
...@@ -295,7 +294,6 @@ void DirectXEventThread( vout_thread_t *p_vout ) ...@@ -295,7 +294,6 @@ void DirectXEventThread( vout_thread_t *p_vout )
/* Set thread Status */ /* Set thread Status */
p_vout->p_sys->i_event_thread_status = THREAD_OVER; p_vout->p_sys->i_event_thread_status = THREAD_OVER;
return;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* dvd_ifo.c: Functions for ifo parsing * dvd_ifo.c: Functions for ifo parsing
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: dvd_ifo.c,v 1.34 2001/06/20 07:43:48 sam Exp $ * $Id: dvd_ifo.c,v 1.35 2001/07/25 08:41:21 gbazin Exp $
* *
* Authors: Stphane Borel <stef@via.ecp.fr> * Authors: Stphane Borel <stef@via.ecp.fr>
* German Tischler <tanis@gaspode.franken.de> * German Tischler <tanis@gaspode.franken.de>
...@@ -121,6 +121,7 @@ int IfoInit( ifo_t * p_ifo ) ...@@ -121,6 +121,7 @@ int IfoInit( ifo_t * p_ifo )
/* find the start sector of video information on the dvd */ /* find the start sector of video information on the dvd */
p_ifo->i_start = UDFFindFile( p_ifo->dvdhandle, "/VIDEO_TS/VIDEO_TS.IFO" ); p_ifo->i_start = UDFFindFile( p_ifo->dvdhandle, "/VIDEO_TS/VIDEO_TS.IFO" );
if( !p_ifo->i_start ) return -1;
p_tmp = FillBuffer( p_ifo, p_buf, p_ifo->i_start ); p_tmp = FillBuffer( p_ifo, p_buf, p_ifo->i_start );
//i_start = p_ifo->i_pos; //i_start = p_ifo->i_pos;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vdec_idct.c : common IDCT functions * vdec_idct.c : common IDCT functions
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: vdec_idct.c,v 1.2 2001/07/17 09:48:07 massiot Exp $ * $Id: vdec_idct.c,v 1.3 2001/07/25 08:41:21 gbazin Exp $
* *
* Authors: Gal Hendryckx <jimmy@via.ecp.fr> * Authors: Gal Hendryckx <jimmy@via.ecp.fr>
* *
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
*****************************************************************************/ *****************************************************************************/
#include "defs.h" #include "defs.h"
#include <stdlib.h> /* malloc() */
#include <string.h> /* memcpy(), memset() */ #include <string.h> /* memcpy(), memset() */
#include "config.h" #include "config.h"
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* aout_sdl.c : audio sdl functions library * aout_sdl.c : audio sdl functions library
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: aout_sdl.c,v 1.14 2001/07/12 20:44:52 reno Exp $ * $Id: aout_sdl.c,v 1.15 2001/07/25 08:41:21 gbazin Exp $
* *
* Authors: Michel Kaempf <maxx@via.ecp.fr> * Authors: Michel Kaempf <maxx@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -108,6 +108,7 @@ void _M( aout_getfunctions )( function_list_t * p_function_list ) ...@@ -108,6 +108,7 @@ void _M( aout_getfunctions )( function_list_t * p_function_list )
*****************************************************************************/ *****************************************************************************/
static int aout_Probe( probedata_t *p_data ) static int aout_Probe( probedata_t *p_data )
{ {
#if 0
SDL_AudioSpec desired, obtained; SDL_AudioSpec desired, obtained;
/* Start AudioSDL */ /* Start AudioSDL */
...@@ -135,6 +136,7 @@ static int aout_Probe( probedata_t *p_data ) ...@@ -135,6 +136,7 @@ static int aout_Probe( probedata_t *p_data )
/* Otherwise, there are good chances we can use this plugin, return 100. */ /* Otherwise, there are good chances we can use this plugin, return 100. */
intf_DbgMsg( "aout: SDL_OpenAudio successfully run" ); intf_DbgMsg( "aout: SDL_OpenAudio successfully run" );
SDL_CloseAudio(); SDL_CloseAudio();
#endif
if( TestMethod( AOUT_METHOD_VAR, "sdl" ) ) if( TestMethod( AOUT_METHOD_VAR, "sdl" ) )
{ {
......
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