X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Faudio_output%2Fhd1000a.cpp;h=29481707c72ed01bf51b26ad13ce0d51c96d39ce;hb=12ade3e3bc975d5426ba4af155b7372c31093b31;hp=28a3627cd45e3e2fa589500902774cc52ebff943;hpb=db5fedc62315cfc0f93c0bb1fff76f53627142b8;p=vlc diff --git a/modules/audio_output/hd1000a.cpp b/modules/audio_output/hd1000a.cpp index 28a3627cd4..29481707c7 100644 --- a/modules/audio_output/hd1000a.cpp +++ b/modules/audio_output/hd1000a.cpp @@ -1,7 +1,7 @@ /***************************************************************************** * hd1000a.cpp : Roku HD1000 audio output ***************************************************************************** - * Copyright (C) 2004 VideoLAN + * Copyright (C) 2004 the VideoLAN team * $Id$ * * Author: Jon Lech Johansen @@ -18,7 +18,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ /***************************************************************************** @@ -26,12 +26,13 @@ *****************************************************************************/ extern "C" { -#include -#include -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif -#include -#include +#include +#include +#include #include "aout_internal.h" } @@ -64,21 +65,21 @@ static int Open ( vlc_object_t * ); static void Close ( vlc_object_t * ); static void Play ( aout_instance_t * ); -static int Thread ( aout_instance_t * ); +static void* Thread ( vlc_object_t * ); static void InterleaveS16( int16_t *, int16_t * ); /***************************************************************************** * Module descriptor *****************************************************************************/ -vlc_module_begin(); - set_shortname( "Roku HD1000" ); - set_description( N_("Roku HD1000 audio output") ); - set_capability( "audio output", 100 ); - set_category( CAT_AUDIO ); - set_subcategory( SUBCAT_AUDIO_AOUT ); - set_callbacks( Open, Close ); -vlc_module_end(); +vlc_module_begin () + set_shortname( "Roku HD1000" ) + set_description( N_("Roku HD1000 audio output") ) + set_capability( "audio output", 100 ) + set_category( CAT_AUDIO ) + set_subcategory( SUBCAT_AUDIO_AOUT ) + set_callbacks( Open, Close ) +vlc_module_end () /***************************************************************************** * Open: open a dummy audio device @@ -94,18 +95,14 @@ static int Open( vlc_object_t * p_this ) p_aout->output.p_sys = p_sys = (aout_sys_t *)malloc( sizeof( aout_sys_t ) ); if( p_aout->output.p_sys == NULL ) - { - msg_Err( p_aout, "out of memory" ); - return VLC_EGENERIC; - } + return VLC_ENOMEM; /* New PCMAudioPlayer */ p_sys->pPlayer = pPlayer = new PCMAudioPlayer(); if( p_sys->pPlayer == NULL ) { - msg_Err( p_aout, "out of memory" ); free( p_sys ); - return VLC_EGENERIC; + return VLC_ENOMEM; } /* Get Buffer Requirements */ @@ -117,17 +114,16 @@ static int Open( vlc_object_t * p_this ) delete pPlayer; free( p_sys ); return VLC_EGENERIC; - } + } p_sys->nBuffers = __MIN( p_sys->nBuffers, 4 ); p_sys->ppBuffers = (void **)malloc( p_sys->nBuffers * sizeof( void * ) ); if( p_sys->ppBuffers == NULL ) { - msg_Err( p_aout, "out of memory" ); delete pPlayer; free( p_sys ); - return VLC_EGENERIC; + return VLC_ENOMEM; } /* Open PCMAudioPlayer */ @@ -158,26 +154,26 @@ static int Open( vlc_object_t * p_this ) } } - p_aout->output.output.i_format = AOUT_FMT_S16_NE; + p_aout->output.output.i_format = VLC_CODEC_S16N; p_aout->output.i_nb_samples = FRAME_SIZE; p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT; p_aout->output.pf_play = Play; aout_VolumeSoftInit( p_aout ); - i_volume = config_GetInt( p_aout->p_vlc, "volume" ); + i_volume = config_GetInt( p_aout->p_libvlc, "volume" ); pPlayer->SetVolume( (u32)__MIN( i_volume * 64, 0xFFFF ) ); /* Create thread and wait for its readiness. */ if( vlc_thread_create( p_aout, "aout", Thread, - VLC_THREAD_PRIORITY_OUTPUT, VLC_FALSE ) ) + VLC_THREAD_PRIORITY_OUTPUT ) ) { - msg_Err( p_aout, "cannot create OSS thread (%s)", strerror(errno) ); + msg_Err( p_aout, "cannot create OSS thread (%m)" ); pPlayer->Close(); delete pPlayer; free( p_sys->ppBuffers ); free( p_sys ); - return VLC_ETHREAD; + return VLC_ENOMEM; } return VLC_SUCCESS; @@ -192,9 +188,9 @@ static void Close( vlc_object_t * p_this ) aout_instance_t * p_aout = (aout_instance_t *)p_this; struct aout_sys_t * p_sys = p_aout->output.p_sys; - p_aout->b_die = VLC_TRUE; + vlc_object_kill( p_aout ); vlc_thread_join( p_aout ); - p_aout->b_die = VLC_FALSE; + p_aout->b_die = false; do { @@ -218,13 +214,15 @@ static void Play( aout_instance_t * p_aout ) /***************************************************************************** * Thread: thread used to DMA the data to the device *****************************************************************************/ -static int Thread( aout_instance_t * p_aout ) +static void* Thread( vlc_object_t *p_this ) { + aout_instance_t * p_aout = (aout_instance_t*)p_this; aout_buffer_t * p_buffer; struct aout_sys_t * p_sys = p_aout->output.p_sys; PCMAudioPlayer * pPlayer = p_sys->pPlayer; + int canc = vlc_savecancel (); - while( !p_aout->b_die ) + while( vlc_object_alive (p_aout) ) { pPlayer->WaitForBuffer(); @@ -235,8 +233,8 @@ static int Thread( aout_instance_t * p_aout ) #define i p_sys->nNextBufferIndex if( p_buffer == NULL ) { - p_aout->p_vlc->pf_memset( p_sys->ppBuffers[ i ], 0, - p_sys->nBufferSize ); + vlc_memset( p_aout, p_sys->ppBuffers[ i ], 0, + p_sys->nBufferSize ); } else { @@ -249,13 +247,14 @@ static int Thread( aout_instance_t * p_aout ) p_sys->nBufferSize / 2 ) ) { msg_Err( p_aout, "QueueBuffer failed" ); - } + } i = (i + 1) % p_sys->nBuffers; #undef i } - return VLC_SUCCESS; + vlc_restorecancel (canc); + return NULL; } /*****************************************************************************