[vlc-commits] ALSA: destroy audio-device at exit (refs #6874)
Rémi Denis-Courmont
git at videolan.org
Sun May 27 18:57:27 CEST 2012
vlc/vlc-2.0 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun May 27 19:50:19 2012 +0300| [f48fde01f3ae673520744ba7189ed1e8896b7edb] | committer: Rémi Denis-Courmont
ALSA: destroy audio-device at exit (refs #6874)
(cherry picked from commit 3b0b4fb354db179353d4d319484f1711f979de58)
> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.0.git/?a=commit;h=f48fde01f3ae673520744ba7189ed1e8896b7edb
---
modules/audio_output/alsa.c | 34 ++++++++++++++++++----------------
1 file changed, 18 insertions(+), 16 deletions(-)
diff --git a/modules/audio_output/alsa.c b/modules/audio_output/alsa.c
index 393fe01..a29b3fa 100644
--- a/modules/audio_output/alsa.c
+++ b/modules/audio_output/alsa.c
@@ -148,18 +148,14 @@ static void DumpDeviceStatus (vlc_object_t *obj, snd_pcm_t *pcm)
*/
static void Probe (vlc_object_t *obj, const char *dev)
{
- /* Due to design bug in audio output core, this hack is required: */
- if (var_Type (obj, "audio-device") == 0)
- {
- /* The variable does not exist - first call. */
- vlc_value_t text;
+ vlc_value_t text;
- var_Create (obj, "audio-device", VLC_VAR_STRING | VLC_VAR_HASCHOICE);
- text.psz_string = _("Audio Device");
- var_Change (obj, "audio-device", VLC_VAR_SETTEXT, &text, NULL);
+ var_Create (obj, "audio-device", VLC_VAR_STRING | VLC_VAR_HASCHOICE);
+ text.psz_string = _("Audio Device");
+ var_Change (obj, "audio-device", VLC_VAR_SETTEXT, &text, NULL);
+
+ GetDevices (obj, NULL, dev);
- GetDevices (obj, NULL, dev);
- }
var_AddCallback (obj, "audio-device", aout_ChannelsRestart, NULL);
var_TriggerCallback (obj, "intf-change");
}
@@ -176,12 +172,7 @@ static int Open (vlc_object_t *obj)
audio_output_t *aout = (audio_output_t *)obj;
/* Get device name */
- char *device;
-
- if (var_Type (aout, "audio-device"))
- device = var_GetString (aout, "audio-device");
- else
- device = var_InheritString (aout, "alsa-audio-device");
+ char *device = var_InheritString (aout, "alsa-audio-device");
if (unlikely(device == NULL))
return VLC_ENOMEM;
@@ -663,7 +654,18 @@ static void Close (vlc_object_t *obj)
aout_sys_t *sys = aout->sys;
snd_pcm_t *pcm = aout->sys->pcm;
+ /* FIXME: ugly hack so selected ALSA device survives restart */
+ char *device = var_InheritString (obj, "audio-device");
+ if (device != NULL)
+ {
+ if (!var_Type (obj, "alsa-audio-device"))
+ var_Create (obj, "alsa-audio-device", VLC_VAR_STRING);
+ var_SetString (obj, "alsa-audio-device", device);
+ free (device);
+ }
+
var_DelCallback (obj, "audio-device", aout_ChannelsRestart, NULL);
+ var_Destroy (obj, "audio-device");
snd_pcm_drop (pcm);
snd_pcm_close (pcm);
free (sys);
More information about the vlc-commits
mailing list