1 /*****************************************************************************
2 * alsa.c : alsa plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2001 VideoLAN
5 * $Id: alsa.c,v 1.31 2003/07/18 20:06:00 gbazin Exp $
7 * Authors: Henri Fallon <henri@videolan.org> - Original Author
8 * Jeffrey Baker <jwbaker@acm.org> - Port to ALSA 1.0 API
9 * John Paul Lorenti <jpl31@columbia.edu> - Device selection
10 * Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr> - S/PDIF and aout3
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
25 *****************************************************************************/
27 /*****************************************************************************
29 *****************************************************************************/
30 #include <errno.h> /* ENOMEM */
31 #include <string.h> /* strerror() */
32 #include <stdlib.h> /* calloc(), malloc(), free() */
38 #include "aout_internal.h"
41 Note: we use the new API which is available since 0.9.0beta10a. */
42 #define ALSA_PCM_NEW_HW_PARAMS_API
43 #define ALSA_PCM_NEW_SW_PARAMS_API
44 #include <alsa/asoundlib.h>
46 /*****************************************************************************
47 * aout_sys_t: ALSA audio output method descriptor
48 *****************************************************************************
49 * This structure is part of the audio output thread descriptor.
50 * It describes the ALSA specific properties of an audio device.
51 *****************************************************************************/
54 snd_pcm_t * p_snd_pcm;
58 snd_output_t * p_snd_stderr;
61 int b_playing; /* playing status */
68 #define A52_FRAME_NB 1536
70 /* These values are in frames.
71 To convert them to a number of bytes you have to multiply them by the
72 number of channel(s) (eg. 2 for stereo) and the size of a sample (eg.
74 #define ALSA_DEFAULT_PERIOD_SIZE 1024
75 #define ALSA_DEFAULT_BUFFER_SIZE ( ALSA_DEFAULT_PERIOD_SIZE << 4 )
76 #define ALSA_SPDIF_PERIOD_SIZE A52_FRAME_NB
77 #define ALSA_SPDIF_BUFFER_SIZE ( ALSA_SPDIF_PERIOD_SIZE << 4 )
78 /* Why << 4 ? --Meuuh */
79 /* Why not ? --Bozo */
82 #define DEFAULT_ALSA_DEVICE "default"
84 /*****************************************************************************
86 *****************************************************************************/
87 static int Open ( vlc_object_t * );
88 static void Close ( vlc_object_t * );
89 static void Play ( aout_instance_t * );
90 static int ALSAThread ( aout_instance_t * );
91 static void ALSAFill ( aout_instance_t * );
93 /*****************************************************************************
95 *****************************************************************************/
97 add_category_hint( N_("ALSA"), NULL, VLC_FALSE );
98 add_string( "alsadev", DEFAULT_ALSA_DEVICE, aout_FindAndRestart,
99 N_("ALSA device name"), NULL, VLC_FALSE );
100 set_description( _("ALSA audio output") );
101 set_capability( "audio output", 150 );
102 set_callbacks( Open, Close );
105 /*****************************************************************************
106 * Probe: probe the audio device for available formats and channels
107 *****************************************************************************/
108 static void Probe( aout_instance_t * p_aout,
109 const char * psz_device, const char * psz_iec_device,
110 int i_snd_pcm_format )
112 struct aout_sys_t * p_sys = p_aout->output.p_sys;
113 vlc_value_t val, text;
115 var_Create ( p_aout, "audio-device", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
116 text.psz_string = _("Audio device");
117 var_Change( p_aout, "audio-device", VLC_VAR_SETTEXT, &text, NULL );
119 /* Now test linear PCM capabilities */
120 if ( !snd_pcm_open( &p_sys->p_snd_pcm, psz_device,
121 SND_PCM_STREAM_PLAYBACK, 0 ) )
124 snd_pcm_hw_params_t * p_hw;
125 snd_pcm_hw_params_alloca (&p_hw);
127 if ( snd_pcm_hw_params_any( p_sys->p_snd_pcm, p_hw ) < 0 )
129 msg_Warn( p_aout, "unable to retrieve initial hardware parameters"
130 ", disabling linear PCM audio" );
131 snd_pcm_close( p_sys->p_snd_pcm );
132 var_Destroy( p_aout, "audio-device" );
136 if ( snd_pcm_hw_params_set_format( p_sys->p_snd_pcm, p_hw,
137 i_snd_pcm_format ) < 0 )
139 /* Assume a FPU enabled computer can handle float32 format.
140 If somebody tells us it's not always true then we'll have
142 msg_Warn( p_aout, "unable to set stream sample size and word order"
143 ", disabling linear PCM audio" );
144 snd_pcm_close( p_sys->p_snd_pcm );
145 var_Destroy( p_aout, "audio-device" );
149 i_channels = aout_FormatNbChannels( &p_aout->output.output );
151 while ( i_channels > 0 )
153 /* Here we have to probe multi-channel capabilities but I have
154 no idea (at the moment) of how its managed by the ALSA
156 It seems that '6' channels aren't well handled on a stereo
157 sound card like my i810 but it requires some more
158 investigations. That's why '4' and '6' cases are disabled.
160 if ( !snd_pcm_hw_params_test_channels( p_sys->p_snd_pcm, p_hw,
163 switch ( i_channels )
166 val.i_int = AOUT_VAR_MONO;
167 text.psz_string = N_("Mono");
168 var_Change( p_aout, "audio-device",
169 VLC_VAR_ADDCHOICE, &val, &text );
172 val.i_int = AOUT_VAR_STEREO;
173 text.psz_string = N_("Stereo");
174 var_Change( p_aout, "audio-device",
175 VLC_VAR_ADDCHOICE, &val, &text );
176 var_Set( p_aout, "audio-device", val );
179 val.i_int = AOUT_VAR_2F2R;
180 text.psz_string = N_("2 Front 2 Rear");
181 var_Change( p_aout, "audio-device",
182 VLC_VAR_ADDCHOICE, &val, &text );
185 val.i_int = AOUT_VAR_5_1;
186 text.psz_string = N_("5.1");
187 var_Change( p_aout, "audio-device",
188 VLC_VAR_ADDCHOICE, &val, &text );
196 /* Close the previously opened device */
197 snd_pcm_close( p_sys->p_snd_pcm );
200 /* Test for S/PDIF device if needed */
201 if ( psz_iec_device )
203 /* Opening the device should be enough */
204 if ( !snd_pcm_open( &p_sys->p_snd_pcm, psz_iec_device,
205 SND_PCM_STREAM_PLAYBACK, 0 ) )
207 val.i_int = AOUT_VAR_SPDIF;
208 text.psz_string = N_("A/52 over S/PDIF");
209 var_Change( p_aout, "audio-device",
210 VLC_VAR_ADDCHOICE, &val, &text );
211 if( config_GetInt( p_aout, "spdif" ) )
212 var_Set( p_aout, "audio-device", val );
214 snd_pcm_close( p_sys->p_snd_pcm );
218 var_Change( p_aout, "audio-device", VLC_VAR_CHOICESCOUNT, &val, NULL );
221 /* Probe() has failed. */
222 var_Destroy( p_aout, "audio-device" );
226 /* Add final settings to the variable */
227 var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL );
228 val.b_bool = VLC_TRUE;
229 var_Set( p_aout, "intf-change", val );
232 /*****************************************************************************
233 * Open: create a handle and open an alsa device
234 *****************************************************************************
235 * This function opens an alsa device, through the alsa API.
237 * Note: the only heap-allocated string is psz_device. All the other pointers
238 * are references to psz_device or to stack-allocated data.
239 *****************************************************************************/
240 static int Open( vlc_object_t *p_this )
242 aout_instance_t * p_aout = (aout_instance_t *)p_this;
243 struct aout_sys_t * p_sys;
246 char psz_default_iec_device[128]; /* Buffer used to store the default
248 char * psz_device, * psz_iec_device; /* device names for PCM and S/PDIF
251 int i_vlc_pcm_format; /* Audio format for VLC's data */
252 int i_snd_pcm_format; /* Audio format for ALSA's data */
254 snd_pcm_uframes_t i_buffer_size = 0;
255 snd_pcm_uframes_t i_period_size = 0;
258 snd_pcm_hw_params_t *p_hw;
259 snd_pcm_sw_params_t *p_sw;
263 /* Allocate structures */
264 p_aout->output.p_sys = p_sys = malloc( sizeof( aout_sys_t ) );
267 msg_Err( p_aout, "out of memory" );
270 p_sys->b_playing = VLC_FALSE;
271 p_sys->start_date = 0;
272 vlc_cond_init( p_aout, &p_sys->wait );
273 vlc_mutex_init( p_aout, &p_sys->lock );
275 /* Get device name */
276 if( (psz_device = config_GetPsz( p_aout, "alsadev" )) == NULL )
278 msg_Err( p_aout, "no audio device given (maybe \"default\" ?)" );
283 /* Choose the IEC device for S/PDIF output:
284 if the device is overriden by the user then it will be the one
285 otherwise we compute the default device based on the output format. */
286 if( AOUT_FMT_NON_LINEAR( &p_aout->output.output )
287 && !strcmp( psz_device, DEFAULT_ALSA_DEVICE ) )
289 snprintf( psz_default_iec_device, sizeof(psz_default_iec_device),
290 "iec958:AES0=0x%x,AES1=0x%x,AES2=0x%x,AES3=0x%x",
291 IEC958_AES0_CON_EMPHASIS_NONE | IEC958_AES0_NONAUDIO,
292 IEC958_AES1_CON_ORIGINAL | IEC958_AES1_CON_PCM_CODER,
294 ( p_aout->output.output.i_rate == 48000 ?
295 IEC958_AES3_CON_FS_48000 :
296 ( p_aout->output.output.i_rate == 44100 ?
297 IEC958_AES3_CON_FS_44100 : IEC958_AES3_CON_FS_32000 ) ) );
298 psz_iec_device = psz_default_iec_device;
300 else if( AOUT_FMT_NON_LINEAR( &p_aout->output.output ) )
302 psz_iec_device = psz_device;
306 psz_iec_device = NULL;
309 /* Choose the linear PCM format (read the comment above about FPU
311 if( p_aout->p_libvlc->i_cpu & CPU_CAPABILITY_FPU )
313 i_vlc_pcm_format = VLC_FOURCC('f','l','3','2');
314 i_snd_pcm_format = SND_PCM_FORMAT_FLOAT;
318 i_vlc_pcm_format = AOUT_FMT_S16_NE;
319 i_snd_pcm_format = SND_PCM_FORMAT_S16;
322 /* If the variable doesn't exist then it's the first time we're called
323 and we have to probe the available audio formats and channels */
324 if ( var_Type( p_aout, "audio-device" ) == 0 )
326 Probe( p_aout, psz_device, psz_iec_device, i_snd_pcm_format );
329 if ( var_Get( p_aout, "audio-device", &val ) < 0 )
336 if ( val.i_int == AOUT_VAR_SPDIF )
338 p_aout->output.output.i_format = VLC_FOURCC('s','p','d','i');
340 else if ( val.i_int == AOUT_VAR_5_1 )
342 p_aout->output.output.i_format = i_vlc_pcm_format;
343 p_aout->output.output.i_physical_channels
344 = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
345 | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT
348 else if ( val.i_int == AOUT_VAR_2F2R )
350 p_aout->output.output.i_format = i_vlc_pcm_format;
351 p_aout->output.output.i_physical_channels
352 = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT
353 | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT;
355 else if ( val.i_int == AOUT_VAR_STEREO )
357 p_aout->output.output.i_format = i_vlc_pcm_format;
358 p_aout->output.output.i_physical_channels
359 = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
361 else if ( val.i_int == AOUT_VAR_MONO )
363 p_aout->output.output.i_format = i_vlc_pcm_format;
364 p_aout->output.output.i_physical_channels = AOUT_CHAN_CENTER;
369 /* This should not happen ! */
370 msg_Err( p_aout, "internal: can't find audio-device (%i)", val.i_int );
376 snd_output_stdio_attach( &p_sys->p_snd_stderr, stderr, 0 );
379 /* Open the device */
380 if ( AOUT_FMT_NON_LINEAR( &p_aout->output.output ) )
382 if ( ( i_snd_rc = snd_pcm_open( &p_sys->p_snd_pcm, psz_iec_device,
383 SND_PCM_STREAM_PLAYBACK, 0 ) ) < 0 )
385 msg_Err( p_aout, "cannot open ALSA device `%s' (%s)",
386 psz_iec_device, snd_strerror( i_snd_rc ) );
391 i_buffer_size = ALSA_SPDIF_BUFFER_SIZE;
392 i_snd_pcm_format = SND_PCM_FORMAT_S16;
395 p_aout->output.i_nb_samples = i_period_size = ALSA_SPDIF_PERIOD_SIZE;
396 p_aout->output.output.i_bytes_per_frame = AOUT_SPDIF_SIZE;
397 p_aout->output.output.i_frame_length = A52_FRAME_NB;
399 aout_VolumeNoneInit( p_aout );
403 if ( ( i_snd_rc = snd_pcm_open( &p_sys->p_snd_pcm, psz_device,
404 SND_PCM_STREAM_PLAYBACK, 0 ) ) < 0 )
406 msg_Err( p_aout, "cannot open ALSA device `%s' (%s)",
407 psz_device, snd_strerror( i_snd_rc ) );
412 i_buffer_size = ALSA_DEFAULT_BUFFER_SIZE;
413 i_channels = aout_FormatNbChannels( &p_aout->output.output );
415 p_aout->output.i_nb_samples = i_period_size = ALSA_DEFAULT_PERIOD_SIZE;
417 aout_VolumeSoftInit( p_aout );
420 /* Free psz_device so that all the remaining data is stack-allocated */
423 p_aout->output.pf_play = Play;
425 snd_pcm_hw_params_alloca(&p_hw);
426 snd_pcm_sw_params_alloca(&p_sw);
428 /* Get Initial hardware parameters */
429 if ( ( i_snd_rc = snd_pcm_hw_params_any( p_sys->p_snd_pcm, p_hw ) ) < 0 )
431 msg_Err( p_aout, "unable to retrieve initial hardware parameters (%s)",
432 snd_strerror( i_snd_rc ) );
437 if ( ( i_snd_rc = snd_pcm_hw_params_set_format( p_sys->p_snd_pcm, p_hw,
438 i_snd_pcm_format ) ) < 0 )
440 msg_Err( p_aout, "unable to set stream sample size and word order (%s)",
441 snd_strerror( i_snd_rc ) );
445 if ( ( i_snd_rc = snd_pcm_hw_params_set_access( p_sys->p_snd_pcm, p_hw,
446 SND_PCM_ACCESS_RW_INTERLEAVED ) ) < 0 )
448 msg_Err( p_aout, "unable to set interleaved stream format (%s)",
449 snd_strerror( i_snd_rc ) );
454 if ( ( i_snd_rc = snd_pcm_hw_params_set_channels( p_sys->p_snd_pcm, p_hw,
457 msg_Err( p_aout, "unable to set number of output channels (%s)",
458 snd_strerror( i_snd_rc ) );
463 #ifdef HAVE_ALSA_NEW_API
464 if ( ( i_snd_rc = snd_pcm_hw_params_set_rate_near( p_sys->p_snd_pcm, p_hw,
465 &p_aout->output.output.i_rate, NULL ) ) < 0 )
467 if ( ( i_snd_rc = snd_pcm_hw_params_set_rate_near( p_sys->p_snd_pcm, p_hw,
468 p_aout->output.output.i_rate, NULL ) ) < 0 )
471 msg_Warn( p_aout, "The rate %d Hz is not supported by your hardware. "
472 "Using %d Hz instead.\n", p_aout->output.output.i_rate,
474 p_aout->output.output.i_rate = i_snd_rc;
477 /* Set buffer size. */
478 #ifdef HAVE_ALSA_NEW_API
479 if ( ( i_snd_rc = snd_pcm_hw_params_set_buffer_size_near( p_sys->p_snd_pcm,
480 p_hw, &i_buffer_size ) ) < 0 )
482 if ( ( i_snd_rc = snd_pcm_hw_params_set_buffer_size_near( p_sys->p_snd_pcm,
483 p_hw, i_buffer_size ) ) < 0 )
486 msg_Err( p_aout, "unable to set buffer size (%s)",
487 snd_strerror( i_snd_rc ) );
491 /* Set period size. */
492 #ifdef HAVE_ALSA_NEW_API
493 if ( ( i_snd_rc = snd_pcm_hw_params_set_period_size_near( p_sys->p_snd_pcm,
494 p_hw, &i_period_size, NULL ) ) < 0 )
496 if ( ( i_snd_rc = snd_pcm_hw_params_set_period_size_near( p_sys->p_snd_pcm,
497 p_hw, i_period_size, NULL ) ) < 0 )
500 msg_Err( p_aout, "unable to set period size (%s)",
501 snd_strerror( i_snd_rc ) );
504 p_aout->output.i_nb_samples = i_period_size;
506 /* Commit hardware parameters. */
507 if ( ( i_snd_rc = snd_pcm_hw_params( p_sys->p_snd_pcm, p_hw ) ) < 0 )
509 msg_Err( p_aout, "unable to commit hardware configuration (%s)",
510 snd_strerror( i_snd_rc ) );
514 #ifdef HAVE_ALSA_NEW_API
515 if( ( i_snd_rc = snd_pcm_hw_params_get_period_time( p_hw,
516 &p_sys->i_period_time, NULL ) ) < 0 )
518 if( ( p_sys->i_period_time =
519 snd_pcm_hw_params_get_period_time( p_hw, NULL ) ) < 0 )
522 msg_Err( p_aout, "unable to get period time (%s)",
523 snd_strerror( i_snd_rc ) );
527 /* Get Initial software parameters */
528 snd_pcm_sw_params_current( p_sys->p_snd_pcm, p_sw );
530 i_snd_rc = snd_pcm_sw_params_set_sleep_min( p_sys->p_snd_pcm, p_sw, 0 );
532 i_snd_rc = snd_pcm_sw_params_set_avail_min( p_sys->p_snd_pcm, p_sw,
533 p_aout->output.i_nb_samples );
535 /* Commit software parameters. */
536 if ( snd_pcm_sw_params( p_sys->p_snd_pcm, p_sw ) < 0 )
538 msg_Err( p_aout, "unable to set software configuration" );
543 snd_output_printf( p_sys->p_snd_stderr, "\nALSA hardware setup:\n\n" );
544 snd_pcm_dump_hw_setup( p_sys->p_snd_pcm, p_sys->p_snd_stderr );
545 snd_output_printf( p_sys->p_snd_stderr, "\nALSA software setup:\n\n" );
546 snd_pcm_dump_sw_setup( p_sys->p_snd_pcm, p_sys->p_snd_stderr );
547 snd_output_printf( p_sys->p_snd_stderr, "\n" );
550 /* Create ALSA thread and wait for its readiness. */
551 if( vlc_thread_create( p_aout, "aout", ALSAThread,
552 VLC_THREAD_PRIORITY_OUTPUT, VLC_FALSE ) )
554 msg_Err( p_aout, "cannot create ALSA thread (%s)", strerror(errno) );
561 snd_pcm_close( p_sys->p_snd_pcm );
563 snd_output_close( p_sys->p_snd_stderr );
569 /*****************************************************************************
570 * Play: nothing to do
571 *****************************************************************************/
572 static void Play( aout_instance_t *p_aout )
574 if( !p_aout->output.p_sys->b_playing )
576 p_aout->output.p_sys->b_playing = 1;
578 /* get the playing date of the first aout buffer */
579 p_aout->output.p_sys->start_date =
580 aout_FifoFirstDate( p_aout, &p_aout->output.fifo );
582 /* wake up the audio output thread */
583 vlc_mutex_lock( &p_aout->output.p_sys->lock );
584 vlc_cond_signal( &p_aout->output.p_sys->wait );
585 vlc_mutex_unlock( &p_aout->output.p_sys->lock );
589 /*****************************************************************************
590 * Close: close the ALSA device
591 *****************************************************************************/
592 static void Close( vlc_object_t *p_this )
594 aout_instance_t *p_aout = (aout_instance_t *)p_this;
595 struct aout_sys_t * p_sys = p_aout->output.p_sys;
598 /* make sure the audio output thread is waken up */
599 vlc_mutex_lock( &p_aout->output.p_sys->lock );
600 vlc_cond_signal( &p_aout->output.p_sys->wait );
601 vlc_mutex_unlock( &p_aout->output.p_sys->lock );
603 p_aout->b_die = VLC_TRUE;
604 vlc_thread_join( p_aout );
605 p_aout->b_die = VLC_FALSE;
607 i_snd_rc = snd_pcm_close( p_sys->p_snd_pcm );
611 msg_Err( p_aout, "failed closing ALSA device (%s)",
612 snd_strerror( i_snd_rc ) );
616 snd_output_close( p_sys->p_snd_stderr );
622 /*****************************************************************************
623 * ALSAThread: asynchronous thread used to DMA the data to the device
624 *****************************************************************************/
625 static int ALSAThread( aout_instance_t * p_aout )
627 /* Wait for the exact time to start playing (avoids resampling) */
628 vlc_mutex_lock( &p_aout->output.p_sys->lock );
629 if( !p_aout->output.p_sys->start_date )
630 vlc_cond_wait( &p_aout->output.p_sys->wait,
631 &p_aout->output.p_sys->lock );
632 vlc_mutex_unlock( &p_aout->output.p_sys->lock );
634 mwait( p_aout->output.p_sys->start_date - AOUT_PTS_TOLERANCE / 4 );
636 while ( !p_aout->b_die )
644 /*****************************************************************************
645 * ALSAFill: function used to fill the ALSA buffer as much as possible
646 *****************************************************************************/
647 static void ALSAFill( aout_instance_t * p_aout )
649 struct aout_sys_t * p_sys = p_aout->output.p_sys;
651 aout_buffer_t * p_buffer;
652 snd_pcm_status_t * p_status;
653 snd_timestamp_t ts_next;
657 snd_pcm_status_alloca( &p_status );
659 /* Fill in the buffer until space or audio output buffer shortage */
662 i_snd_rc = snd_pcm_status( p_sys->p_snd_pcm, p_status );
665 msg_Err( p_aout, "unable to get the device's status (%s)",
666 snd_strerror( i_snd_rc ) );
668 msleep( p_sys->i_period_time >> 1 );
672 /* Handle buffer underruns and reget the status */
673 if( snd_pcm_status_get_state( p_status ) == SND_PCM_STATE_XRUN )
675 /* Prepare the device */
676 i_snd_rc = snd_pcm_prepare( p_sys->p_snd_pcm );
680 msg_Warn( p_aout, "recovered from buffer underrun" );
682 /* Reget the status */
683 i_snd_rc = snd_pcm_status( p_sys->p_snd_pcm, p_status );
686 msg_Err( p_aout, "unable to get the device's status after "
687 "recovery (%s)", snd_strerror( i_snd_rc ) );
689 msleep( p_sys->i_period_time >> 1 );
695 msg_Err( p_aout, "unable to recover from buffer underrun" );
697 msleep( p_sys->i_period_time >> 1 );
702 /* Here the device should be either in the RUNNING state either in
703 the PREPARE state. p_status is valid. */
705 snd_pcm_status_get_tstamp( p_status, &ts_next );
706 next_date = (mtime_t)ts_next.tv_sec * 1000000 + ts_next.tv_usec;
707 next_date += (mtime_t)snd_pcm_status_get_delay(p_status)
708 * 1000000 / p_aout->output.output.i_rate;
710 p_buffer = aout_OutputNextBuffer( p_aout, next_date,
711 (p_aout->output.output.i_format ==
712 VLC_FOURCC('s','p','d','i')) );
714 /* Audio output buffer shortage -> stop the fill process and wait */
715 if( p_buffer == NULL )
717 msleep( p_sys->i_period_time >> 1 );
721 i_snd_rc = snd_pcm_writei( p_sys->p_snd_pcm, p_buffer->p_buffer,
722 p_buffer->i_nb_samples );
726 msg_Err( p_aout, "write failed (%s)",
727 snd_strerror( i_snd_rc ) );
730 aout_BufferFree( p_buffer );