Changeset 06996317f9c056ba12188a797ba38444ddcc782c
- Timestamp:
- 31/08/02 01:27:06 (6 years ago)
- git-parent:
- Files:
-
- include/aout_internal.h (modified) (2 diffs)
- modules/audio_output/alsa.c (modified) (9 diffs)
- modules/audio_output/arts.c (modified) (8 diffs)
- modules/audio_output/esd.c (modified) (7 diffs)
- modules/audio_output/file.c (modified) (5 diffs)
- modules/audio_output/oss.c (modified) (7 diffs)
- modules/audio_output/sdl.c (modified) (4 diffs)
- modules/audio_output/waveout.c (modified) (5 diffs)
- modules/gui/beos/AudioOutput.cpp (modified) (7 diffs)
- modules/gui/macosx/aout.m (modified) (4 diffs)
- modules/gui/qnx/aout.c (modified) (6 diffs)
- modules/misc/dummy/aout.c (modified) (3 diffs)
- modules/video_output/directx/aout.c (modified) (6 diffs)
- src/audio_output/output.c (modified) (3 diffs)
- src/misc/threads.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
include/aout_internal.h
r0b88e77 r0699631 3 3 ***************************************************************************** 4 4 * Copyright (C) 2002 VideoLAN 5 * $Id: aout_internal.h,v 1.1 3 2002/08/30 22:22:24massiot Exp $5 * $Id: aout_internal.h,v 1.14 2002/08/30 23:27:05 massiot Exp $ 6 6 * 7 7 * Authors: Christophe Massiot <massiot@via.ecp.fr> … … 159 159 struct module_t * p_module; 160 160 struct aout_sys_t * p_sys; 161 int (* pf_setformat)( aout_instance_t * );162 161 void (* pf_play)( aout_instance_t * ); 163 162 int i_nb_samples; modules/audio_output/alsa.c
r7d2f6de r0699631 3 3 ***************************************************************************** 4 4 * Copyright (C) 2000-2001 VideoLAN 5 * $Id: alsa.c,v 1. 9 2002/08/29 23:53:22massiot Exp $5 * $Id: alsa.c,v 1.10 2002/08/30 23:27:06 massiot Exp $ 6 6 * 7 7 * Authors: Henri Fallon <henri@videolan.org> - Original Author … … 53 53 int i_period_time; 54 54 55 volatile vlc_bool_t b_initialized;56 57 55 volatile vlc_bool_t b_can_sleek; 58 56 … … 78 76 static int Open ( vlc_object_t * ); 79 77 static void Close ( vlc_object_t * ); 80 81 static int SetFormat ( aout_instance_t * );82 78 static void Play ( aout_instance_t * ); 83 84 79 static int ALSAThread ( aout_instance_t * ); 85 80 static void ALSAFill ( aout_instance_t * ); … … 106 101 struct aout_sys_t * p_sys; 107 102 103 int i_snd_rc; 104 105 char * psz_device; 106 char psz_alsadev[128]; 107 char * psz_userdev; 108 109 int i_format; 110 int i_channels; 111 112 snd_pcm_hw_params_t *p_hw; 113 snd_pcm_sw_params_t *p_sw; 114 108 115 /* Allocate structures */ 109 116 p_aout->output.p_sys = p_sys = malloc( sizeof( aout_sys_t ) ); … … 114 121 } 115 122 116 /* Create ALSA thread and wait for its readiness. */117 p_sys->b_initialized = VLC_FALSE;118 if( vlc_thread_create( p_aout, "aout", ALSAThread,119 VLC_THREAD_PRIORITY_OUTPUT, VLC_FALSE ) )120 {121 msg_Err( p_aout, "cannot create ALSA thread (%s)", strerror(errno) );122 free( p_sys );123 return -1;124 }125 126 p_aout->output.pf_setformat = SetFormat;127 123 p_aout->output.pf_play = Play; 128 124 … … 130 126 snd_output_stdio_attach( &p_sys->p_snd_stderr, stderr, 0 ); 131 127 #endif 132 133 return 0;134 }135 136 /*****************************************************************************137 * SetFormat : sets the alsa output format138 *****************************************************************************139 * This function prepares the device, sets the rate, format, the mode140 * ( "play as soon as you have data" ), and buffer information.141 *****************************************************************************/142 static int SetFormat( aout_instance_t * p_aout )143 {144 struct aout_sys_t * p_sys = p_aout->output.p_sys;145 146 int i_snd_rc;147 148 char * psz_device;149 char psz_alsadev[128];150 char * psz_userdev;151 152 int i_format;153 int i_channels;154 155 snd_pcm_hw_params_t *p_hw;156 snd_pcm_sw_params_t *p_sw;157 128 158 129 /* Read in ALSA device preferences from configuration */ … … 335 306 #endif 336 307 337 p_sys->b_initialized = VLC_TRUE; 308 /* Create ALSA thread and wait for its readiness. */ 309 if( vlc_thread_create( p_aout, "aout", ALSAThread, 310 VLC_THREAD_PRIORITY_OUTPUT, VLC_FALSE ) ) 311 { 312 msg_Err( p_aout, "cannot create ALSA thread (%s)", strerror(errno) ); 313 free( p_sys ); 314 return -1; 315 } 338 316 339 317 return 0; … … 341 319 342 320 /***************************************************************************** 343 * Play: queue a buffer for playing by ALSAThread321 * Play: nothing to do 344 322 *****************************************************************************/ 345 323 static void Play( aout_instance_t *p_aout ) … … 383 361 { 384 362 struct aout_sys_t * p_sys = p_aout->output.p_sys; 385 386 while ( !p_aout->b_die && !p_sys->b_initialized )387 msleep( THREAD_SLEEP );388 363 389 364 while ( !p_aout->b_die ) modules/audio_output/arts.c
r7d2f6de r0699631 3 3 ***************************************************************************** 4 4 * Copyright (C) 2001-2002 VideoLAN 5 * $Id: arts.c,v 1.10 2002/08/30 23:27:06 massiot Exp $ 5 6 * 6 7 * Authors: Emmanuel Blindauer <manu@agat.net> … … 47 48 { 48 49 arts_stream_t stream; 49 vlc_bool_t b_initialized;50 50 51 51 mtime_t latency; … … 58 58 static int Open ( vlc_object_t * ); 59 59 static void Close ( vlc_object_t * ); 60 61 static int SetFormat ( aout_instance_t * );62 60 static void Play ( aout_instance_t * ); 63 61 static int aRtsThread ( aout_instance_t * ); … … 88 86 return -1; 89 87 } 88 p_aout->output.p_sys = p_sys; 90 89 91 90 i_err = arts_init(); … … 98 97 } 99 98 100 p_aout->output.p_sys = p_sys;101 102 /* Create aRts thread and wait for its readiness. */103 p_sys->b_initialized = VLC_FALSE;104 if( vlc_thread_create( p_aout, "aout", aRtsThread,105 VLC_THREAD_PRIORITY_OUTPUT, VLC_FALSE ) )106 {107 msg_Err( p_aout, "cannot create aRts thread (%s)", strerror(errno) );108 free( p_sys );109 return -1;110 }111 112 p_aout->output.pf_setformat = SetFormat;113 99 p_aout->output.pf_play = Play; 114 100 115 101 p_sys->stream = NULL; 116 117 return 0;118 }119 120 /*****************************************************************************121 * SetFormat: set the output format122 *****************************************************************************/123 static int SetFormat( aout_instance_t *p_aout )124 {125 struct aout_sys_t * p_sys = p_aout->output.p_sys;126 127 p_sys->b_initialized = VLC_FALSE;128 102 129 103 if( p_sys->stream ) … … 153 127 p_aout->output.i_nb_samples = p_sys->i_size; 154 128 155 p_sys->b_initialized = VLC_TRUE; 129 /* Create aRts thread and wait for its readiness. */ 130 if( vlc_thread_create( p_aout, "aout", aRtsThread, 131 VLC_THREAD_PRIORITY_OUTPUT, VLC_FALSE ) ) 132 { 133 msg_Err( p_aout, "cannot create aRts thread (%s)", strerror(errno) ); 134 free( p_sys ); 135 return -1; 136 } 156 137 157 138 return 0; … … 159 140 160 141 /***************************************************************************** 161 * Play: queue a buffer for playing by aRtsThread142 * Play: nothing to do 162 143 *****************************************************************************/ 163 144 static void Play( aout_instance_t *p_aout ) … … 198 179 int i_tmp, i_size; 199 180 byte_t * p_bytes; 200 201 if( !p_sys->b_initialized )202 {203 msleep( THREAD_SLEEP );204 continue;205 }206 181 207 182 /* Get the presentation date of the next write() operation. It modules/audio_output/esd.c
r7d2f6de r0699631 3 3 ***************************************************************************** 4 4 * Copyright (C) 2000, 2001 VideoLAN 5 * $Id: esd.c,v 1.1 1 2002/08/29 23:53:22massiot Exp $5 * $Id: esd.c,v 1.12 2002/08/30 23:27:06 massiot Exp $ 6 6 * 7 7 * Authors: Samuel Hocevar <sam@zoy.org> … … 47 47 esd_format_t esd_format; 48 48 int i_fd; 49 vlc_bool_t b_initialized;50 49 51 50 mtime_t latency; … … 57 56 static int Open ( vlc_object_t * ); 58 57 static void Close ( vlc_object_t * ); 59 60 static int SetFormat ( aout_instance_t * );61 58 static void Play ( aout_instance_t * ); 62 59 static int ESDThread ( aout_instance_t * ); … … 90 87 p_aout->output.p_sys = p_sys; 91 88 92 /* Create ESD thread and wait for its readiness. */93 p_sys->b_initialized = VLC_FALSE;94 if( vlc_thread_create( p_aout, "aout", ESDThread,95 VLC_THREAD_PRIORITY_OUTPUT, VLC_FALSE ) )96 {97 msg_Err( p_aout, "cannot create ESD thread (%s)", strerror(errno) );98 free( p_sys );99 return -1;100 }101 102 p_aout->output.pf_setformat = SetFormat;103 89 p_aout->output.pf_play = Play; 104 105 return( 0 );106 }107 108 /*****************************************************************************109 * SetFormat: set the output format110 *****************************************************************************/111 static int SetFormat( aout_instance_t *p_aout )112 {113 struct aout_sys_t * p_sys = p_aout->output.p_sys;114 115 p_sys->b_initialized = VLC_FALSE;116 90 117 91 /* Initialize some variables */ … … 156 130 / p_aout->output.output.i_rate; 157 131 158 p_sys->b_initialized = VLC_TRUE; 132 /* Create ESD thread and wait for its readiness. */ 133 if( vlc_thread_create( p_aout, "aout", ESDThread, 134 VLC_THREAD_PRIORITY_OUTPUT, VLC_FALSE ) ) 135 { 136 msg_Err( p_aout, "cannot create ESD thread (%s)", strerror(errno) ); 137 free( p_sys ); 138 return -1; 139 } 159 140 160 141 return 0; … … 162 143 163 144 /***************************************************************************** 164 * Play: queue a buffer for playing by ESDThread145 * Play: nothing to do 165 146 *****************************************************************************/ 166 147 static void Play( aout_instance_t *p_aout ) … … 195 176 int i_tmp, i_size; 196 177 byte_t * p_bytes; 197 198 if( !p_sys->b_initialized )199 {200 msleep( THREAD_SLEEP );201 continue;202 }203 178 204 179 /* Get the presentation date of the next write() operation. It modules/audio_output/file.c
r0b88e77 r0699631 3 3 ***************************************************************************** 4 4 * Copyright (C) 2002 VideoLAN 5 * $Id: file.c,v 1. 9 2002/08/30 22:22:24massiot Exp $5 * $Id: file.c,v 1.10 2002/08/30 23:27:06 massiot Exp $ 6 6 * 7 7 * Authors: Christophe Massiot <massiot@via.ecp.fr> … … 42 42 static int Open ( vlc_object_t * ); 43 43 static void Close ( vlc_object_t * ); 44 static int SetFormat ( aout_instance_t * );45 44 static void Play ( aout_instance_t * ); 46 45 … … 83 82 FILE * p_file; 84 83 char * psz_name = config_GetPsz( p_this, "path" ); 84 char * psz_format = config_GetPsz( p_aout, "format" ); 85 char ** ppsz_compare = format_list; 86 int i = 0; 87 85 88 86 89 p_file = fopen( psz_name, "wb" ); … … 89 92 if ( p_file == NULL ) return -1; 90 93 91 p_aout->output.pf_setformat = SetFormat;92 94 p_aout->output.pf_play = Play; 93 94 return VLC_SUCCESS;95 }96 97 /*****************************************************************************98 * Close: close our file99 *****************************************************************************/100 static void Close( vlc_object_t * p_this )101 {102 aout_instance_t * p_aout = (aout_instance_t *)p_this;103 104 fclose( (FILE *)p_aout->output.p_sys );105 }106 107 /*****************************************************************************108 * SetFormat: pretend to set the dsp output format109 *****************************************************************************/110 static int SetFormat( aout_instance_t * p_aout )111 {112 char * psz_format = config_GetPsz( p_aout, "format" );113 char ** ppsz_compare = format_list;114 int i = 0;115 95 116 96 while ( *ppsz_compare != NULL ) … … 145 125 146 126 /***************************************************************************** 127 * Close: close our file 128 *****************************************************************************/ 129 static void Close( vlc_object_t * p_this ) 130 { 131 aout_instance_t * p_aout = (aout_instance_t *)p_this; 132 133 fclose( (FILE *)p_aout->output.p_sys ); 134 } 135 136 /***************************************************************************** 147 137 * Play: pretend to play a sound 148 138 *****************************************************************************/ modules/audio_output/oss.c
r7d2f6de r0699631 3 3 ***************************************************************************** 4 4 * Copyright (C) 2000-2002 VideoLAN 5 * $Id: oss.c,v 1.2 0 2002/08/29 23:53:22massiot Exp $5 * $Id: oss.c,v 1.21 2002/08/30 23:27:06 massiot Exp $ 6 6 * 7 7 * Authors: Michel Kaempf <maxx@via.ecp.fr> … … 63 63 { 64 64 int i_fd; 65 volatile vlc_bool_t b_initialized;66 65 }; 67 66 … … 76 75 static void Close ( vlc_object_t * ); 77 76 78 static int SetFormat ( aout_instance_t * );79 77 static void Play ( aout_instance_t * ); 80 78 static int OSSThread ( aout_instance_t * ); … … 103 101 struct aout_sys_t * p_sys; 104 102 char * psz_device; 103 int i_format; 104 int i_rate; 105 int i_fragments; 106 vlc_bool_t b_stereo; 105 107 106 108 /* Allocate structure */ … … 130 132 free( psz_device ); 131 133 134 p_aout->output.pf_play = Play; 135 136 /* Reset the DSP device */ 137 if( ioctl( p_sys->i_fd, SNDCTL_DSP_RESET, NULL ) < 0 ) 138 { 139 msg_Err( p_aout, "cannot reset OSS audio device" ); 140 return VLC_EGENERIC; 141 } 142 143 /* Set the fragment size */ 144 i_fragments = FRAME_COUNT << 16 | FRAME_SIZE; 145 if( ioctl( p_sys->i_fd, SNDCTL_DSP_SETFRAGMENT, &i_fragments ) < 0 ) 146 { 147 msg_Err( p_aout, "cannot set fragment size (%.8x)", i_fragments ); 148 return VLC_EGENERIC; 149 } 150 151 /* Set the output format */ 152 if ( p_aout->output.output.i_format == AOUT_FMT_SPDIF ) 153 { 154 i_format = AOUT_FMT_SPDIF; 155 p_aout->output.i_nb_samples = A52_FRAME_NB; 156 p_aout->output.output.i_bytes_per_frame = AOUT_SPDIF_SIZE; 157 p_aout->output.output.i_frame_length = A52_FRAME_NB; 158 } 159 else 160 { 161 p_aout->output.output.i_format = i_format = AOUT_FMT_S16_NE; 162 p_aout->output.i_nb_samples = FRAME_SIZE; 163 } 164 165 if( ioctl( p_sys->i_fd, SNDCTL_DSP_SETFMT, &i_format ) < 0 166 || i_format != p_aout->output.output.i_format ) 167 { 168 msg_Err( p_aout, "cannot set audio output format (%i)", i_format ); 169 return VLC_EGENERIC; 170 } 171 172 if ( p_aout->output.output.i_format != AOUT_FMT_SPDIF ) 173 { 174 /* FIXME */ 175 if ( p_aout->output.output.i_channels > 2 ) 176 { 177 msg_Warn( p_aout, "only two channels are supported at the moment" ); 178 /* Trigger downmixing */ 179 p_aout->output.output.i_channels = 2; 180 } 181 182 /* Set the number of channels */ 183 b_stereo = p_aout->output.output.i_channels - 1; 184 185 if( ioctl( p_sys->i_fd, SNDCTL_DSP_STEREO, &b_stereo ) < 0 ) 186 { 187 msg_Err( p_aout, "cannot set number of audio channels (%i)", 188 p_aout->output.output.i_channels ); 189 return VLC_EGENERIC; 190 } 191 192 if ( b_stereo + 1 != p_aout->output.output.i_channels ) 193 { 194 msg_Warn( p_aout, "driver forced up/downmixing %li->%li", 195 p_aout->output.output.i_channels, 196 b_stereo + 1 ); 197 p_aout->output.output.i_channels = b_stereo + 1; 198 } 199 200 /* Set the output rate */ 201 i_rate = p_aout->output.output.i_rate; 202 if( ioctl( p_sys->i_fd, SNDCTL_DSP_SPEED, &i_rate ) < 0 ) 203 { 204 msg_Err( p_aout, "cannot set audio output rate (%i)", 205 p_aout->output.output.i_rate ); 206 return VLC_EGENERIC; 207 } 208 209 if( i_rate != p_aout->output.output.i_rate ) 210 { 211 msg_Warn( p_aout, "driver forced resampling %li->%li", 212 p_aout->output.output.i_rate, i_rate ); 213 p_aout->output.output.i_rate = i_rate; 214 } 215 } 216 132 217 /* Create OSS thread and wait for its readiness. */ 133 p_sys->b_initialized = VLC_FALSE;134 218 if( vlc_thread_create( p_aout, "aout", OSSThread, 135 219 VLC_THREAD_PRIORITY_OUTPUT, VLC_FALSE ) ) … … 142 226 } 143 227 144 p_aout->output.pf_setformat = SetFormat;145 p_aout->output.pf_play = Play;146 147 228 return VLC_SUCCESS; 148 229 } 149 230 150 231 /***************************************************************************** 151 * SetFormat: reset the dsp and set its format 152 ***************************************************************************** 153 * This functions resets the DSP device, tries to initialize the output 154 * format with the value contained in the dsp structure, and if this value 155 * could not be set, the default value returned by ioctl is set. It then 156 * does the same for the stereo mode, and for the output rate. 157 *****************************************************************************/ 158 static int SetFormat( aout_instance_t *p_aout ) 159 { 160 struct aout_sys_t * p_sys = p_aout->output.p_sys; 161 int i_format; 162 int i_rate; 163 int i_fragments; 164 vlc_bool_t b_stereo; 165 166 p_sys->b_initialized = VLC_FALSE; 167 168 /* Reset the DSP device */ 169 if( ioctl( p_sys->i_fd, SNDCTL_DSP_RESET, NULL ) < 0 ) 170 { 171 msg_Err( p_aout, "cannot reset OSS audio device" ); 172 return VLC_EGENERIC; 173 } 174 175 /* Set the fragment size */ 176 i_fragments = FRAME_COUNT << 16 | FRAME_SIZE; 177 if( ioctl( p_sys->i_fd, SNDCTL_DSP_SETFRAGMENT, &i_fragments ) < 0 ) 178 { 179 msg_Err( p_aout, "cannot set fragment size (%.8x)", i_fragments ); 180 return VLC_EGENERIC; 181 } 182 183 /* Set the output format */ 184 if ( p_aout->output.output.i_format == AOUT_FMT_SPDIF ) 185 { 186 i_format = AOUT_FMT_SPDIF; 187 p_aout->output.i_nb_samples = A52_FRAME_NB; 188 p_aout->output.output.i_bytes_per_frame = AOUT_SPDIF_SIZE; 189 p_aout->output.output.i_frame_length = A52_FRAME_NB; 190 } 191 else 192 { 193 p_aout->output.output.i_format = i_format = AOUT_FMT_S16_NE; 194 p_aout->output.i_nb_samples = FRAME_SIZE; 195 } 196 197 if( ioctl( p_sys->i_fd, SNDCTL_DSP_SETFMT, &i_format ) < 0 198 || i_format != p_aout->output.output.i_format ) 199 { 200 msg_Err( p_aout, "cannot set audio output format (%i)", i_format ); 201 return VLC_EGENERIC; 202 } 203 204 if ( p_aout->output.output.i_format != AOUT_FMT_SPDIF ) 205 { 206 /* FIXME */ 207 if ( p_aout->output.output.i_channels > 2 ) 208 { 209 msg_Warn( p_aout, "only two channels are supported at the moment" ); 210 /* Trigger downmixing */ 211 p_aout->output.output.i_channels = 2; 212 } 213 214 /* Set the number of channels */ 215 b_stereo = p_aout->output.output.i_channels - 1; 216 217 if( ioctl( p_sys->i_fd, SNDCTL_DSP_STEREO, &b_stereo ) < 0 ) 218 { 219 msg_Err( p_aout, "cannot set number of audio channels (%i)", 220 p_aout->output.output.i_channels ); 221 return VLC_EGENERIC; 222 } 223 224 if ( b_stereo + 1 != p_aout->output.output.i_channels ) 225 { 226 msg_Warn( p_aout, "driver forced up/downmixing %li->%li", 227 p_aout->output.output.i_channels, 228 b_stereo + 1 ); 229 p_aout->output.output.i_channels = b_stereo + 1; 230 } 231 232 /* Set the output rate */ 233 i_rate = p_aout->output.output.i_rate; 234 if( ioctl( p_sys->i_fd, SNDCTL_DSP_SPEED, &i_rate ) < 0 ) 235 { 236 msg_Err( p_aout, "cannot set audio output rate (%i)", 237 p_aout->output.output.i_rate ); 238 return VLC_EGENERIC; 239 } 240 241 if( i_rate != p_aout->output.output.i_rate ) 242 { 243 msg_Warn( p_aout, "driver forced resampling %li->%li", 244 p_aout->output.output.i_rate, i_rate ); 245 p_aout->output.output.i_rate = i_rate; 246 } 247 } 248 249 p_sys->b_initialized = VLC_TRUE; 250 251 return VLC_SUCCESS; 252 } 253 254 /***************************************************************************** 255 * Play: queue a buffer for playing by OSSThread 232 * Play: nothing to do 256 233 *****************************************************************************/ 257 234 static void Play( aout_instance_t *p_aout ) … … 319 296 int i_tmp, i_size; 320 297 byte_t * p_bytes; 321 322 if( !p_sys->b_initialized )323 {324 msleep( THREAD_SLEEP );325 continue;326 }327 298 328 299 if ( p_aout->output.output.i_format != AOUT_FMT_SPDIF ) modules/audio_output/sdl.c
r0b88e77 r0699631 3 3 ***************************************************************************** 4 4 * Copyright (C) 2000-2002 VideoLAN 5 * $Id: sdl.c,v 1. 8 2002/08/30 22:22:24massiot Exp $5 * $Id: sdl.c,v 1.9 2002/08/30 23:27:06 massiot Exp $ 6 6 * 7 7 * Authors: Michel Kaempf <maxx@via.ecp.fr> … … 58 58 static int Open ( vlc_object_t * ); 59 59 static void Close ( vlc_object_t * ); 60 61 static int SetFormat ( aout_instance_t * );62 60 static void Play ( aout_instance_t * ); 63 64 61 static void SDLCallback ( void *, Uint8 *, int ); 65 62 … … 79 76 { 80 77 aout_instance_t *p_aout = (aout_instance_t *)p_this; 78 SDL_AudioSpec desired; 81 79 82 80 Uint32 i_flags = SDL_INIT_AUDIO; … … 107 105 } 108 106 109 return VLC_SUCCESS;110 }111 112 /*****************************************************************************113 * SetFormat: reset the audio device and sets its format114 *****************************************************************************/115 static int SetFormat( aout_instance_t *p_aout )116 {117 107 /* TODO: finish and clean this */ 118 SDL_AudioSpec desired;119 108 120 109 desired.freq = p_aout->output.output.i_rate; modules/audio_output/waveout.c
r51e9975 r0699631 3 3 ***************************************************************************** 4 4 * Copyright (C) 2001 VideoLAN 5 * $Id: waveout.c,v 1. 5 2002/08/25 09:40:00 samExp $5 * $Id: waveout.c,v 1.6 2002/08/30 23:27:06 massiot Exp $ 6 6 * 7 7 * Authors: Gildas Bazin <gbazin@netcourrier.com> … … 44 44 static int Open ( vlc_object_t * ); 45 45 static void Close ( vlc_object_t * ); 46 47 static int SetFormat ( aout_instance_t * );48 46 static void Play ( aout_instance_t * ); 49 47 … … 103 101 } 104 102 105 p_aout->output.pf_setformat = SetFormat;106 103 p_aout->output.pf_play = Play; 107 104 … … 120 117 /* We need to open the device with default values to be sure it is 121 118 * available */ 122 return OpenWaveOut( p_aout, WAVE_FORMAT_PCM, 2, 44100 ); 123 } 124 125 /***************************************************************************** 126 * SetFormat: reset the audio device and sets its format 127 ***************************************************************************** 128 * This functions set a new audio format. 129 * For this we need to close the current device and create another 130 * one with the desired format. 131 *****************************************************************************/ 132 static int SetFormat( aout_instance_t *p_aout ) 133 { 134 msg_Dbg( p_aout, "SetFormat" ); 119 if ( OpenWaveOut( p_aout, WAVE_FORMAT_PCM, 2, 44100 ) ) 120 { 121 msg_Err( p_aout, "cannot open waveout" ); 122 return 1; 123 } 135 124 136 125 waveOutReset( p_aout->output.p_sys->h_waveout ); … … 138 127 p_aout->output.output.i_format = AOUT_FMT_S16_NE; 139 128 p_aout->output.i_nb_samples = FRAME_SIZE; 140 141 /* Check if the format has changed */142 if( (p_aout->output.p_sys->waveformat.nChannels !=143 p_aout->output.output.i_channels) ||144 (p_aout->output.p_sys->waveformat.nSamplesPerSec !=145 p_aout->output.output.i_rate) )146 {147 if( waveOutClose( p_aout->output.p_sys->h_waveout ) !=148 MMSYSERR_NOERROR )149 {150 msg_Err( p_aout, "waveOutClose failed" );151 }152 153 /* calculate the frame size in bytes */154 p_aout->output.p_sys->i_buffer_size = FRAME_SIZE * sizeof(s16)155 * p_aout->output.output.i_channels;156 157 /* take care of silence buffer */158 free( p_aout->output.p_sys->p_silence_buffer );159 p_aout->output.p_sys->p_silence_buffer =160 calloc( p_aout->output.p_sys->i_buffer_size, 1 );161 if( p_aout->output.p_sys->p_silence_buffer == NULL )162 {163 msg_Err( p_aout, "out of memory" );164 return 1;165 }166 167 if( OpenWaveOut( p_aout, WAVE_FORMAT_PCM,168 p_aout->output.output.i_channels,169 p_aout->output.output.i_rate ) )170 return 1;171 }172 129 173 130 /* We need to kick off the playback in order to have the callback properly modules/gui/beos/AudioOutput.cpp
r7d2f6de r0699631 3 3 ***************************************************************************** 4 4 * Copyright (C) 1999, 2000, 2001 VideoLAN 5 * $Id: AudioOutput.cpp,v 1. 6 2002/08/29 23:53:22massiot Exp $5 * $Id: AudioOutput.cpp,v 1.7 2002/08/30 23:27:06 massiot Exp $ 6 6 * 7 7 * Authors: Jean-Marc Dressler <polux@via.ecp.fr> … … 55 55 int i_buffer_size; 56 56 uint i_buffer_pos; 57 volatile vlc_bool_t b_initialized;58 57 mtime_t clock_diff; 59 60 58 }; 61 59 … … 65 63 * Local prototypes. 66 64 *****************************************************************************/ 67 int Open ( vlc_object_t * );68 void Close ( vlc_object_t * );69 70 65 static int SetFormat ( aout_instance_t * ); 71 66 static void Play ( aout_instance_t * ); 72 static int BeOSThread ( aout_instance_t * );67 static int BeOSThread ( aout_instance_t * ); 73 68 74 69 /***************************************************************************** … … 77 72 int E_(OpenAudio) ( vlc_object_t * p_this ) 78 73 { 79 80 74 aout_instance_t * p_aout = (aout_instance_t *)p_this; 81 75 struct aout_sys_t * p_sys; … … 114 108 free( p_sys ); 115 109 return -1; 116 117 } 118 119 p_aout->output.pf_setformat = SetFormat; 110 } 111 120 112 p_aout->output.pf_play = Play; 121 113 … … 158 150 p_aout->output.p_sys->p_format->buffer_size = 4*8192; 159 151 160 p_aout->output.p_sys->b_initialized = VLC_TRUE;161 162 152 return( 0 ); 163 153 } 164 154 165 155 /***************************************************************************** 166 * Play: plays a sound samples buffer 167 ***************************************************************************** 168 * This function writes a buffer of i_length bytes in the dsp 156 * Play: nothing to do 169 157 *****************************************************************************/ 170 158 static void Play( aout_instance_t *p_aout ) … … 223 211 byte_t * p_bytes; 224 212 225 if( !p_sys->b_initialized )226 {227 msleep( THREAD_SLEEP );228 continue;229 }230 213 mtime_t next_date = 0; 231 214 /* Get the presentation date of the next write() operation. It modules/gui/macosx/aout.m
r51e9975 r0699631 3 3 ***************************************************************************** 4 4 * Copyright (C) 2002 VideoLAN 5 * $Id: aout.m,v 1. 7 2002/08/25 09:40:00 samExp $5 * $Id: aout.m,v 1.8 2002/08/30 23:27:06 massiot Exp $ 6 6 * 7 7 * Authors: Colin Delacroix <colin@zoy.org> … … 58 58 * Local prototypes. 59 59 *****************************************************************************/ 60 static int SetFormat ( aout_instance_t *p_aout );61 60 static void Play ( aout_instance_t *p_aout ); 62 61 … … 100 99 } 101 100 102 p_aout->output.pf_setformat = SetFormat;103 101 p_aout->output.pf_play = Play; 104 102 105 return 0;106 }107 108 /*****************************************************************************109 * SetFormat: find the closest available format from p_format110 *****************************************************************************/111 static int SetFormat( aout_instance_t * p_aout )112 {113 struct aout_sys_t * p_sys = p_aout->output.p_sys;114 OSErr err;115 116 103 /* Get a description of the data format used by the device */ 117 UInt32i_param_size = sizeof( p_sys->stream_format );104 i_param_size = sizeof( p_sys->stream_format ); 118 105 err = AudioDeviceGetProperty( p_sys->device, 0, false, 119 106 kAudioDevicePropertyStreamFormat, … … 209 196 210 197 /***************************************************************************** 211 * Play: queue a buffer for playing by IOCallback198 * Play: nothing to do 212 199 *****************************************************************************/ 213 200 static void Play( aout_instance_t * p_aout ) modules/gui/qnx/aout.c
r7d2f6de r0699631 48 48 49 49 byte_t * p_silent_buffer; 50 vlc_bool_t b_initialized;51 50 }; 52 51 … … 59 58 void E_(CloseAudio) ( vlc_object_t *p_this ); 60 59 static int GetBufInfo ( aout_instance_t * ); 61 static int SetFormat ( aout_instance_t * );62 60 static void Play ( aout_instance_t * ); 63 61 static int QNXaoutThread ( aout_instance_t * ); … … 72 70 aout_instance_t *p_aout = (aout_instance_t *)p_this; 73 71 int i_ret; 72 int i_bytes_per_sample; 73 snd_pcm_channel_info_t pi; 74 snd_pcm_channel_params_t pp; 75 aout_instance_t *p_aout = (aout_instance_t *)p_this; 74 76 75 77 /* allocate structure */ … … 103 105 } 104 106 105 /* Create audio thread and wait for its readiness. */106 p_aout->output.p_sys->b_initialized = VLC_FALSE;107 if( vlc_thread_create( p_aout, "aout", QNXaoutThread,108 VLC_THREAD_PRIORITY_OUTPUT, VLC_FALSE ) )109 {110 msg_Err( p_aout, "cannot create QNX audio thread (%s)", strerror(errno) );111 E_(CloseAudio)( p_this );112 free( p_aout->output.p_sys );113 return -1;114 }115 116 107 p_aout->output.p_sys->p_silent_buffer = malloc( DEFAULT_FRAME_SIZE * 4 ); 117 118 p_aout->output.pf_setformat = SetFormat;119 108 p_aout->output.pf_play = Play; 120 121 return( 0 );122 }123 124 /*****************************************************************************125 * SetFormat : set the audio output format126 *****************************************************************************127 * This function prepares the device, sets the rate, format, the mode128 * ("play as soon as you have data"), and buffer information.129 *****************************************************************************/130 static int SetFormat( aout_instance_t *p_this )131 {132 int i_ret;133 int i_bytes_per_sample;134 snd_pcm_channel_info_t pi;135 snd_pcm_channel_params_t pp;
