Commit 4edd2384 authored by Gildas Bazin's avatar Gildas Bazin

* modules/audio_output/oss.c: Finally fixed! There also is a new config option
   (--oss-buggy) to work-around buggy oss drivers.
parent b25a28ba
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* oss.c : OSS /dev/dsp module for vlc * oss.c : OSS /dev/dsp module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2002 VideoLAN * Copyright (C) 2000-2002 VideoLAN
* $Id: oss.c,v 1.30 2002/10/20 12:23:47 massiot Exp $ * $Id: oss.c,v 1.31 2002/10/24 17:36:42 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>
...@@ -61,7 +61,8 @@ ...@@ -61,7 +61,8 @@
*****************************************************************************/ *****************************************************************************/
struct aout_sys_t struct aout_sys_t
{ {
int i_fd; int i_fd;
int b_workaround_buggy_driver;
}; };
/* This must be a power of 2. */ /* This must be a power of 2. */
...@@ -69,6 +70,10 @@ struct aout_sys_t ...@@ -69,6 +70,10 @@ struct aout_sys_t
#define FRAME_COUNT 8 #define FRAME_COUNT 8
#define A52_FRAME_NB 1536 #define A52_FRAME_NB 1536
/* estimation of the size of the internal soundcard driver
* (used for buggy drivers) */
#define OSS_BUFFER_SIZE 20000
/***************************************************************************** /*****************************************************************************
* Local prototypes * Local prototypes
*****************************************************************************/ *****************************************************************************/
...@@ -81,10 +86,17 @@ static int OSSThread ( aout_instance_t * ); ...@@ -81,10 +86,17 @@ static int OSSThread ( aout_instance_t * );
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
*****************************************************************************/ *****************************************************************************/
#define BUGGY_TEXT N_("Try to work around buggy OSS drivers")
#define BUGGY_LONGTEXT N_( \
"Some buggy OSS drivers just don't like when their internal buffers " \
"are completely filled (the sound gets heavily hashed). If you have one " \
"of these drivers, then you need to enable this option." )
vlc_module_begin(); vlc_module_begin();
add_category_hint( N_("OSS"), NULL ); add_category_hint( N_("OSS"), NULL );
add_file( "dspdev", "/dev/dsp", aout_FindAndRestart, add_file( "dspdev", "/dev/dsp", aout_FindAndRestart,
N_("OSS dsp device"), NULL ); N_("OSS dsp device"), NULL );
add_bool( "oss-buggy", 0, NULL, BUGGY_TEXT, BUGGY_LONGTEXT );
set_description( _("Linux OSS /dev/dsp module") ); set_description( _("Linux OSS /dev/dsp module") );
set_capability( "audio output", 100 ); set_capability( "audio output", 100 );
add_shortcut( "oss" ); add_shortcut( "oss" );
...@@ -119,8 +131,16 @@ static int Open( vlc_object_t *p_this ) ...@@ -119,8 +131,16 @@ static int Open( vlc_object_t *p_this )
return VLC_EGENERIC; return VLC_EGENERIC;
} }
p_aout->output.p_sys->b_workaround_buggy_driver =
config_GetInt( p_aout, "oss-buggy" );
if( p_aout->output.p_sys->b_workaround_buggy_driver )
p_sys->i_fd = open( psz_device, O_WRONLY|O_NONBLOCK );
else
p_sys->i_fd = open( psz_device, O_WRONLY );
/* Open the sound device */ /* Open the sound device */
if( (p_sys->i_fd = open( psz_device, O_WRONLY )) < 0 ) if( p_sys->i_fd < 0 )
{ {
msg_Err( p_aout, "cannot open audio device (%s)", psz_device ); msg_Err( p_aout, "cannot open audio device (%s)", psz_device );
free( psz_device ); free( psz_device );
...@@ -421,11 +441,14 @@ static int OSSThread( aout_instance_t * p_aout ) ...@@ -421,11 +441,14 @@ static int OSSThread( aout_instance_t * p_aout )
{ {
mtime_t buffered = BufferDuration( p_aout ); mtime_t buffered = BufferDuration( p_aout );
/* Wait a bit - we don't want our buffer to be full */ if( p_aout->output.p_sys->b_workaround_buggy_driver )
while( buffered > AOUT_PTS_TOLERANCE * 2 )
{ {
msleep( buffered / 2 - 10000 ); /* Wait a bit - we don't want our buffer to be full */
buffered = BufferDuration( p_aout ); while( buffered > OSS_BUFFER_SIZE )
{
msleep( buffered - OSS_BUFFER_SIZE * 2 );
buffered = BufferDuration( p_aout );
}
} }
if( !next_date ) if( !next_date )
......
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