Thanks for the post Remi.
1.) My call to libvlc_new() is like this:
/* Load the VLC engine */
inst = libvlc_new (0, NULL);
Does this look correct?
2.) I don't believe I am using an custom callbacks.
3.) Here is my code below toggling between audio output devices.
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <vlc/vlc.h> // old
#include <vlc/libvlc_media_player.h>
int main(int argc, char* argv[])
{
libvlc_instance_t * inst;
libvlc_media_player_t *mp;
libvlc_media_t *m;
libvlc_audio_output_t *audio_list;
int var_test = 0;
libvlc_audio_output_device_t *audio_output_list;
int i = 0;
char debug_string[500];
int64_t delayplayer = 100;
printf("This is going somewhere.....\n\n\n");
/* Load the VLC engine */
inst = libvlc_new (0, NULL);
/////////////////////////////////////////////////////////////////////////////////
// The list here will give me the list of available output modules.
// we wnat to be using the alsa module.
/////////////////////////////////////////////////////////////////////////////////
audio_list = libvlc_audio_output_list_get(inst);
printf("Print out all the audio modules here......\n\n");
for ( var_test =0; var_test < 6; var_test++)
{
printf("The address of the pointer here %X \n", audio_list);
printf("The psz_name field is %s \n", audio_list->psz_name);
printf("The psz_descriptoin is %s \n", audio_list->psz_description);
printf("The psz_descriptoin field is %X \n\n\n", audio_list->p_next);
audio_list = audio_list->p_next;
}
// Free's the list of available audio output modules
libvlc_audio_output_list_release(audio_list);
/////////////////////////////////////////////////////////////////////////////////
// Here I am getting a list of audio output devices for a given audio output
///////////////////////////////////////////////////////////////////////////////
audio_output_list = libvlc_audio_output_device_list_get(inst,"alsa");
printf("Printing out all the audio outputs here......\n\n");
for ( var_test =0; var_test < 18; var_test++)
{
printf("The address of the pointer here %X \n", audio_output_list);
printf("The psz_name (device ID) field is %s \n", audio_output_list->psz_device);
printf("The psz_descriptoin is %s \n", audio_output_list->psz_description);
printf("Next entry in list: %X \n\n\n", audio_output_list->p_next);
audio_output_list = audio_output_list->p_next;
}
libvlc_audio_output_device_list_release(audio_output_list);
//////////////////////////////////////////////////////////////////////
/* Create a new item */
m = libvlc_media_new_path (inst, "/home/pi/libvlc/h.mp4");
/* Create a media player playing environement */
mp = libvlc_media_player_new_from_media (m);
/* No need to keep the media now */
libvlc_media_release (m);
/////////////////////////////////////////////////
libvlc_audio_output_set(mp,"alsa"); // This has to be here or audio wil not play
/////////////////////////////////////////////////////////////
// This will play to the external speakers and sound bar
libvlc_audio_output_device_set(mp,"alsa","hw:CARD=sndrpihifiberry,DEV=0"); // Audio 1
// libvlc_audio_output_device_set(mp,"alsa","hw:CARD=ALSA,DEV=1"); // Audio 2 TV
libvlc_audio_output_set(mp,"alsa"); // This has to be here or audio wil not play
printf("\n\nStarting the player.....\n\n\n");
libvlc_media_player_play (mp);
sleep (10);
printf("Doing the switch....\n");
libvlc_audio_output_device_set(mp,NULL,"hw:CARD=ALSA,DEV=1");
sleep (10);
libvlc_audio_output_device_set(mp,NULL,"hw:CARD=sndrpihifiberry,DEV=0"); // Audio 1
sleep (10);
libvlc_audio_output_device_set(mp,NULL,"hw:CARD=ALSA,DEV=1");
sleep (10);
printf("\n\nStopping the player \n\n\n");
/* Stop playing */
libvlc_media_player_stop (mp);
/* Free the media_player */
libvlc_media_player_release (mp);
libvlc_release (inst);
return 0;
}
Any ideas?
Thanks.
-Mike