/*****************************************************************************
* aout_u8.c: 8 bit unsigned audio output functions
*****************************************************************************
- * Copyright (C) 1999, 2000, 2001 VideoLAN
+ * Copyright (C) 1999-2001 VideoLAN
+ * $Id: aout_u8.c,v 1.9 2001/12/07 18:33:08 sam Exp $
*
* Authors: Michel Kaempf <maxx@via.ecp.fr>
*
#include <stdio.h> /* "intf_msg.h" */
#include <stdlib.h> /* calloc(), malloc(), free() */
+#include <string.h>
-#include "config.h"
#include "common.h"
+#include "intf_msg.h" /* intf_DbgMsg(), intf_ErrMsg() */
#include "threads.h"
#include "mtime.h" /* mtime_t, mdate(), msleep() */
-#include "intf_msg.h" /* intf_DbgMsg(), intf_ErrMsg() */
-
#include "audio_output.h"
#include "aout_common.h"
for ( l_buffer = 0; l_buffer < l_buffer_limit; l_buffer++ )
{
- ((u8 *)p_aout->buffer)[l_buffer] = (u8)( ( (p_aout->s32_buffer[l_buffer] / AOUT_MAX_FIFOS / 256 ) + 128 ) * p_aout->vol / 256 );
+ ((u8 *)p_aout->buffer)[l_buffer] = (u8)( ( (p_aout->s32_buffer[l_buffer] / AOUT_MAX_FIFOS / 256 ) + 128 ) * p_aout->i_volume / 256 );
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 / 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_main->i_desync;
+
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) */
{
int i_fifo;
long l_buffer, l_buffer_limit, l_bytes;
- intf_DbgMsg("adec debug: running audio output U8_S_thread (%p) (pid == %i)", p_aout, getpid());
-
/* As the s32_buffer was created with calloc(), we don't have to set this
* memory to zero and we can immediately jump into the thread's loop */
while ( ! p_aout->b_die )
for ( l_buffer = 0; l_buffer < l_buffer_limit; l_buffer++ )
{
- ((u8 *)p_aout->buffer)[l_buffer] = (u8)( ( (p_aout->s32_buffer[l_buffer] / AOUT_MAX_FIFOS / 256) + 128 ) * p_aout->vol / 256 );
+ ((u8 *)p_aout->buffer)[l_buffer] = (u8)( ( (p_aout->s32_buffer[l_buffer] / AOUT_MAX_FIFOS / 256) + 128 ) * p_aout->i_volume / 256 );
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_main->i_desync;
+
p_aout->pf_play( p_aout, (byte_t *)p_aout->buffer, l_buffer_limit * sizeof(u8) );
if ( l_bytes > (l_buffer_limit * sizeof(u8)) )
{