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
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
* 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>
*
/* 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 */
* 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>
*
/* 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;
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 );
}
*****************************************************************************/
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 );
}
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)
}
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
}
}
* 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>
*
}
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) */
{
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)) )
{