Commit 5e9d8674 authored by Eric Petit's avatar Eric Petit

Now BeOS sound is (almost) clean.

It is kludgy, but it works ;)
parent af3a25f5
......@@ -2,7 +2,7 @@
* aout.cpp: BeOS audio output
*****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: AudioOutput.cpp,v 1.10 2002/10/12 12:24:52 titer Exp $
* $Id: AudioOutput.cpp,v 1.11 2002/10/13 15:39:16 titer Exp $
*
* Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -37,6 +37,8 @@
#include <vlc/aout.h>
#include "aout_internal.h"
#define FRAME_SIZE 2048
/*****************************************************************************
* aout_sys_t: BeOS audio output method descriptor
*****************************************************************************/
......@@ -45,11 +47,9 @@ typedef struct aout_sys_t
{
BSoundPlayer *p_player;
float *p_buffer;
size_t i_buffer_size;
int i_got_data;
} aout_sys_t;
#define FRAME_SIZE 2048
/*****************************************************************************
* Local prototypes.
*****************************************************************************/
......@@ -66,8 +66,8 @@ int E_(OpenAudio) ( vlc_object_t * p_this )
p_aout->output.p_sys = (aout_sys_t *) malloc( sizeof( aout_sys_t ) );
aout_sys_t *p_sys = p_aout->output.p_sys;
p_sys->i_buffer_size = 0;
p_sys->p_buffer = NULL;
p_sys->i_got_data = 0;
p_sys->p_buffer = (float*) malloc( 16384 ); /*FIXME*/
aout_VolumeSoftInit( p_aout );
......@@ -109,41 +109,33 @@ static void Play( void *aout, void *buffer, size_t size,
aout_sys_t *p_sys = p_aout->output.p_sys;
float *p_buffer = (float*) buffer;
if( format.format != media_raw_audio_format::B_AUDIO_FLOAT )
/* <kludge> */
/* Usually BSoundPlay asks for 8192 bytes buffers, while vlc gives
a 16384 one. So we keep the second half of it in p_sys->p_buffer */
if( p_sys->i_got_data )
{
msg_Err( p_aout, "Bad audio format" );
return;
memcpy( p_buffer, p_sys->p_buffer, 8192 );
p_sys->i_got_data = 0;
}
if( p_sys->i_buffer_size < size )
else
{
p_aout_buffer = aout_FifoPop( p_aout, &p_aout->output.fifo );
if( p_aout_buffer != NULL )
{
if( p_sys->p_buffer == NULL )
{
p_sys->p_buffer = (float*)malloc( p_aout_buffer->i_nb_bytes );
p_sys->i_buffer_size = p_aout_buffer->i_nb_bytes;
}
else
{
realloc( p_sys->p_buffer,
p_sys->i_buffer_size + p_aout_buffer->i_nb_bytes );
memcpy( p_sys->p_buffer + p_sys->i_buffer_size,
p_aout_buffer->p_buffer,
p_aout_buffer->i_nb_bytes );
p_sys->i_buffer_size += p_aout_buffer->i_nb_bytes;
}
memcpy( p_buffer,
p_aout_buffer->p_buffer,
8192 );
memcpy( p_sys->p_buffer,
p_aout_buffer->p_buffer + 8192,
8192 );
p_sys->i_got_data = 1;
}
}
if( p_sys->i_buffer_size >= size )
{
memcpy( p_buffer, p_sys->p_buffer,
MIN( size, p_sys->i_buffer_size ) );
p_sys->i_buffer_size -= MIN( size, p_sys->i_buffer_size );
}
/* </kludge> */
}
/*****************************************************************************
......
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