Commit cc5919ad authored by Gildas Bazin's avatar Gildas Bazin

* src/misc/modules.c: fixed a memory leak with the "plugin-path" config option.
* modules/audio_output/directx.c, modules/audio_output/waveout.c: ported the directx
   and waveout audio plugins to the new changes in the audio output layer.
* configure.ac.in: fixes for cygwin compilation, and the gtk plugin under mingw32.
parent c5bd872c
......@@ -1726,8 +1726,13 @@ then
then
AC_MSG_ERROR([Your development package for Gtk+ is too old, you need at least version 1.2.0. Please upgrade and try again. Alternatively you can also configure with --disable-gtk.])
fi
CFLAGS_gtk="${CFLAGS_gtk} `${GTK_CONFIG} --cflags gtk gthread`"
LDFLAGS_gtk="${LDFLAGS_gtk} `${GTK_CONFIG} --libs gtk gthread | sed 's,-rdynamic,,'`"
if test "x${SYS}" != "xmingw32"; then
CFLAGS_gtk="${CFLAGS_gtk} `${GTK_CONFIG} --cflags gtk gthread`"
LDFLAGS_gtk="${LDFLAGS_gtk} `${GTK_CONFIG} --libs gtk gthread | sed 's,-rdynamic,,'`"
else
CFLAGS_gtk="${CFLAGS_gtk} `${GTK_CONFIG} --cflags gtk`"
LDFLAGS_gtk="${LDFLAGS_gtk} `${GTK_CONFIG} --libs gtk | sed 's,-rdynamic,,'`"
fi
# now look for the gtk.h header
CPPFLAGS="${CPPFLAGS_save} ${CFLAGS_gtk}"
ac_cv_gtk_headers=yes
......@@ -2070,8 +2075,10 @@ AC_ARG_ENABLE(st,
fi])
])
LDFLAGS_vlc="${LDFLAGS_vlc} ${THREAD_LIB}"
LDFLAGS_plugins="${LDFLAGS_plugins} ${THREAD_LIB}"
if test "x${SYS}" != "xmingw32"; then
LDFLAGS_vlc="${LDFLAGS_vlc} ${THREAD_LIB}"
LDFLAGS_plugins="${LDFLAGS_plugins} ${THREAD_LIB}"
fi
dnl
dnl Mozilla plugin
......
......@@ -2,7 +2,7 @@
* aout.c: Windows DirectX audio output method
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: directx.c,v 1.2 2002/10/06 19:28:28 gbazin Exp $
* $Id: directx.c,v 1.3 2002/10/11 10:08:06 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -179,13 +179,6 @@ static int OpenAudio( vlc_object_t *p_this )
vlc_mutex_lock( &p_aout->output.p_sys->buffer_lock );
/* first release the current secondary buffer */
DirectxDestroySecondaryBuffer( p_aout );
/* calculate the frame size in bytes */
p_aout->output.p_sys->p_notif->i_buffer_size = FRAME_SIZE * sizeof(s16)
* p_aout->output.output.i_channels;
/* then create a new secondary buffer */
if( DirectxCreateSecondaryBuffer( p_aout ) )
{
......@@ -363,26 +356,29 @@ static int DirectxCreateSecondaryBuffer( aout_instance_t *p_aout )
DSBUFFERDESC dsbdesc;
DSBCAPS dsbcaps;
if( p_aout->output.output.i_channels > 2 )
p_aout->output.output.i_channels = 2;
/* First set the buffer format */
memset(&waveformat, 0, sizeof(WAVEFORMATEX));
waveformat.wFormatTag = WAVE_FORMAT_PCM;
memset(&waveformat, 0, sizeof(WAVEFORMATEX));
waveformat.wFormatTag = WAVE_FORMAT_PCM;
waveformat.nChannels = p_aout->output.output.i_channels;
waveformat.nSamplesPerSec = p_aout->output.output.i_rate;
waveformat.wBitsPerSample = 16;
waveformat.nSamplesPerSec = p_aout->output.output.i_rate;
waveformat.wBitsPerSample = 16;
waveformat.nBlockAlign = waveformat.wBitsPerSample / 8 *
waveformat.nChannels;
waveformat.nAvgBytesPerSec = waveformat.nSamplesPerSec *
waveformat.nBlockAlign;
/* Then fill in the descriptor */
memset(&dsbdesc, 0, sizeof(DSBUFFERDESC));
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
memset(&dsbdesc, 0, sizeof(DSBUFFERDESC));
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
dsbdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2/* Better position accuracy */
| DSBCAPS_CTRLPOSITIONNOTIFY /* We need notification */
| DSBCAPS_GLOBALFOCUS; /* Allows background playing */
dsbdesc.dwBufferBytes = FRAME_SIZE * 2 /* frames*/ * /* buffer size */
sizeof(s16) * p_aout->output.output.i_channels;
dsbdesc.lpwfxFormat = &waveformat;
dsbdesc.lpwfxFormat = &waveformat;
if( IDirectSound_CreateSoundBuffer( p_aout->output.p_sys->p_dsobject,
&dsbdesc,
......@@ -393,12 +389,15 @@ static int DirectxCreateSecondaryBuffer( aout_instance_t *p_aout )
goto error;
}
/* backup the size of the secondary sound buffer */
memset(&dsbcaps, 0, sizeof(DSBCAPS));
/* backup the size of a frame */
p_aout->output.p_sys->p_notif->i_buffer_size = FRAME_SIZE * sizeof(s16)
* p_aout->output.output.i_channels;
memset(&dsbcaps, 0, sizeof(DSBCAPS));
dsbcaps.dwSize = sizeof(DSBCAPS);
IDirectSoundBuffer_GetCaps( p_aout->output.p_sys->p_dsbuffer, &dsbcaps );
msg_Dbg( p_aout, "DirectxCreateSecondaryBuffer: %li",
msg_Dbg( p_aout, "requested %li bytes buffer and got %li bytes.",
2 * p_aout->output.p_sys->p_notif->i_buffer_size,
dsbcaps.dwBufferBytes );
/* Now the secondary buffer is created, we need to setup its position
......@@ -413,7 +412,7 @@ static int DirectxCreateSecondaryBuffer( aout_instance_t *p_aout )
&IID_IDirectSoundNotify,
(LPVOID *)&p_aout->output.p_sys->p_dsnotify ) )
{
msg_Warn( p_aout, "cannot get Notify interface" );
msg_Err( p_aout, "cannot get Notify interface" );
goto error;
}
......@@ -421,10 +420,9 @@ static int DirectxCreateSecondaryBuffer( aout_instance_t *p_aout )
p_aout->output.p_sys->p_dsnotify, 2,
p_aout->output.p_sys->p_notif->p_events ) )
{
msg_Warn( p_aout, "cannot set position Notification" );
msg_Err( p_aout, "cannot set position Notification" );
goto error;
}
p_aout->output.output.i_format = AOUT_FMT_S16_NE;
p_aout->output.i_nb_samples = FRAME_SIZE;
......@@ -486,13 +484,6 @@ static void DirectSoundThread( notification_thread_t *p_notif )
/* Tell the main thread that we are ready */
vlc_thread_ready( p_notif );
/* this thread must be high-priority */
if( !SetThreadPriority( GetCurrentThread(),
THREAD_PRIORITY_ABOVE_NORMAL ) )
{
msg_Warn( p_notif, "DirectSoundThread could not raise its priority" );
}
msg_Dbg( p_notif, "DirectSoundThread ready" );
while( !p_notif->b_die )
......@@ -546,8 +537,10 @@ static void DirectSoundThread( notification_thread_t *p_notif )
continue;
}
/* FIXME : take into account DirectSound latency instead of mdate() */
p_buffer = aout_OutputNextBuffer( p_aout, mdate(), VLC_FALSE );
/* We also take into account the latency instead of just mdate() */
p_buffer = aout_OutputNextBuffer( p_aout,
mdate() + 1000000 / p_aout->output.output.i_rate * FRAME_SIZE,
VLC_FALSE );
/* Now do the actual memcpy into the circular buffer */
if ( l_bytes1 != p_notif->i_buffer_size )
......
......@@ -2,7 +2,7 @@
* waveout.c : Windows waveOut plugin for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: waveout.c,v 1.7 2002/09/18 21:21:23 massiot Exp $
* $Id: waveout.c,v 1.8 2002/10/11 10:08:06 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -34,6 +34,7 @@
#include <vlc/aout.h>
#include "aout_internal.h"
#include <windows.h>
#include <mmsystem.h>
#define FRAME_SIZE 2048 /* The size is in samples, not in bytes */
......@@ -90,6 +91,7 @@ struct aout_sys_t
static int Open( vlc_object_t *p_this )
{
aout_instance_t *p_aout = (aout_instance_t *)p_this;
aout_buffer_t *p_buffer;
/* Allocate structure */
p_aout->output.p_sys = malloc( sizeof( aout_sys_t ) );
......@@ -103,6 +105,37 @@ static int Open( vlc_object_t *p_this )
p_aout->output.pf_play = Play;
aout_VolumeSoftInit( p_aout );
/* FIXME */
if ( p_aout->output.output.i_channels > 2 )
{
msg_Warn( p_aout, "only two channels are supported at the moment" );
/* Trigger downmixing */
p_aout->output.output.i_channels = 2;
}
/* We need to open the device with default values to be sure it is
* available */
if ( OpenWaveOut( p_aout, WAVE_FORMAT_PCM,
p_aout->output.output.i_channels,
p_aout->output.output.i_rate ) )
{
msg_Err( p_aout, "cannot open waveout audio device with output "
"rate (%i)",
p_aout->output.output.i_rate );
return 1;
if ( OpenWaveOut( p_aout, WAVE_FORMAT_PCM,
p_aout->output.output.i_channels,
44100 ) )
{
msg_Err( p_aout, "cannot open waveout audio device with output "
"rate (44100)" );
return 1;
}
}
waveOutReset( p_aout->output.p_sys->h_waveout );
/* calculate the frame size in bytes */
p_aout->output.p_sys->i_buffer_size = FRAME_SIZE * sizeof(s16)
* p_aout->output.p_sys->waveformat.nChannels;
......@@ -115,16 +148,6 @@ static int Open( vlc_object_t *p_this )
return 1;
}
/* We need to open the device with default values to be sure it is
* available */
if ( OpenWaveOut( p_aout, WAVE_FORMAT_PCM, 2, 44100 ) )
{
msg_Err( p_aout, "cannot open waveout" );
return 1;
}
waveOutReset( p_aout->output.p_sys->h_waveout );
p_aout->output.output.i_format = AOUT_FMT_S16_NE;
p_aout->output.i_nb_samples = FRAME_SIZE;
......@@ -132,8 +155,12 @@ static int Open( vlc_object_t *p_this )
* working */
PlayWaveOut( p_aout, p_aout->output.p_sys->h_waveout,
&p_aout->output.p_sys->waveheader[0], NULL );
p_buffer = aout_OutputNextBuffer( p_aout,
mdate() + 1000000 / p_aout->output.output.i_rate * FRAME_SIZE,
VLC_FALSE );
PlayWaveOut( p_aout, p_aout->output.p_sys->h_waveout,
&p_aout->output.p_sys->waveheader[1], NULL );
&p_aout->output.p_sys->waveheader[1], p_buffer );
return 0;
}
......@@ -256,9 +283,9 @@ static void CALLBACK WaveOutCallback( HWAVEOUT h_waveout, UINT uMsg,
DWORD _p_aout,
DWORD dwParam1, DWORD dwParam2 )
{
aout_instance_t * p_aout = (aout_instance_t *)_p_aout;
aout_instance_t *p_aout = (aout_instance_t *)_p_aout;
WAVEHDR *p_waveheader = (WAVEHDR *)dwParam1;
aout_buffer_t * p_buffer;
aout_buffer_t *p_buffer;
if( uMsg != WOM_DONE ) return;
......@@ -267,8 +294,10 @@ static void CALLBACK WaveOutCallback( HWAVEOUT h_waveout, UINT uMsg,
if( p_waveheader->dwUser )
aout_BufferFree( (aout_buffer_t *)p_waveheader->dwUser );
/* FIXME : take into account WaveOut latency instead of mdate() */
p_buffer = aout_OutputNextBuffer( p_aout, mdate(), VLC_FALSE );
/* Take into account WaveOut latency instead of just mdate() */
p_buffer = aout_OutputNextBuffer( p_aout,
mdate() + 1000000 / p_aout->output.output.i_rate * FRAME_SIZE,
VLC_FALSE );
PlayWaveOut( p_aout, h_waveout, p_waveheader, p_buffer );
}
......@@ -2,7 +2,7 @@
* modules.c : Builtin and plugin modules management functions
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: modules.c,v 1.96 2002/10/08 18:10:10 sam Exp $
* $Id: modules.c,v 1.97 2002/10/11 10:08:06 gbazin Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Ethan C. Baldridge <BaldridgeE@cadmus.com>
......@@ -580,6 +580,10 @@ static void AllocateAllPlugins( vlc_object_t *p_this )
}
#endif
}
/* Free plugin-path */
free( path[ sizeof(path)/sizeof(char*) - 2 ] );
path[ sizeof(path)/sizeof(char*) - 2 ] = NULL;
}
/*****************************************************************************
......
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