1 /*****************************************************************************
2 * alsa.c : alsa plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2001 the VideoLAN team
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25 *****************************************************************************/
27 /*****************************************************************************
29 *****************************************************************************/
36 #include <vlc_common.h>
37 #include <vlc_plugin.h>
39 #include <errno.h> /* ENOMEM */
40 #include <vlc_dialog.h>
46 Note: we use the new API which is available since 0.9.0beta10a. */
47 #define ALSA_PCM_NEW_HW_PARAMS_API
48 #define ALSA_PCM_NEW_SW_PARAMS_API
49 #include <alsa/asoundlib.h>
50 #include <alsa/version.h>
52 /*#define ALSA_DEBUG*/
54 /*****************************************************************************
55 * aout_sys_t: ALSA audio output method descriptor
56 *****************************************************************************
57 * This structure is part of the audio output thread descriptor.
58 * It describes the ALSA specific properties of an audio device.
59 *****************************************************************************/
62 snd_pcm_t * p_snd_pcm;
63 unsigned int i_period_time;
66 snd_output_t * p_snd_stderr;
74 #define A52_FRAME_NB 1536
76 /* These values are in frames.
77 To convert them to a number of bytes you have to multiply them by the
78 number of channel(s) (eg. 2 for stereo) and the size of a sample (eg.
80 #define ALSA_DEFAULT_PERIOD_SIZE 1024
81 #define ALSA_DEFAULT_BUFFER_SIZE ( ALSA_DEFAULT_PERIOD_SIZE << 8 )
82 #define ALSA_SPDIF_PERIOD_SIZE A52_FRAME_NB
83 #define ALSA_SPDIF_BUFFER_SIZE ( ALSA_SPDIF_PERIOD_SIZE << 4 )
84 /* Why << 4 ? --Meuuh */
85 /* Why not ? --Bozo */
88 #define DEFAULT_ALSA_DEVICE "default"
90 /*****************************************************************************
92 *****************************************************************************/
93 static int Open ( vlc_object_t * );
94 static void Close ( vlc_object_t * );
95 static void Play ( audio_output_t * );
96 static void* ALSAThread ( void * );
97 static void ALSAFill ( audio_output_t * );
98 static int FindDevicesCallback( vlc_object_t *p_this, char const *psz_name,
99 vlc_value_t newval, vlc_value_t oldval, void *p_unused );
100 static void GetDevices( vlc_object_t *, module_config_t * );
102 /*****************************************************************************
104 *****************************************************************************/
105 static const char *const ppsz_devices[] = {
106 "default", "plug:front",
107 "plug:side", "plug:rear", "plug:center_lfe",
108 "plug:surround40", "plug:surround41",
109 "plug:surround50", "plug:surround51",
113 static const char *const ppsz_devices_text[] = {
114 N_("Default"), N_("Front speakers"),
115 N_("Side speakers"), N_("Rear speakers"), N_("Center and subwoofer"),
116 N_("Surround 4.0"), N_("Surround 4.1"),
117 N_("Surround 5.0"), N_("Surround 5.1"),
119 N_("HDMI"), N_("S/PDIF"),
122 set_shortname( "ALSA" )
123 set_description( N_("ALSA audio output") )
124 set_category( CAT_AUDIO )
125 set_subcategory( SUBCAT_AUDIO_AOUT )
126 add_string( "alsa-audio-device", DEFAULT_ALSA_DEVICE,
127 N_("ALSA Device Name"), NULL, false )
128 add_deprecated_alias( "alsadev" ) /* deprecated since 0.9.3 */
129 change_string_list( ppsz_devices, ppsz_devices_text, FindDevicesCallback )
130 change_action_add( FindDevicesCallback, N_("Refresh list") )
132 set_capability( "audio output", 150 )
133 set_callbacks( Open, Close )
136 /* VLC will insert a resampling filter in any case, so it is best to turn off
137 * ALSA (plug) resampling. */
138 static const int mode = SND_PCM_NO_AUTO_RESAMPLE
139 /* ALSA just discards extra channels. Not good. Disable it. */
140 | SND_PCM_NO_AUTO_CHANNELS
141 /* VLC is currently unable to leverage ALSA softvol. Disable it. */
142 | SND_PCM_NO_SOFTVOL;
145 * Initializes list of devices.
147 static void Probe (vlc_object_t *obj)
149 /* Due to design bug in audio output core, this hack is required: */
150 if (var_Type (obj, "audio-device"))
153 /* The variable does not exist - first call. */
156 var_Create (obj, "audio-device", VLC_VAR_STRING | VLC_VAR_HASCHOICE);
157 text.psz_string = _("Audio Device");
158 var_Change (obj, "audio-device", VLC_VAR_SETTEXT, &text, NULL);
160 GetDevices (obj, NULL);
162 var_AddCallback (obj, "audio-device", aout_ChannelsRestart, NULL);
163 var_TriggerCallback (obj, "intf-change");
166 /*****************************************************************************
167 * Open: create a handle and open an alsa device
168 *****************************************************************************
169 * This function opens an alsa device, through the alsa API.
171 * Note: the only heap-allocated string is psz_device. All the other pointers
172 * are references to psz_device or to stack-allocated data.
173 *****************************************************************************/
174 static int Open (vlc_object_t *obj)
176 audio_output_t * p_aout = (audio_output_t *)obj;
178 /* Get device name */
181 if (var_Type (p_aout, "audio-device"))
182 psz_device = var_GetString (p_aout, "audio-device");
184 psz_device = var_InheritString( p_aout, "alsa-audio-device" );
185 if (unlikely(psz_device == NULL))
188 snd_pcm_format_t pcm_format; /* ALSA sample format */
189 vlc_fourcc_t fourcc = p_aout->format.i_format;
195 pcm_format = SND_PCM_FORMAT_FLOAT64_BE;
198 pcm_format = SND_PCM_FORMAT_FLOAT64_LE;
201 pcm_format = SND_PCM_FORMAT_FLOAT_BE;
204 pcm_format = SND_PCM_FORMAT_FLOAT_LE;
207 fourcc = VLC_CODEC_FL32;
208 pcm_format = SND_PCM_FORMAT_FLOAT;
211 pcm_format = SND_PCM_FORMAT_S32_BE;
214 pcm_format = SND_PCM_FORMAT_S32_LE;
217 pcm_format = SND_PCM_FORMAT_S24_3BE;
220 pcm_format = SND_PCM_FORMAT_S24_3LE;
223 pcm_format = SND_PCM_FORMAT_U24_3BE;
226 pcm_format = SND_PCM_FORMAT_U24_3LE;
229 pcm_format = SND_PCM_FORMAT_S16_BE;
232 pcm_format = SND_PCM_FORMAT_S16_LE;
235 pcm_format = SND_PCM_FORMAT_U16_BE;
238 pcm_format = SND_PCM_FORMAT_U16_LE;
241 pcm_format = SND_PCM_FORMAT_S8;
244 pcm_format = SND_PCM_FORMAT_U8;
247 if (AOUT_FMT_NON_LINEAR(&p_aout->format))
248 spdif = var_InheritBool (p_aout, "spdif");
251 fourcc = VLC_CODEC_FL32;
252 pcm_format = SND_PCM_FORMAT_FLOAT;
256 fourcc = VLC_CODEC_S16N;
257 pcm_format = SND_PCM_FORMAT_S16;
261 /* Choose the IEC device for S/PDIF output:
262 if the device is overridden by the user then it will be the one
263 otherwise we compute the default device based on the output format. */
264 if (spdif && !strcmp (psz_device, DEFAULT_ALSA_DEVICE))
268 switch (p_aout->format.i_rate)
271 case freq: aes3 = IEC958_AES3_CON_FS_ ## freq; break;
272 FS( 44100) /* def. */ FS( 48000) FS( 32000)
273 FS( 22050) FS( 24000)
274 FS( 88200) FS(768000) FS( 96000)
275 FS(176400) FS(192000)
278 aes3 = IEC958_AES3_CON_FS_NOTID;
283 if (asprintf (&psz_device,
284 "iec958:AES0=0x%x,AES1=0x%x,AES2=0x%x,AES3=0x%x",
285 IEC958_AES0_CON_EMPHASIS_NONE | IEC958_AES0_NONAUDIO,
286 IEC958_AES1_CON_ORIGINAL | IEC958_AES1_CON_PCM_CODER,
291 /* Allocate structures */
292 aout_sys_t *p_sys = malloc (sizeof (*p_sys));
293 if (unlikely(p_sys == NULL))
301 snd_output_stdio_attach( &p_sys->p_snd_stderr, stderr, 0 );
304 /* Open the device */
305 msg_Dbg( p_aout, "opening ALSA device `%s'", psz_device );
306 int val = snd_pcm_open (&p_sys->p_snd_pcm, psz_device,
307 SND_PCM_STREAM_PLAYBACK, mode);
308 #if (SND_LIB_VERSION <= 0x010015)
309 # warning Please update alsa-lib to version > 1.0.21a.
310 var_Create (p_aout->p_libvlc, "alsa-working", VLC_VAR_BOOL);
311 if (val != 0 && var_GetBool (p_aout->p_libvlc, "alsa-working"))
312 dialog_Fatal (p_aout, "ALSA version problem",
313 "VLC failed to re-initialize your audio output device.\n"
314 "Please update alsa-lib to version 1.0.22 or higher "
315 "to fix this issue.");
316 var_SetBool (p_aout->p_libvlc, "alsa-working", !val);
320 #if (SND_LIB_VERSION <= 0x010017)
321 # warning Please update alsa-lib to version > 1.0.23.
322 var_Create (p_aout->p_libvlc, "alsa-broken", VLC_VAR_BOOL);
323 if (!var_GetBool (p_aout->p_libvlc, "alsa-broken"))
325 var_SetBool (p_aout->p_libvlc, "alsa-broken", true);
326 dialog_Fatal (p_aout, "Potential ALSA version problem",
327 "VLC failed to initialize your audio output device (if any).\n"
328 "Please update alsa-lib to version 1.0.24 or higher "
329 "to try to fix this issue.");
332 msg_Err (p_aout, "cannot open ALSA device `%s' (%s)",
333 psz_device, snd_strerror (val));
334 dialog_Fatal (p_aout, _("Audio output failed"),
335 _("The audio device \"%s\" could not be used:\n%s."),
336 psz_device, snd_strerror (val));
343 snd_pcm_uframes_t i_buffer_size;
344 snd_pcm_uframes_t i_period_size;
349 fourcc = VLC_CODEC_SPDIFL;
350 i_buffer_size = ALSA_SPDIF_BUFFER_SIZE;
351 pcm_format = SND_PCM_FORMAT_S16;
354 p_aout->i_nb_samples = i_period_size = ALSA_SPDIF_PERIOD_SIZE;
355 p_aout->format.i_bytes_per_frame = AOUT_SPDIF_SIZE;
356 p_aout->format.i_frame_length = A52_FRAME_NB;
358 aout_VolumeNoneInit( p_aout );
362 i_buffer_size = ALSA_DEFAULT_BUFFER_SIZE;
363 channels = aout_FormatNbChannels( &p_aout->format );
365 p_aout->i_nb_samples = i_period_size = ALSA_DEFAULT_PERIOD_SIZE;
367 aout_VolumeSoftInit( p_aout );
370 p_aout->pf_play = Play;
371 p_aout->pf_pause = NULL;
373 snd_pcm_hw_params_t *p_hw;
374 snd_pcm_sw_params_t *p_sw;
376 snd_pcm_hw_params_alloca(&p_hw);
377 snd_pcm_sw_params_alloca(&p_sw);
379 /* Get Initial hardware parameters */
380 val = snd_pcm_hw_params_any( p_sys->p_snd_pcm, p_hw );
383 msg_Err( p_aout, "unable to retrieve hardware parameters (%s)",
384 snd_strerror( val ) );
389 val = snd_pcm_hw_params_set_format (p_sys->p_snd_pcm, p_hw, pcm_format);
392 msg_Err (p_aout, "cannot set sample format: %s", snd_strerror (val));
396 val = snd_pcm_hw_params_set_access( p_sys->p_snd_pcm, p_hw,
397 SND_PCM_ACCESS_RW_INTERLEAVED );
400 msg_Err( p_aout, "unable to set interleaved stream format (%s)",
401 snd_strerror( val ) );
406 val = snd_pcm_hw_params_set_channels (p_sys->p_snd_pcm, p_hw, channels);
407 if (val < 0 && channels > 2) /* Fallback to stereo */
409 val = snd_pcm_hw_params_set_channels (p_sys->p_snd_pcm, p_hw, 2);
414 msg_Err( p_aout, "unable to set number of output channels (%s)",
415 snd_strerror( val ) );
420 unsigned rate = p_aout->format.i_rate;
421 val = snd_pcm_hw_params_set_rate_near (p_sys->p_snd_pcm, p_hw, &rate,
425 msg_Err (p_aout, "unable to set sampling rate (%s)",
429 if (p_aout->format.i_rate != rate)
430 msg_Warn (p_aout, "resampling from %d Hz to %d Hz",
431 p_aout->format.i_rate, rate);
433 /* Set period size. */
434 val = snd_pcm_hw_params_set_period_size_near( p_sys->p_snd_pcm, p_hw,
435 &i_period_size, NULL );
438 msg_Err( p_aout, "unable to set period size (%s)",
439 snd_strerror( val ) );
442 p_aout->i_nb_samples = i_period_size;
444 /* Set buffer size. */
445 val = snd_pcm_hw_params_set_buffer_size_near( p_sys->p_snd_pcm, p_hw,
449 msg_Err( p_aout, "unable to set buffer size (%s)",
450 snd_strerror( val ) );
454 /* Commit hardware parameters. */
455 val = snd_pcm_hw_params( p_sys->p_snd_pcm, p_hw );
458 msg_Err( p_aout, "unable to commit hardware configuration (%s)",
459 snd_strerror( val ) );
463 val = snd_pcm_hw_params_get_period_time( p_hw, &p_sys->i_period_time,
467 msg_Err( p_aout, "unable to get period time (%s)",
468 snd_strerror( val ) );
472 /* Get Initial software parameters */
473 snd_pcm_sw_params_current( p_sys->p_snd_pcm, p_sw );
475 snd_pcm_sw_params_set_avail_min( p_sys->p_snd_pcm, p_sw,
476 p_aout->i_nb_samples );
477 /* start playing when one period has been written */
478 val = snd_pcm_sw_params_set_start_threshold( p_sys->p_snd_pcm, p_sw,
479 ALSA_DEFAULT_PERIOD_SIZE);
482 msg_Err( p_aout, "unable to set start threshold (%s)",
483 snd_strerror( val ) );
487 /* Commit software parameters. */
488 if ( snd_pcm_sw_params( p_sys->p_snd_pcm, p_sw ) < 0 )
490 msg_Err( p_aout, "unable to set software configuration" );
495 snd_output_printf( p_sys->p_snd_stderr, "\nALSA hardware setup:\n\n" );
496 snd_pcm_dump_hw_setup( p_sys->p_snd_pcm, p_sys->p_snd_stderr );
497 snd_output_printf( p_sys->p_snd_stderr, "\nALSA software setup:\n\n" );
498 snd_pcm_dump_sw_setup( p_sys->p_snd_pcm, p_sys->p_snd_stderr );
499 snd_output_printf( p_sys->p_snd_stderr, "\n" );
502 p_sys->start_date = 0;
503 vlc_sem_init( &p_sys->wait, 0 );
505 /* Create ALSA thread and wait for its readiness. */
506 if( vlc_clone( &p_sys->thread, ALSAThread, p_aout,
507 VLC_THREAD_PRIORITY_OUTPUT ) )
509 msg_Err( p_aout, "cannot create ALSA thread (%m)" );
510 vlc_sem_destroy( &p_sys->wait );
514 p_aout->format.i_format = fourcc;
515 p_aout->format.i_rate = rate;
517 p_aout->format.i_physical_channels = AOUT_CHAN_LEFT|AOUT_CHAN_RIGHT;
523 snd_pcm_close( p_sys->p_snd_pcm );
525 snd_output_close( p_sys->p_snd_stderr );
531 static void PlayIgnore( audio_output_t *p_aout )
532 { /* Already playing - nothing to do */
536 /*****************************************************************************
537 * Play: start playback
538 *****************************************************************************/
539 static void Play( audio_output_t *p_aout )
541 p_aout->pf_play = PlayIgnore;
543 /* get the playing date of the first aout buffer */
544 p_aout->sys->start_date = aout_FifoFirstDate( &p_aout->fifo );
546 /* wake up the audio output thread */
547 sem_post( &p_aout->sys->wait );
550 /*****************************************************************************
551 * Close: close the ALSA device
552 *****************************************************************************/
553 static void Close (vlc_object_t *obj)
555 audio_output_t *p_aout = (audio_output_t *)obj;
556 struct aout_sys_t * p_sys = p_aout->sys;
558 /* Make sure that the thread will stop once it is waken up */
559 vlc_cancel( p_sys->thread );
560 vlc_join( p_sys->thread, NULL );
561 vlc_sem_destroy( &p_sys->wait );
563 snd_pcm_drop( p_sys->p_snd_pcm );
564 snd_pcm_close( p_sys->p_snd_pcm );
566 snd_output_close( p_sys->p_snd_stderr );
571 /*****************************************************************************
572 * ALSAThread: asynchronous thread used to DMA the data to the device
573 *****************************************************************************/
574 static void* ALSAThread( void *data )
576 audio_output_t * p_aout = data;
577 struct aout_sys_t * p_sys = p_aout->sys;
579 /* Wait for the exact time to start playing (avoids resampling) */
580 vlc_sem_wait( &p_sys->wait );
581 mwait( p_sys->start_date - AOUT_MAX_PTS_ADVANCE / 4 );
582 #warning Should wait for buffer availability instead!
590 /*****************************************************************************
591 * ALSAFill: function used to fill the ALSA buffer as much as possible
592 *****************************************************************************/
593 static void ALSAFill( audio_output_t * p_aout )
595 struct aout_sys_t * p_sys = p_aout->sys;
596 snd_pcm_t *p_pcm = p_sys->p_snd_pcm;
597 snd_pcm_status_t * p_status;
601 int canc = vlc_savecancel();
602 /* Fill in the buffer until space or audio output buffer shortage */
605 snd_pcm_status_alloca(&p_status);
606 i_snd_rc = snd_pcm_status( p_pcm, p_status );
609 msg_Err( p_aout, "cannot get device status" );
613 /* Handle buffer underruns and get the status again */
614 if( snd_pcm_status_get_state( p_status ) == SND_PCM_STATE_XRUN )
616 /* Prepare the device */
617 i_snd_rc = snd_pcm_prepare( p_pcm );
620 msg_Err( p_aout, "cannot recover from buffer underrun" );
624 msg_Dbg( p_aout, "recovered from buffer underrun" );
626 /* Get the new status */
627 i_snd_rc = snd_pcm_status( p_pcm, p_status );
630 msg_Err( p_aout, "cannot get device status after recovery" );
634 /* Underrun, try to recover as quickly as possible */
639 /* Here the device should be in RUNNING state, p_status is valid. */
640 snd_pcm_sframes_t delay = snd_pcm_status_get_delay( p_status );
641 if( delay == 0 ) /* workaround buggy alsa drivers */
642 if( snd_pcm_delay( p_pcm, &delay ) < 0 )
643 delay = 0; /* FIXME: use a positive minimal delay */
645 size_t i_bytes = snd_pcm_frames_to_bytes( p_pcm, delay );
646 mtime_t delay_us = CLOCK_FREQ * i_bytes
647 / p_aout->format.i_bytes_per_frame
648 / p_aout->format.i_rate
649 * p_aout->format.i_frame_length;
652 snd_pcm_state_t state = snd_pcm_status_get_state( p_status );
653 if( state != SND_PCM_STATE_RUNNING )
654 msg_Err( p_aout, "pcm status (%d) != RUNNING", state );
656 msg_Dbg( p_aout, "Delay is %ld frames (%zu bytes)", delay, i_bytes );
658 msg_Dbg( p_aout, "Bytes per frame: %d", p_aout->format.i_bytes_per_frame );
659 msg_Dbg( p_aout, "Rate: %d", p_aout->format.i_rate );
660 msg_Dbg( p_aout, "Frame length: %d", p_aout->format.i_frame_length );
661 msg_Dbg( p_aout, "Next date: in %"PRId64" microseconds", delay_us );
663 next_date = mdate() + delay_us;
666 block_t *p_buffer = aout_OutputNextBuffer( p_aout, next_date,
667 (p_aout->format.i_format == VLC_CODEC_SPDIFL) );
669 /* Audio output buffer shortage -> stop the fill process and wait */
670 if( p_buffer == NULL )
673 block_cleanup_push( p_buffer );
676 int n = snd_pcm_poll_descriptors_count(p_pcm);
677 struct pollfd ufd[n];
678 unsigned short revents;
680 snd_pcm_poll_descriptors(p_pcm, ufd, n);
683 vlc_restorecancel(canc);
685 canc = vlc_savecancel();
686 snd_pcm_poll_descriptors_revents(p_pcm, ufd, n, &revents);
690 if(revents & POLLOUT)
692 i_snd_rc = snd_pcm_writei( p_pcm, p_buffer->p_buffer,
693 p_buffer->i_nb_samples );
694 if( i_snd_rc != -ESTRPIPE )
698 /* a suspend event occurred
699 * (stream is suspended and waiting for an application recovery) */
700 msg_Dbg( p_aout, "entering in suspend mode, trying to resume..." );
702 while( ( i_snd_rc = snd_pcm_resume( p_pcm ) ) == -EAGAIN )
704 vlc_restorecancel(canc);
705 msleep(CLOCK_FREQ); /* device still suspended, wait... */
706 canc = vlc_savecancel();
710 /* Device does not support resuming, restart it */
711 i_snd_rc = snd_pcm_prepare( p_pcm );
716 msg_Err( p_aout, "cannot write: %s", snd_strerror( i_snd_rc ) );
718 vlc_restorecancel(canc);
724 msg_Err( p_aout, "ALSA error: %s", snd_strerror( i_snd_rc ) );
726 vlc_restorecancel(canc);
727 msleep(p_sys->i_period_time / 2);
730 /*****************************************************************************
731 * config variable callback
732 *****************************************************************************/
733 static int FindDevicesCallback( vlc_object_t *p_this, char const *psz_name,
734 vlc_value_t newval, vlc_value_t oldval, void *p_unused )
736 module_config_t *p_item;
741 p_item = config_FindConfig( p_this, psz_name );
742 if( !p_item ) return VLC_SUCCESS;
744 /* Clear-up the current list */
749 /* Keep the first entrie */
750 for( i = 1; i < p_item->i_list; i++ )
752 free( (char *)p_item->ppsz_list[i] );
753 free( (char *)p_item->ppsz_list_text[i] );
755 /* TODO: Remove when no more needed */
756 p_item->ppsz_list[i] = NULL;
757 p_item->ppsz_list_text[i] = NULL;
761 GetDevices( p_this, p_item );
763 /* Signal change to the interface */
764 p_item->b_dirty = true;
770 static void GetDevices (vlc_object_t *obj, module_config_t *item)
774 msg_Dbg(obj, "Available ALSA PCM devices:");
776 if (snd_device_name_hint(-1, "pcm", &hints) < 0)
779 for (size_t i = 0; hints[i] != NULL; i++)
781 void *hint = hints[i];
784 char *name = snd_device_name_get_hint(hint, "NAME");
785 if (unlikely(name == NULL))
787 if (unlikely(asprintf (&dev, "plug:'%s'", name) == -1))
793 char *desc = snd_device_name_get_hint(hint, "DESC");
795 for (char *lf = strchr(desc, '\n'); lf; lf = strchr(lf, '\n'))
797 msg_Dbg(obj, "%s (%s)", (desc != NULL) ? desc : name, name);
801 item->ppsz_list = xrealloc(item->ppsz_list,
802 (item->i_list + 2) * sizeof(char *));
803 item->ppsz_list_text = xrealloc(item->ppsz_list_text,
804 (item->i_list + 2) * sizeof(char *));
805 item->ppsz_list[item->i_list] = dev;
808 item->ppsz_list_text[item->i_list] = desc;
813 vlc_value_t val, text;
815 val.psz_string = dev;
816 text.psz_string = desc;
817 var_Change(obj, "audio-device", VLC_VAR_ADDCHOICE, &val, &text);
824 snd_device_name_free_hint(hints);
828 item->ppsz_list[item->i_list] = NULL;
829 item->ppsz_list_text[item->i_list] = NULL;