Changeset 54929735f8c480fcbdecb870e97405670acc6ce8
- Timestamp:
- 20/10/02 14:23:48 (6 years ago)
- git-parent:
- Files:
-
- include/aout_internal.h (modified) (2 diffs)
- include/audio_output.h (modified) (2 diffs)
- include/vlc_threads.h (modified) (2 diffs)
- modules/audio_filter/converter/a52tofloat32.c (modified) (2 diffs)
- modules/audio_output/alsa.c (modified) (16 diffs)
- modules/audio_output/arts.c (modified) (6 diffs)
- modules/audio_output/directx.c (modified) (8 diffs)
- modules/audio_output/esd.c (modified) (6 diffs)
- modules/audio_output/file.c (modified) (3 diffs)
- modules/audio_output/oss.c (modified) (8 diffs)
- modules/audio_output/waveout.c (modified) (6 diffs)
- modules/codec/mpeg_video/idct/idctaltivec.c (modified) (1 diff)
- modules/codec/mpeg_video/synchro.c (modified) (2 diffs)
- modules/demux/mpeg/system.c (modified) (2 diffs)
- modules/demux/mpeg/system.h (modified) (2 diffs)
- modules/demux/mpeg/ts.c (modified) (4 diffs)
- src/audio_output/common.c (modified) (2 diffs)
- src/audio_output/filters.c (modified) (2 diffs)
- src/audio_output/input.c (modified) (3 diffs)
- src/audio_output/intf.c (modified) (2 diffs)
- src/audio_output/mixer.c (modified) (2 diffs)
- src/audio_output/output.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
include/aout_internal.h
ref6c706 r5492973 3 3 ***************************************************************************** 4 4 * Copyright (C) 2002 VideoLAN 5 * $Id: aout_internal.h,v 1.2 2 2002/09/27 23:38:04massiot Exp $5 * $Id: aout_internal.h,v 1.23 2002/10/20 12:23:47 massiot Exp $ 6 6 * 7 7 * Authors: Christophe Massiot <massiot@via.ecp.fr> … … 261 261 VLC_EXPORT( int, aout_FormatNbChannels, ( audio_sample_format_t * p_format ) ); 262 262 void aout_FormatPrepare( audio_sample_format_t * p_format ); 263 VLC_EXPORT( void, aout_FormatPrint, ( aout_instance_t * p_aout, const char * psz_text, audio_sample_format_t * p_format ) ); 264 VLC_EXPORT( void, aout_FormatsPrint, ( aout_instance_t * p_aout, const char * psz_text, audio_sample_format_t * p_format1, audio_sample_format_t * p_format2 ) ); 263 265 void aout_FifoInit( aout_instance_t *, aout_fifo_t *, u32 ); 264 266 mtime_t aout_FifoNextStart( aout_instance_t *, aout_fifo_t * ); include/audio_output.h
r9a6b90b r5492973 3 3 ***************************************************************************** 4 4 * Copyright (C) 2002 VideoLAN 5 * $Id: audio_output.h,v 1.6 8 2002/09/30 21:32:31massiot Exp $5 * $Id: audio_output.h,v 1.69 2002/10/20 12:23:47 massiot Exp $ 6 6 * 7 7 * Authors: Christophe Massiot <massiot@via.ecp.fr> … … 179 179 VLC_EXPORT( int, aout_VolumeDown, ( aout_instance_t *, int, audio_volume_t * ) ); 180 180 VLC_EXPORT( int, aout_Restart, ( aout_instance_t * p_aout ) ); 181 VLC_EXPORT( void, aout_FindAndRestart, ( vlc_object_t * p_this ) ); 181 182 include/vlc_threads.h
r146bc0b r5492973 4 4 ***************************************************************************** 5 5 * Copyright (C) 1999, 2002 VideoLAN 6 * $Id: vlc_threads.h,v 1.1 4 2002/10/08 22:48:25massiot Exp $6 * $Id: vlc_threads.h,v 1.15 2002/10/20 12:23:47 massiot Exp $ 7 7 * 8 8 * Authors: Jean-Marc Dressler <polux@via.ecp.fr> … … 73 73 # define VLC_THREAD_PRIORITY_AUDIO 38 74 74 # define VLC_THREAD_PRIORITY_VIDEO 31 75 # define VLC_THREAD_PRIORITY_OUTPUT 3 875 # define VLC_THREAD_PRIORITY_OUTPUT 31 76 76 77 77 #elif defined(WIN32) modules/audio_filter/converter/a52tofloat32.c
r9a6b90b r5492973 5 5 ***************************************************************************** 6 6 * Copyright (C) 2001, 2002 VideoLAN 7 * $Id: a52tofloat32.c,v 1. 3 2002/09/30 21:32:32massiot Exp $7 * $Id: a52tofloat32.c,v 1.4 2002/10/20 12:23:47 massiot Exp $ 8 8 * 9 9 * Authors: Gildas Bazin <gbazin@netcourrier.com> … … 195 195 msg_Err( p_filter, 196 196 "liba52 couldn't do the requested downmix 0x%x->0x%x", 197 p_sys->i_flags, i_flags ); 197 p_sys->i_flags & A52_CHANNEL_MASK, 198 i_flags & A52_CHANNEL_MASK ); 198 199 memset( p_out_buf->p_buffer, 0, i_bytes_per_block * 6 ); 199 200 return; modules/audio_output/alsa.c
rd81ece4 r5492973 3 3 ***************************************************************************** 4 4 * Copyright (C) 2000-2001 VideoLAN 5 * $Id: alsa.c,v 1.1 3 2002/10/05 03:44:50 bozoExp $5 * $Id: alsa.c,v 1.14 2002/10/20 12:23:47 massiot Exp $ 6 6 * 7 7 * Authors: Henri Fallon <henri@videolan.org> - Original Author … … 50 50 { 51 51 snd_pcm_t * p_snd_pcm; 52 snd_pcm_sframes_t i_buffer_size;53 52 int i_period_time; 54 55 volatile vlc_bool_t b_can_sleek;56 53 57 54 #ifdef DEBUG … … 70 67 #define ALSA_SPDIF_PERIOD_SIZE A52_FRAME_NB 71 68 #define ALSA_SPDIF_BUFFER_SIZE ( ALSA_SPDIF_PERIOD_SIZE << 4 ) 69 /* Why << 4 ? --Meuuh */ 72 70 73 71 /***************************************************************************** … … 85 83 vlc_module_begin(); 86 84 add_category_hint( N_("ALSA"), NULL ); 87 add_string( "alsa-device", NULL, NULL, N_("device name"), NULL ); 85 add_string( "alsa-device", "default", aout_FindAndRestart, 86 N_("device name"), NULL ); 88 87 set_description( _("ALSA audio module") ); 89 88 set_capability( "audio output", 50 ); … … 100 99 aout_instance_t * p_aout = (aout_instance_t *)p_this; 101 100 struct aout_sys_t * p_sys; 102 103 int i_snd_rc = -1; 104 105 char * psz_device = NULL; 106 char psz_alsadev[128]; 107 char * psz_userdev; 108 109 int i_format_tries[2]; 110 int i_tries_count, i; 111 112 int i_format; 113 int i_channels; 101 char * psz_device; 102 int i_buffer_size; 114 103 115 104 snd_pcm_hw_params_t *p_hw; 116 105 snd_pcm_sw_params_t *p_sw; 106 107 int i_snd_rc = -1; 108 109 int i_format; 110 117 111 118 112 /* Allocate structures */ … … 124 118 } 125 119 126 p_aout->output.pf_play = Play; 120 /* Get device name */ 121 if( (psz_device = config_GetPsz( p_aout, "dspdev" )) == NULL ) 122 { 123 msg_Err( p_aout, "no audio device given (maybe \"default\" ?)" ); 124 free( p_sys ); 125 return VLC_EGENERIC; 126 } 127 127 128 128 #ifdef DEBUG … … 130 130 #endif 131 131 132 i_tries_count = 0; 133 i_format_tries[i_tries_count++] = p_aout->output.output.i_format; 134 if( i_format_tries[0] == VLC_FOURCC('s','p','d','i') ) 135 { 136 /* Try S/PDIF, and then FLOAT32 */ 137 i_format_tries[i_tries_count++] = VLC_FOURCC('f','l','3','2'); 138 } 139 140 /* Read in ALSA device preferences from configuration */ 141 psz_userdev = config_GetPsz( p_aout, "alsa-device" ); 142 143 for( i = 0 ; ( i_snd_rc < 0 ) && ( i < i_tries_count ) ; ++i ) 144 { 145 if( i_format_tries[i] == VLC_FOURCC('s','p','d','i') ) 146 { 147 if( psz_userdev ) 148 { 149 psz_device = psz_userdev; 150 } 151 else 152 { 153 /* Will probably need some little modification in the case 154 we want to send some data at a different rate 155 (32000, 44100 and 48000 are the possibilities) -- bozo */ 156 unsigned char s[4]; 157 s[0] = IEC958_AES0_CON_EMPHASIS_NONE | IEC958_AES0_NONAUDIO; 158 s[1] = IEC958_AES1_CON_ORIGINAL | IEC958_AES1_CON_PCM_CODER; 159 s[2] = 0; 160 s[3] = IEC958_AES3_CON_FS_48000; 161 sprintf( psz_alsadev, 162 "iec958:AES0=0x%x,AES1=0x%x,AES2=0x%x,AES3=0x%x", 163 s[0], s[1], s[2], s[3] ); 164 psz_device = psz_alsadev; 165 } 132 /* Open the device */ 133 if ( AOUT_FMT_NON_LINEAR( &p_aout->output.output ) 134 && !strcmp( "default", psz_device ) ) 135 { 136 /* ALSA doesn't understand "default" for S/PDIF. Cheat a little. */ 137 char psz_iecdev[128]; 138 139 if ( !strcmp( "default", psz_device ) ) 140 { 141 snprintf( psz_iecdev, sizeof(psz_iecdev), 142 "iec958:AES0=0x%x,AES1=0x%x,AES2=0x%x,AES3=0x%x", 143 IEC958_AES0_CON_EMPHASIS_NONE | IEC958_AES0_NONAUDIO, 144 IEC958_AES1_CON_ORIGINAL | IEC958_AES1_CON_PCM_CODER, 145 0, 146 (p_aout->output.output.i_rate == 48000 ? 147 IEC958_AES3_CON_FS_48000 : 148 (p_aout->output.output.i_rate == 44100 ? 149 IEC958_AES3_CON_FS_44100 : IEC958_AES3_CON_FS_32000)) ); 166 150 } 167 151 else 168 152 { 169 if( psz_userdev ) 170 psz_device = psz_userdev; 171 else 172 psz_device = "default"; 173 } 174 175 /* Open device */ 176 i_snd_rc = snd_pcm_open( &p_sys->p_snd_pcm, psz_device, 177 SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK); 178 } 179 180 if( i_snd_rc < 0 ) 181 { 182 msg_Err( p_aout, "cannot open ALSA device `%s' (%s)", 183 psz_device, snd_strerror(i_snd_rc) ); 184 if( psz_userdev ) 185 free( psz_userdev ); 186 p_sys->p_snd_pcm = NULL; 187 return -1; 188 } 189 190 if( psz_userdev ) 191 free( psz_userdev ); 192 193 p_aout->output.output.i_format = i_format_tries[i - 1]; 194 195 /* Default settings */ 196 p_sys->b_can_sleek = VLC_FALSE; 197 i_channels = p_aout->output.output.i_channels; 198 if ( p_aout->output.output.i_format == VLC_FOURCC('s','p','d','i') ) 199 { 200 p_sys->i_buffer_size = ALSA_SPDIF_BUFFER_SIZE; 201 p_aout->output.i_nb_samples = ALSA_SPDIF_PERIOD_SIZE; 202 aout_VolumeNoneInit( p_aout ); 203 } 204 else 205 { 206 p_sys->i_buffer_size = ALSA_DEFAULT_BUFFER_SIZE; 153 strncat( psz_iecdev, psz_device, sizeof(psz_iecdev) ); 154 } 155 156 if ( (i_snd_rc = snd_pcm_open( &p_sys->p_snd_pcm, psz_iecdev, 157 SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK)) < 0 ) 158 { 159 /* No S/PDIF. */ 160 msg_Warn( p_aout, "cannot open S/PDIF ALSA device `%s' (%s)", 161 psz_device, snd_strerror(i_snd_rc) ); 162 p_aout->output.output.i_format = VLC_FOURCC('f','l','3','2'); 163 } 164 else 165 { 166 i_buffer_size = ALSA_SPDIF_BUFFER_SIZE; 167 i_format = SND_PCM_FORMAT_S16_NE; 168 169 p_aout->output.i_nb_samples = ALSA_SPDIF_PERIOD_SIZE; 170 p_aout->output.output.i_format = VLC_FOURCC('s','p','d','i'); 171 p_aout->output.output.i_bytes_per_frame = AOUT_SPDIF_SIZE; 172 p_aout->output.output.i_frame_length = A52_FRAME_NB; 173 174 aout_VolumeNoneInit( p_aout ); 175 } 176 } 177 178 if ( !AOUT_FMT_NON_LINEAR( &p_aout->output.output ) ) 179 { 180 if ( (i_snd_rc = snd_pcm_open( &p_sys->p_snd_pcm, psz_device, 181 SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK)) < 0 ) 182 { 183 msg_Err( p_aout, "cannot open ALSA device `%s' (%s)", 184 psz_device, snd_strerror(i_snd_rc) ); 185 free( p_sys ); 186 free( psz_device ); 187 return VLC_EGENERIC; 188 } 189 190 if ( p_aout->p_libvlc->i_cpu & CPU_CAPABILITY_FPU ) 191 { 192 p_aout->output.output.i_format = VLC_FOURCC('f','l','3','2'); 193 i_format = SND_PCM_FORMAT_FLOAT; 194 } 195 else 196 { 197 p_aout->output.output.i_format = AOUT_FMT_S16_NE; 198 i_format = SND_PCM_FORMAT_S16_NE; 199 } 200 201 i_buffer_size = ALSA_DEFAULT_BUFFER_SIZE; 207 202 p_aout->output.i_nb_samples = ALSA_DEFAULT_PERIOD_SIZE; 203 208 204 aout_VolumeSoftInit( p_aout ); 209 205 } 210 206 211 /* Compute the settings */ 212 switch (p_aout->output.output.i_format) 213 { 214 case VLC_FOURCC('f','l','3','2'): 215 i_format = SND_PCM_FORMAT_FLOAT; 216 break; 217 218 case VLC_FOURCC('s','p','d','i'): 219 /* Override some settings to make S/PDIF work */ 220 p_sys->b_can_sleek = VLC_TRUE; 221 i_format = SND_PCM_FORMAT_S16_LE; 222 i_channels = 2; 223 p_aout->output.output.i_bytes_per_frame = AOUT_SPDIF_SIZE; 224 p_aout->output.output.i_frame_length = ALSA_SPDIF_PERIOD_SIZE; 225 break; 226 default: 227 msg_Err( p_aout, "audio output format '%.4s' not supported", 228 &p_aout->output.output.i_format ); 229 return -1; 230 break; 231 } 207 free( psz_device ); 208 p_aout->output.pf_play = Play; 232 209 233 210 snd_pcm_hw_params_alloca(&p_hw); 234 211 snd_pcm_sw_params_alloca(&p_sw); 235 212 236 i_snd_rc = snd_pcm_hw_params_any( p_sys->p_snd_pcm, p_hw ); 237 if( i_snd_rc < 0 ) 213 if ( snd_pcm_hw_params_any( p_sys->p_snd_pcm, p_hw ) < 0 ) 238 214 { 239 215 msg_Err( p_aout, "unable to retrieve initial hardware parameters" ); 240 return -1; 241 } 242 243 i_snd_rc = snd_pcm_hw_params_set_access( p_sys->p_snd_pcm, p_hw, 244 SND_PCM_ACCESS_RW_INTERLEAVED ); 245 if( i_snd_rc < 0 ) 246 { 247 msg_Err( p_aout, "unable to set interleaved stream format" ); 248 return -1; 249 } 250 251 i_snd_rc = snd_pcm_hw_params_set_format( p_sys->p_snd_pcm, p_hw, i_format ); 252 if( i_snd_rc < 0 ) 216 goto error; 217 } 218 219 /* Set format. */ 220 if ( snd_pcm_hw_params_set_format( p_sys->p_snd_pcm, p_hw, i_format ) < 0 ) 253 221 { 254 222 msg_Err( p_aout, "unable to set stream sample size and word order" ); 255 return -1; 256 } 257 258 i_snd_rc = snd_pcm_hw_params_set_channels( p_sys->p_snd_pcm, p_hw, 259 i_channels ); 260 if( i_snd_rc < 0 ) 261 { 262 msg_Err( p_aout, "unable to set number of output channels" ); 263 return -1; 264 } 265 266 i_snd_rc = snd_pcm_hw_params_set_rate_near( p_sys->p_snd_pcm, p_hw, 267 p_aout->output.output.i_rate, 268 NULL ); 269 if( i_snd_rc < 0 ) 270 { 271 msg_Err( p_aout, "unable to set sample rate" ); 272 return -1; 273 } 274 p_aout->output.output.i_rate = i_snd_rc; 275 223 goto error; 224 } 225 226 if ( !AOUT_FMT_NON_LINEAR( &p_aout->output.output ) ) 227 { 228 int i_nb_channels; 229 230 if ( snd_pcm_hw_params_set_access( p_sys->p_snd_pcm, p_hw, 231 SND_PCM_ACCESS_RW_INTERLEAVED ) < 0 ) 232 { 233 msg_Err( p_aout, "unable to set interleaved stream format" ); 234 goto error; 235 } 236 237 /* Set channels. */ 238 i_nb_channels = aout_FormatNbChannels( &p_aout->output.output ); 239 240 if ( (i_snd_rc = snd_pcm_hw_params_set_channels( p_sys->p_snd_pcm, 241 p_hw, i_nb_channels )) < 0 ) 242 { 243 msg_Err( p_aout, "unable to set number of output channels" ); 244 goto error; 245 } 246 if ( i_snd_rc != i_nb_channels ) 247 { 248 switch ( i_snd_rc ) 249 { 250 case 1: p_aout->output.output.i_channels = AOUT_CHAN_MONO; break; 251 case 2: p_aout->output.output.i_channels = AOUT_CHAN_STEREO; break; 252 case 4: p_aout->output.output.i_channels = AOUT_CHAN_2F2R; break; 253 default: 254 msg_Err( p_aout, "Unsupported downmixing (%d)", i_snd_rc ); 255 goto error; 256 } 257 } 258 259 /* Set rate. */ 260 if ( (i_snd_rc = snd_pcm_hw_params_set_rate_near( p_sys->p_snd_pcm, 261 p_hw, p_aout->output.output.i_rate, 262 NULL )) < 0 ) 263 { 264 msg_Err( p_aout, "unable to set sample rate" ); 265 goto error; 266 } 267 p_aout->output.output.i_rate = i_snd_rc; 268 } 269 270 /* Set buffer size. */ 276 271 i_snd_rc = snd_pcm_hw_params_set_buffer_size_near( p_sys->p_snd_pcm, p_hw, 277 272 p_sys->i_buffer_size ); 278 273 if( i_snd_rc < 0 ) 279 274 { 280 msg_Err( p_aout, "unable to set buffer time" );281 return -1;282 } 283 p_sys->i_buffer_size = i_snd_rc; 284 275 msg_Err( p_aout, "unable to set buffer size" ); 276 goto error; 277 } 278 279 /* Set period size. */ 285 280 i_snd_rc = snd_pcm_hw_params_set_period_size_near( 286 p_sys->p_snd_pcm, p_hw, p_aout->output.i_nb_samples, NULL );281 p_sys->p_snd_pcm, p_hw, p_aout->output.i_nb_samples, NULL ); 287 282 if( i_snd_rc < 0 ) 288 283 { 289 284 msg_Err( p_aout, "unable to set period size" ); 290 return -1;285 goto error; 291 286 } 292 287 p_aout->output.i_nb_samples = i_snd_rc; 293 288 294 i_snd_rc = snd_pcm_hw_params( p_sys->p_snd_pcm, p_hw );295 if ( i_snd_rc < 0)289 /* Write hardware configuration. */ 290 if ( snd_pcm_hw_params( p_sys->p_snd_pcm, p_hw ) < 0 ) 296 291 { 297 292 msg_Err( p_aout, "unable to set hardware configuration" ); 298 return -1;293 goto error; 299 294 } 300 295 … … 307 302 p_aout->output.i_nb_samples ); 308 303 309 i_snd_rc = snd_pcm_sw_params( p_sys->p_snd_pcm, p_sw );310 if ( i_snd_rc< 0 )304 /* Write software configuration. */ 305 if ( snd_pcm_sw_params( p_sys->p_snd_pcm, p_sw ) < 0 ) 311 306 { 312 307 msg_Err( p_aout, "unable to set software configuration" ); 313 return -1;308 goto error; 314 309 } 315 310 … … 327 322 { 328 323 msg_Err( p_aout, "cannot create ALSA thread (%s)", strerror(errno) ); 329 free( p_sys ); 330 return -1; 324 goto error; 331 325 } 332 326 333 327 return 0; 328 329 error: 330 snd_pcm_close( p_sys->p_snd_pcm ); 331 #ifdef DEBUG 332 snd_output_close( p_sys->p_snd_stderr ); 333 #endif 334 free( p_sys ); 335 return VLC_EGENERIC; 334 336 } 335 337 … … 342 344 343 345 /***************************************************************************** 344 * Close: close the A lsadevice346 * Close: close the ALSA device 345 347 *****************************************************************************/ 346 348 static void Close( vlc_object_t *p_this ) … … 353 355 vlc_thread_join( p_aout ); 354 356 355 if( p_sys->p_snd_pcm ) 356 { 357 i_snd_rc = snd_pcm_close( p_sys->p_snd_pcm ); 358 359 if( i_snd_rc > 0 ) 360 { 361 msg_Err( p_aout, "failed closing ALSA device (%s)", 362 snd_strerror( i_snd_rc ) ); 363 } 357 i_snd_rc = snd_pcm_close( p_sys->p_snd_pcm ); 358 359 if( i_snd_rc > 0 ) 360 { 361 msg_Err( p_aout, "failed closing ALSA device (%s)", 362 snd_strerror( i_snd_rc ) ); 364 363 } 365 364 … … 384 383 /* Sleep during less than one period to avoid a lot of buffer 385 384 underruns */ 385 386 /* Why do we need to sleep ? --Meuuh */ 386 387 msleep( p_sys->i_period_time >> 2 ); 387 388 } … … 410 411 if( i_snd_rc < 0 ) 411 412 { 412 msg_Err( p_aout, " alsadevice not ready !!! (%s)",413 msg_Err( p_aout, "ALSA device not ready !!! (%s)", 413 414 snd_strerror( i_snd_rc ) ); 414 415 return; … … 416 417 417 418 /* Fill in the buffer until space or audio output buffer shortage */ 418 while( VLC_TRUE)419 for ( ; ; ) 419 420 { 420 421 /* Get the status */ … … 467 468 468 469 p_buffer = aout_OutputNextBuffer( p_aout, next_date, 469 p_sys->b_can_sleek ); 470 (p_aout->output.output.i_format != 471 VLC_FOURCC('s','p','d','i')) ); 470 472 471 473 /* Audio output buffer shortage -> stop the fill process and … … 482 484 snd_strerror( i_snd_rc ) ); 483 485 } 484 else 485 { 486 aout_BufferFree( p_buffer ); 487 } 486 487 aout_BufferFree( p_buffer ); 488 488 } 489 489 } modules/audio_output/arts.c
r89987e1 r5492973 3 3 ***************************************************************************** 4 4 * Copyright (C) 2001-2002 VideoLAN 5 * $Id: arts.c,v 1.1 3 2002/10/04 18:07:21 samExp $5 * $Id: arts.c,v 1.14 2002/10/20 12:23:47 massiot Exp $ 6 6 * 7 7 * Authors: Emmanuel Blindauer <manu@agat.net> … … 78 78 struct aout_sys_t * p_sys; 79 79 int i_err; 80 int i_nb_channels; 80 81 81 82 /* Allocate structure */ … … 100 101 aout_VolumeSoftInit( p_aout ); 101 102 102 p_sys->stream = NULL; 103 104 if( p_sys->stream ) 105 { 106 arts_close_stream( p_sys->stream ); 103 p_aout->output.output.i_format = AOUT_FMT_S16_NE; 104 i_nb_channels = aout_FormatNbChannels( &p_aout->output.output ); 105 if ( i_nb_channels > 2 ) 106 { 107 /* aRts doesn't support more than two channels. */ 108 i_nb_channels = 2; 109 p_aout->output.output.i_channels = AOUT_CHAN_STEREO; 107 110 } 108 111 109 112 /* Open a socket for playing a stream, set format to 16 bits */ 110 113 p_sys->stream = arts_play_stream( p_aout->output.output.i_rate, 16, 111 p_aout->output.output.i_channels, "vlc" );114 i_nb_channels, "vlc" ); 112 115 if( p_sys->stream == NULL ) 113 116 { 114 117 msg_Err( p_aout, "cannot open aRts socket" ); 118 free( p_sys ); 115 119 return -1; 116 120 } … … 129 133 arts_stream_get( p_sys->stream, ARTS_P_PACKET_SIZE ) ); 130 134 131 p_aout->output.output.i_format = AOUT_FMT_S16_NE; 132 p_aout->output.i_nb_samples = p_sys->i_size 133 / sizeof(u16) 134 / p_aout->output.output.i_channels; 135 p_aout->output.i_nb_samples = p_sys->i_size / sizeof(u16) / i_nb_channels; 135 136 136 137 /* Create aRts thread and wait for its readiness. */ … … 139 140 { 140 141 msg_Err( p_aout, "cannot create aRts thread (%s)", strerror(errno) ); 142 arts_close_stream( p_sys->stream ); 143 arts_free(); 141 144 free( p_sys ); 142 145 return -1; … … 165 168 vlc_thread_join( p_aout ); 166 169 167 if( p_sys->stream ) 168 { 169 arts_close_stream( p_sys->stream ); 170 } 171 170 arts_close_stream( p_sys->stream ); 172 171 arts_free(); 173 172 free( p_sys ); modules/audio_output/directx.c
rcc5919a r5492973 1 1 /***************************************************************************** 2 * aout.c: Windows DirectX audio output method2 * directx.c: Windows DirectX audio output method 3 3 ***************************************************************************** 4 4 * Copyright (C) 2001 VideoLAN 5 * $Id: directx.c,v 1. 3 2002/10/11 10:08:06 gbazinExp $5 * $Id: directx.c,v 1.4 2002/10/20 12:23:47 massiot Exp $ 6 6 * 7 7 * Authors: Gildas Bazin <gbazin@netcourrier.com> … … 131 131 { 132 132 msg_Err( p_aout, "out of memory" ); 133 return 1;133 return VLC_EGENERIC; 134 134 } 135 135 … … 224 224 error: 225 225 CloseAudio( VLC_OBJECT(p_aout) ); 226 return 1;226 return VLC_EGENERIC; 227 227 } 228 228 … … 270 270 FreeLibrary( p_aout->output.p_sys->hdsound_dll ); 271 271 272 /* Close the Output. */ 273 if ( p_aout->output.p_sys ) 274 { 275 free( p_aout->output.p_sys ); 276 p_aout->output.p_sys = NULL; 277 } 272 free( p_aout->output.p_sys ); 278 273 } 279 274 … … 356 351 DSBUFFERDESC dsbdesc; 357 352 DSBCAPS dsbcaps; 358 359 if( p_aout->output.output.i_channels > 2 ) 360 p_aout->output.output.i_channels = 2; 353 int i_nb_channels; 354 355 i_nb_channels = aout_FormatNbChannels( &p_aout->output.output ); 356 if ( i_nb_channels > 2 ) 357 { 358 i_nb_channels = 2; 359 p_aout->output.output.i_channels = AOUT_CHAN_STEREO; 360 } 361 361 362 362 /* First set the buffer format */ 363 363 memset(&waveformat, 0, sizeof(WAVEFORMATEX)); 364 364 waveformat.wFormatTag = WAVE_FORMAT_PCM; 365 waveformat.nChannels = p_aout->output.output.i_channels;365 waveformat.nChannels = i_nb_channels; 366 366 waveformat.nSamplesPerSec = p_aout->output.output.i_rate; 367 367 waveformat.wBitsPerSample = 16; … … 378 378 | DSBCAPS_GLOBALFOCUS; /* Allows background playing */ 379 379 dsbdesc.dwBufferBytes = FRAME_SIZE * 2 /* frames*/ * /* buffer size */ 380 sizeof(s16) * p_aout->output.output.i_channels;380 sizeof(s16) * i_nb_channels; 381 381 dsbdesc.lpwfxFormat = &waveformat; 382 382 … … 392 392 /* backup the size of a frame */ 393 393 p_aout->output.p_sys->p_notif->i_buffer_size = FRAME_SIZE * sizeof(s16) 394 * p_aout->output.output.i_channels;394 * i_nb_channels; 395 395 396 396 memset(&dsbcaps, 0, sizeof(DSBCAPS)); … … 440 440 p_aout->output.p_sys->p_dsnotify = NULL; 441 441 } 442 return 1;442 return VLC_EGENERIC; 443 443 } 444 444 modules/audio_output/esd.c
r35b4740 r5492973 3 3 ***************************************************************************** 4 4 * Copyright (C) 2000, 2001 VideoLAN 5 * $Id: esd.c,v 1.1 3 2002/09/18 21:21:23massiot Exp $5 * $Id: esd.c,v 1.14 2002/10/20 12:23:47 massiot Exp $ 6 6 * 7 7 * Authors: Samuel Hocevar <sam@zoy.org> … … 76 76 aout_instance_t *p_aout = (aout_instance_t *)p_this; 77 77 struct aout_sys_t * p_sys; 78 int i_nb_channels; 78 79 79 80 /* Allocate structure */ … … 94 95 p_sys->esd_format &= ~ESD_MASK_CHAN; 95 96 96 switch( p_aout->output.output.i_channels ) 97 p_aout->output.output.i_format = AOUT_FMT_S16_NE; 98 i_nb_channels = aout_FormatNbChannels( &p_aout->output.output ); 99 if ( i_nb_channels > 2 ) 100 { 101 /* EsounD doesn't support more than two channels. */ 102 i_nb_channels = 2; 103 p_aout->output.output.i_channels = AOUT_CHAN_STEREO; 104 } 105 106 switch( i_nb_channels ) 97 107 { 98 108 case 1: … … 102 112 p_sys->esd_format |= ESD_STEREO; 103 113 break; 104 default:105 return -1;106 114 } 107 115 … … 114 122 msg_Err( p_aout, "cannot open esound socket (format 0x%08x at %ld Hz)", 115 123 p_sys->esd_format, p_aout->output.output.i_rate ); 124 free( p_sys ); 116 125 return -1; 117 126 } 118 127 119 p_aout->output.output.i_format = AOUT_FMT_S16_NE;120 128 p_aout->output.i_nb_samples = ESD_BUF_SIZE * 2; 121 129 … … 136 144 { 137 145 msg_Err( p_aout, "cannot create ESD thread (%s)", strerror(errno) ); 146 close( p_sys->i_fd ); 138 147 free( p_sys ); 139 148 return -1; modules/audio_output/file.c
r9a6b90b r5492973 3 3 ***************************************************************************** 4 4 * Copyright (C) 2002 VideoLAN 5 * $Id: file.c,v 1.1 2 2002/09/30 21:32:32massiot Exp $5 * $Id: file.c,v 1.13 2002/10/20 12:23:47 massiot Exp $ 6 6 * 7 7 * Authors: Christophe Massiot <massiot@via.ecp.fr> … … 99 99 100 100 p_aout->output.pf_play = Play; 101 aout_VolumeSoftInit( p_aout );102 101 103 102 while ( *ppsz_compare != NULL ) … … 118 117 119 118 p_aout->output.output.i_format = format_int[i]; 120 if ( p_aout->output.output.i_format == VLC_FOURCC('s','p','d','i') )119 if ( AOUT_FMT_NON_LINEAR( &p_aout->output.output ) ) 121 120 { 122 121 p_aout->output.i_nb_samples = A52_FRAME_NB; 123 122 p_aout->output.output.i_bytes_per_frame = AOUT_SPDIF_SIZE; 124 123 p_aout->output.output.i_frame_length = A52_FRAME_NB; 124 aout_VolumeNoneInit( p_aout ); 125 125 } 126 126 else 127 127 { 128 128 p_aout->output.i_nb_samples = FRAME_SIZE; 129 aout_VolumeSoftInit( p_aout ); 129 130 } 130 131 return 0; modules/audio_output/oss.c
r31c3158 r5492973 3 3 ***************************************************************************** 4 4 * Copyright (C) 2000-2002 VideoLAN 5 * $Id: oss.c,v 1. 29 2002/10/02 15:37:58 sigmunauExp $5 * $Id: oss.c,v 1.30 2002/10/20 12:23:47 massiot Exp $ 6 6 * 7 7 * Authors: Michel Kaempf <maxx@via.ecp.fr> … … 65 65 }; 66 66 67 /* This must be a power of 2. */ 67 68 #define FRAME_SIZE 1024 68 69 #define FRAME_COUNT 8 … … 83 84 vlc_module_begin(); 84 85 add_category_hint( N_("OSS"), NULL ); 85 add_file( "dspdev", "/dev/dsp", NULL, N_("OSS dsp device"), NULL ); 86 add_file( "dspdev", "/dev/dsp", aout_FindAndRestart, 87 N_("OSS dsp device"), NULL ); 86 88 set_description( _("Linux OSS /dev/dsp module") ); 87 89 set_capability( "audio output", 100 ); 88 add_shortcut( " dsp" );90 add_shortcut( "oss" ); 89 91 set_callbacks( Open, Close ); 90 92 vlc_module_end(); … … 101 103 struct aout_sys_t * p_sys; 102 104 char * psz_device; 103 int i_format, i_format_orig;104 int i_rate;105 int i_frame_size;106 int i_fragments;107 vlc_bool_t b_stereo;108 105 109 106 /* Allocate structure */ … … 115 112 } 116 113 117 /* Initialize some variables*/114 /* Get device name */ 118 115 if( (psz_device = config_GetPsz( p_aout, "dspdev" )) == NULL ) 119 116 { … … 139 136 { 140 137 msg_Err( p_aout, "cannot reset OSS audio device" ); 138 close( p_sys->i_fd ); 139 free( p_sys ); 141 140 return VLC_EGENERIC; 142 141 } 143 142 144 /* Set the fragment size145 * i_fragment = xxxxyyyy where: xxxx is fragtotal146 * 1 << yyyy is fragsize */147 i_fragments = 0;148 i_frame_size = FRAME_SIZE;149 while( i_frame_size >>= 1 )150 {151 ++i_fragments;152 }153 i_fragments |= FRAME_COUNT << 16;154 if( ioctl( p_sys->i_fd, SNDCTL_DSP_SETFRAGMENT, &i_fragments ) < 0 )155 {156 msg_Err( p_aout, "cannot set fragment size (%.8x)", i_fragments );157 return VLC_EGENERIC;158 }159 160 143 /* Set the output format */ 161 if ( p_aout->output.output.i_format == VLC_FOURCC('s','p','d','i') ) 162 { 163 i_format = AFMT_AC3; 164 i_format_orig = AFMT_AC3; 165 p_aout->output.i_nb_samples = A52_FRAME_NB; 166 p_aout->output.output.i_bytes_per_frame = AOUT_SPDIF_SIZE; 167 p_aout->output.output.i_frame_length = A52_FRAME_NB; 168 169 aout_VolumeNoneInit( p_aout ); 170 } 171 else 172 { 144 if ( AOUT_FMT_NON_LINEAR( &p_aout->output.output ) ) 145 { 146 int i_format = AFMT_AC3; 147 148 if( ioctl( p_sys->i_fd, SNDCTL_DSP_SETFMT, &i_format ) < 0 149 || i_format != AFMT_AC3 ) 150 { 151 p_aout->output.output.i_format = AOUT_FMT_S16_NE; 152 } 153 else 154 { 155 p_aout->output.output.i_format = VLC_FOURCC('s','p','d','i'); 156 p_aout->output.i_nb_samples = A52_FRAME_NB; 157 p_aout->output.output.i_bytes_per_frame = AOUT_SPDIF_SIZE; 158 p_aout->output.output.i_frame_length = A52_FRAME_NB; 159 160 aout_VolumeNoneInit( p_aout ); 161 } 162 } 163 164 if ( !AOUT_FMT_NON_LINEAR( &p_aout->output.output ) ) 165 { 166 int i_format = AFMT_S16_NE; 167 int i_frame_size, i_fragments; 168 int i_rate; 169 int i_nb_channels; 170 171 if( ioctl( p_sys->i_fd, SNDCTL_DSP_SETFMT, &i_format ) < 0 ) 172 { 173 msg_Err( p_aout, "cannot set audio output format" ); 174 close( p_sys->i_fd ); 175
