X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Faudio_output%2Fsdl.c;h=3e98609e4eb3ef0db5ba486d8933fd4d7206fea7;hb=a418e6d37987a4f7508d0d3c945c5948e1af555f;hp=2bff198612338c1faa6550ecc2a93ceaf363b857;hpb=4e82695c13b55286973d454ca7c23e3389cee006;p=vlc diff --git a/modules/audio_output/sdl.c b/modules/audio_output/sdl.c index 2bff198612..3e98609e4e 100644 --- a/modules/audio_output/sdl.c +++ b/modules/audio_output/sdl.c @@ -1,19 +1,19 @@ /***************************************************************************** * sdl.c : SDL audio output plugin for vlc ***************************************************************************** - * Copyright (C) 2000-2002 VideoLAN - * $Id: sdl.c,v 1.20 2003/01/13 16:58:58 massiot Exp $ + * Copyright (C) 2000-2002 the VideoLAN team + * $Id$ * * Authors: Michel Kaempf - * Samuel Hocevar + * Sam Hocevar * Pierre Baillet * Christophe Massiot - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -21,21 +21,20 @@ * * 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. *****************************************************************************/ /***************************************************************************** * Preamble *****************************************************************************/ -#include /* ENOMEM */ -#include /* open(), O_WRONLY */ -#include /* strerror() */ #include /* write(), close() */ -#include /* calloc(), malloc(), free() */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif #include -#include -#include "aout_internal.h" +#include #include SDL_INCLUDE_FILE @@ -48,7 +47,7 @@ * It describes the specific properties of an audio device. *****************************************************************************/ struct aout_sys_t -{ +{ mtime_t next_date; mtime_t buffer_time; }; @@ -65,8 +64,11 @@ static void SDLCallback ( void *, byte_t *, int ); * Module descriptor *****************************************************************************/ vlc_module_begin(); - set_description( _("Simple DirectMedia Layer audio module") ); + set_shortname( "SDL" ); + set_description( _("Simple DirectMedia Layer audio output") ); set_capability( "audio output", 40 ); + set_category( CAT_AUDIO ); + set_subcategory( SUBCAT_AUDIO_AOUT ); add_shortcut( "sdl" ); set_callbacks( Open, Close ); vlc_module_end(); @@ -79,10 +81,10 @@ static int Open ( vlc_object_t *p_this ) aout_instance_t *p_aout = (aout_instance_t *)p_this; SDL_AudioSpec desired, obtained; int i_nb_channels; - vlc_value_t val; + vlc_value_t val, text; /* Check that no one uses the DSP. */ - Uint32 i_flags = SDL_INIT_AUDIO; + uint32_t i_flags = SDL_INIT_AUDIO; if( SDL_WasInit( i_flags ) ) { return VLC_EGENERIC; @@ -105,22 +107,20 @@ static int Open ( vlc_object_t *p_this ) return VLC_EGENERIC; } - if ( var_Type( p_aout, "audio-device" ) == - (VLC_VAR_STRING | VLC_VAR_HASCHOICE) ) + if ( var_Type( p_aout, "audio-device" ) != 0 ) { /* The user has selected an audio device. */ vlc_value_t val; var_Get( p_aout, "audio-device", &val ); - if ( !strcmp( val.psz_string, N_("Stereo") ) ) + if ( val.i_int == AOUT_VAR_STEREO ) { p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT; } - else if ( !strcmp( val.psz_string, N_("Mono") ) ) + else if ( val.i_int == AOUT_VAR_MONO ) { p_aout->output.output.i_physical_channels = AOUT_CHAN_CENTER; } - free( val.psz_string ); } i_nb_channels = aout_FormatNbChannels( &p_aout->output.output ); @@ -173,10 +173,17 @@ static int Open ( vlc_object_t *p_this ) if ( var_Type( p_aout, "audio-device" ) == 0 ) { - var_Create( p_aout, "audio-device", VLC_VAR_STRING | VLC_VAR_HASCHOICE ); - val.psz_string = (obtained.channels == 2) ? N_("Stereo") : + var_Create( p_aout, "audio-device", + VLC_VAR_INTEGER | VLC_VAR_HASCHOICE ); + text.psz_string = _("Audio Device"); + var_Change( p_aout, "audio-device", VLC_VAR_SETTEXT, &text, NULL ); + + val.i_int = (obtained.channels == 2) ? AOUT_VAR_STEREO : + AOUT_VAR_MONO; + text.psz_string = (obtained.channels == 2) ? N_("Stereo") : N_("Mono"); - var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val ); + var_Change( p_aout, "audio-device", + VLC_VAR_ADDCHOICE, &val, &text ); var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL ); } @@ -184,22 +191,27 @@ static int Open ( vlc_object_t *p_this ) else if ( var_Type( p_aout, "audio-device" ) == 0 ) { /* First launch. */ - var_Create( p_aout, "audio-device", VLC_VAR_STRING | VLC_VAR_HASCHOICE ); - val.psz_string = N_("Stereo"); - var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val ); - val.psz_string = N_("Mono"); - var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val ); + var_Create( p_aout, "audio-device", + VLC_VAR_INTEGER | VLC_VAR_HASCHOICE ); + text.psz_string = _("Audio Device"); + var_Change( p_aout, "audio-device", VLC_VAR_SETTEXT, &text, NULL ); + + val.i_int = AOUT_VAR_STEREO; + text.psz_string = N_("Stereo"); + var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val, &text ); + val.i_int = AOUT_VAR_MONO; + text.psz_string = N_("Mono"); + var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val, &text ); if ( i_nb_channels == 2 ) { - val.psz_string = N_("Stereo"); + val.i_int = AOUT_VAR_STEREO; } else { - val.psz_string = N_("Mono"); + val.i_int = AOUT_VAR_MONO; } - var_Change( p_aout, "audio-device", VLC_VAR_SETDEFAULT, &val ); - var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, - NULL ); + var_Change( p_aout, "audio-device", VLC_VAR_SETDEFAULT, &val, NULL ); + var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL ); } val.b_bool = VLC_TRUE; @@ -217,6 +229,7 @@ static int Open ( vlc_object_t *p_this ) *****************************************************************************/ static void Play( aout_instance_t * p_aout ) { + VLC_UNUSED(p_aout); } /***************************************************************************** @@ -224,6 +237,7 @@ static void Play( aout_instance_t * p_aout ) *****************************************************************************/ static void Close ( vlc_object_t *p_this ) { + VLC_UNUSED(p_this); SDL_PauseAudio( 1 ); SDL_CloseAudio(); SDL_QuitSubSystem( SDL_INIT_AUDIO ); @@ -247,12 +261,12 @@ static void SDLCallback( void * _p_aout, byte_t * p_stream, int i_len ) if ( p_buffer != NULL ) { - p_aout->p_vlc->pf_memcpy( p_stream, p_buffer->p_buffer, i_len ); + p_aout->p_libvlc->pf_memcpy( p_stream, p_buffer->p_buffer, i_len ); aout_BufferFree( p_buffer ); } else { - p_aout->p_vlc->pf_memset( p_stream, 0, i_len ); + p_aout->p_libvlc->pf_memset( p_stream, 0, i_len ); } }