Does libvlc_audio_output_device_set work?
Posted: 01 Mar 2012 22:43
I am trying to use the libvlc api in Windows7 to specify the audio device to output to.
This command works from the command line
C:\Temp>"C:\Program Files (x86)\VideoLAn\vlc\vlc" --waveout-audio-device="Speakers (High Definition Audio ($1,$ffff)" poker_music.mp3
I can get it to work in the UI too. But I can not get libvlc_audio_output_device_set() to work. It always plays to the default sound device regardless of what I do.
I am using the library from the ftp site, version 2.0.0 (http://download.videolan.org/pub/videol ... 0.0/win32/) checked out yesterday and dated 2/17/2012.
Using the libvlc api to iterate through the audio output devices, this is what I see
Number of audio devices = 3
id, longname
1. wavemapper, Microsoft Soundmapper
2. Speakers (USB Audio Device) ($ffff,$ffff), Speakers (USB Audio Device) ($ffff,$ffff)
3. Speakers (High Definition Audio ($1,$ffff),Speakers (High Definition Audio ($1,$ffff)
This is the code that I am using where libvlc_audio_output_device_set() does not work. Can someone tell me what I am doing wrong?
Notice in the commented out code that I have tried switching the output in the vlc instance constructor and with libvlc_media_add_option. Nothing works.
int _tmain(int argc, _TCHAR* argv[])
{
libvlc_instance_t *vlcInstance;
libvlc_media_player_t *vlcMediaPlayer;
libvlc_media_t *vlcMedia;
vlcInstance = libvlc_new (0, NULL);
//const char * const vlc_args[] = {"--waveout-audio-device=\"Speakers (High Definition Audio ($1,$ffff)\""};
//const char * const vlc_args[] = {"--aout=waveout --waveout-audio-device=\"Speakers (High Definition Audio ($1,$ffff)\""};
//vlcInstance = libvlc_new (sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args);
vlcMediaPlayer = libvlc_media_player_new(vlcInstance);
int numAudioDevices = libvlc_audio_output_device_count(vlcInstance, "waveout");
printf ("Number of audio devices = %d\n", numAudioDevices);
for(int i = 0; i < numAudioDevices; i++)
{
printf ("%s\n", libvlc_audio_output_device_id(vlcInstance, "waveout", i));
printf ("%s\n", libvlc_audio_output_device_longname(vlcInstance, "waveout", i));
printf ("\n");
}
libvlc_audio_output_set(vlcMediaPlayer, "waveout");
libvlc_audio_output_device_set(vlcMediaPlayer, "Speakers (High Definition Audio ($1,$ffff)", "Speakers (High Definition Audio ($1,$ffff)");
vlcMedia = libvlc_media_new_path(vlcInstance, "C:\\Temp\\poker_music.mp3");
// libvlc_media_add_option(vlcMedia, "--waveout-audio-device=\"Speakers (High Definition Audio ($1,$ffff)\"");
// libvlc_media_add_option(vlcMedia, "--aout=waveout --waveout-audio-device=\"Speakers (High Definition Audio ($1,$ffff)\"");
libvlc_media_player_set_media (vlcMediaPlayer, vlcMedia);
libvlc_media_release(vlcMedia);
libvlc_media_player_play(vlcMediaPlayer);
libvlc_state_t vlcMediaPlayerState;
do
{
vlcMediaPlayerState = libvlc_media_player_get_state(vlcMediaPlayer);
} while (vlcMediaPlayerState != libvlc_Ended);
libvlc_media_player_stop(vlcMediaPlayer);
libvlc_media_player_release(vlcMediaPlayer);
libvlc_release(vlcInstance);
return 0;
}
What am I missing?
Or is libvlc_audio_output_device_set() broken? If so, is there a work around?
This command works from the command line
C:\Temp>"C:\Program Files (x86)\VideoLAn\vlc\vlc" --waveout-audio-device="Speakers (High Definition Audio ($1,$ffff)" poker_music.mp3
I can get it to work in the UI too. But I can not get libvlc_audio_output_device_set() to work. It always plays to the default sound device regardless of what I do.
I am using the library from the ftp site, version 2.0.0 (http://download.videolan.org/pub/videol ... 0.0/win32/) checked out yesterday and dated 2/17/2012.
Using the libvlc api to iterate through the audio output devices, this is what I see
Number of audio devices = 3
id, longname
1. wavemapper, Microsoft Soundmapper
2. Speakers (USB Audio Device) ($ffff,$ffff), Speakers (USB Audio Device) ($ffff,$ffff)
3. Speakers (High Definition Audio ($1,$ffff),Speakers (High Definition Audio ($1,$ffff)
This is the code that I am using where libvlc_audio_output_device_set() does not work. Can someone tell me what I am doing wrong?
Notice in the commented out code that I have tried switching the output in the vlc instance constructor and with libvlc_media_add_option. Nothing works.
int _tmain(int argc, _TCHAR* argv[])
{
libvlc_instance_t *vlcInstance;
libvlc_media_player_t *vlcMediaPlayer;
libvlc_media_t *vlcMedia;
vlcInstance = libvlc_new (0, NULL);
//const char * const vlc_args[] = {"--waveout-audio-device=\"Speakers (High Definition Audio ($1,$ffff)\""};
//const char * const vlc_args[] = {"--aout=waveout --waveout-audio-device=\"Speakers (High Definition Audio ($1,$ffff)\""};
//vlcInstance = libvlc_new (sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args);
vlcMediaPlayer = libvlc_media_player_new(vlcInstance);
int numAudioDevices = libvlc_audio_output_device_count(vlcInstance, "waveout");
printf ("Number of audio devices = %d\n", numAudioDevices);
for(int i = 0; i < numAudioDevices; i++)
{
printf ("%s\n", libvlc_audio_output_device_id(vlcInstance, "waveout", i));
printf ("%s\n", libvlc_audio_output_device_longname(vlcInstance, "waveout", i));
printf ("\n");
}
libvlc_audio_output_set(vlcMediaPlayer, "waveout");
libvlc_audio_output_device_set(vlcMediaPlayer, "Speakers (High Definition Audio ($1,$ffff)", "Speakers (High Definition Audio ($1,$ffff)");
vlcMedia = libvlc_media_new_path(vlcInstance, "C:\\Temp\\poker_music.mp3");
// libvlc_media_add_option(vlcMedia, "--waveout-audio-device=\"Speakers (High Definition Audio ($1,$ffff)\"");
// libvlc_media_add_option(vlcMedia, "--aout=waveout --waveout-audio-device=\"Speakers (High Definition Audio ($1,$ffff)\"");
libvlc_media_player_set_media (vlcMediaPlayer, vlcMedia);
libvlc_media_release(vlcMedia);
libvlc_media_player_play(vlcMediaPlayer);
libvlc_state_t vlcMediaPlayerState;
do
{
vlcMediaPlayerState = libvlc_media_player_get_state(vlcMediaPlayer);
} while (vlcMediaPlayerState != libvlc_Ended);
libvlc_media_player_stop(vlcMediaPlayer);
libvlc_media_player_release(vlcMediaPlayer);
libvlc_release(vlcInstance);
return 0;
}
What am I missing?
Or is libvlc_audio_output_device_set() broken? If so, is there a work around?