Commit a25f41cb authored by Renaud Dartus's avatar Renaud Dartus

* Fix audio/video synchro bug with esd

* Should fix buggy sound due to 44100-48000 Hz conversions
parent 23b4e9ba
......@@ -103,7 +103,7 @@ Urgency: Critical
Description: Fix AC3 decoder
The AC3 decoder still has a few quality issues; fix them, and try to add
MMX support to it as well.
Status: Todo
Status: Done 15 June 2001 (reno)
Task: 0x52
Difficulty: Guru
......@@ -193,7 +193,7 @@ Urgency: Critical
Description: Fix audio synchro
With some audio plugins, the audio stream is late because of buffer
sizes. See what's wrong and fix it.
Status: Todo
Status: Done 12 July 2001 (reno)
Task: 0x47
Difficulty: Hard
......
......@@ -2,7 +2,7 @@
* audio_output.h : audio output thread interface
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: audio_output.h,v 1.37 2001/05/30 17:03:11 sam Exp $
* $Id: audio_output.h,v 1.38 2001/07/12 20:31:33 reno Exp $
*
* Authors: Michel Kaempf <maxx@via.ecp.fr>
*
......@@ -171,6 +171,7 @@ typedef struct aout_thread_s
/* Rate and gain of the audio output sound (in Hz) */
long l_rate;
long l_gain;
int i_latency;
/* there might be some useful private structure, such as audio_buf_info
* for the OSS output */
......
......@@ -2,7 +2,7 @@
* aout_esd.c : Esound functions library
*****************************************************************************
* Copyright (C) 2000 VideoLAN
* $Id: aout_esd.c,v 1.13 2001/05/30 17:03:12 sam Exp $
* $Id: aout_esd.c,v 1.14 2001/07/12 20:31:33 reno Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -134,7 +134,7 @@ static int aout_Open( aout_thread_t *p_aout )
/* Initialize some variables */
p_aout->i_format = AOUT_FORMAT_DEFAULT;
p_aout->i_channels = 1 + main_GetIntVariable( AOUT_STEREO_VAR, AOUT_STEREO_DEFAULT );
p_aout->l_rate = main_GetIntVariable( AOUT_RATE_VAR, AOUT_RATE_DEFAULT );
p_aout->l_rate = esd_audio_rate; /* We use actual esd rate value, not AOUT_RATE_DEFAULT */
i_bits = ESD_BITS16;
i_mode = ESD_STREAM;
......@@ -162,10 +162,6 @@ static int aout_Open( aout_thread_t *p_aout )
return( -1 );
}
intf_ErrMsg( "aout error: you are using the Esound plugin. There is no way yet to get the\n"
" driver latency because esd_get_latency() hangs, so expect a one\n"
" second delay with sound. Type `esdctl off' to disable esd." );
return( 0 );
}
......@@ -174,6 +170,13 @@ static int aout_Open( aout_thread_t *p_aout )
*****************************************************************************/
static int aout_SetFormat( aout_thread_t *p_aout )
{
int i_fd;
i_fd = esd_open_sound(NULL);
p_aout->i_latency = esd_get_latency(i_fd);
intf_WarnMsg(2, "aout_esd_latency: %d",p_aout->i_latency);
return( 0 );
}
......@@ -194,7 +197,7 @@ static long aout_GetBufInfo( aout_thread_t *p_aout, long l_buffer_limit )
static void aout_Play( aout_thread_t *p_aout, byte_t *buffer, int i_size )
{
int i_amount;
if (p_aout->p_sys->esd_format & ESD_STEREO)
{
if (p_aout->p_sys->esd_format & ESD_BITS16)
......
......@@ -87,37 +87,16 @@ void aout_S16StereoThread( aout_thread_t * p_aout )
}
l_bytes = p_aout->pf_getbufinfo( p_aout, l_buffer_limit );
#if 0
fprintf(stderr,"l_bytes 1: %li\n",l_bytes);
fprintf(stderr," playing...\n");
#endif
/* sizeof(s16) << (p_aout->b_stereo) == 4 */
p_aout->date = mdate() + ((((mtime_t)(l_bytes / 4)) * 1000000)
p_aout->date = mdate() + ((((mtime_t)((l_bytes + 4 * p_aout->i_latency) / 4)) * 1000000)
/ ((mtime_t)p_aout->l_rate));
p_aout->pf_play( p_aout, (byte_t *)p_aout->buffer,
l_buffer_limit * sizeof(s16) );
#if 0
fprintf( stderr,"l_bytes #: %li\n",
p_aout->pf_getbufinfo( p_aout, l_buffer_limit ) );
#endif
if ( l_bytes > (l_buffer_limit * sizeof(s16)) )
{
msleep( p_aout->l_msleep );
#if 0
fprintf(stderr," sleeping...\n");
msleep( p_aout->l_msleep / 2);
l_bytes = p_aout->pf_getbufinfo( p_aout, l_buffer_limit );
fprintf(stderr,"l_bytes *: %li\n",l_bytes);
msleep( p_aout->l_msleep / 2);
}
else
{
fprintf(stderr," not sleeping.\n");
l_bytes = p_aout->pf_getbufinfo( p_aout, l_buffer_limit );
fprintf(stderr,"l_bytes 2: %li\n\n",l_bytes);
#endif
}
}
......
......@@ -2,7 +2,7 @@
* aout_u8.c: 8 bit unsigned audio output functions
*****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: aout_u8.c,v 1.5 2001/05/15 16:19:42 sam Exp $
* $Id: aout_u8.c,v 1.6 2001/07/12 20:31:33 reno Exp $
*
* Authors: Michel Kaempf <maxx@via.ecp.fr>
*
......@@ -82,7 +82,10 @@ void aout_U8MonoThread( aout_thread_t * p_aout )
}
l_bytes = p_aout->pf_getbufinfo( p_aout, l_buffer_limit );
p_aout->date = mdate() + ((((mtime_t)(l_bytes / 1 )) * 1000000) / ((mtime_t)p_aout->l_rate)); /* sizeof(u8) << (p_aout->b_stereo) == 1 */
/* sizeof(u8) << (p_aout->b_stereo) == 1 */
p_aout->date = mdate() + ((((mtime_t)((l_bytes + 4 * p_aout->i_latency) / 1)) * 1000000)
/ ((mtime_t)p_aout->l_rate));
p_aout->pf_play( p_aout, (byte_t *)p_aout->buffer, l_buffer_limit * sizeof(u8) );
if ( l_bytes > (l_buffer_limit * sizeof(u8) * 2) ) /* There are 2 channels (left & right) */
{
......@@ -133,7 +136,10 @@ void aout_U8StereoThread( aout_thread_t * p_aout )
p_aout->s32_buffer[l_buffer] = 0;
}
l_bytes = p_aout->pf_getbufinfo( p_aout, l_buffer_limit );
p_aout->date = mdate() + ((((mtime_t)(l_bytes / 2 )) * 1000000) / ((mtime_t)p_aout->l_rate)); /* sizeof(u8) << (p_aout->b_stereo) == 2 */
/* sizeof(u8) << (p_aout->b_stereo) == 2 */
p_aout->date = mdate() + ((((mtime_t)((l_bytes + 4 * p_aout->i_latency) / 2)) * 1000000)
/ ((mtime_t)p_aout->l_rate));
p_aout->pf_play( p_aout, (byte_t *)p_aout->buffer, l_buffer_limit * sizeof(u8) );
if ( l_bytes > (l_buffer_limit * sizeof(u8)) )
{
......
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