LibVLC Set Output Device not working (C++, R.Pi, Analog Out)
Posted: 30 Jul 2018 10:50
Hello everybody,
I turn to you because I need help.
I'd like to tell the LibVLC library that Alsa Sound should be used instead of PulseAudio. But this does not work / take effect.
My project:
I use the RaspberryPi with Raspian and CodeLite and C ++ (gcc). In the project I use oled display, analogue audio, nfc, ky040 rotary encoders, lis3dh accel., Rgb led, etc and everything is already wired and the classes all work.
Except with the analog audio over LibVLC I still have problems.
First, LibVLC made crackling at the beginning of playback. In addition, I could not change the audio output to "analog audio". Something has set the output exclusively to HDMI (no matter if HDMI was connected / not connected).
After some searching (I am new on the RaspberryPi) I have identified and uninstalled PulseAudio as source. The problem was solved.
But: When playing mp3 files with LibVLC I get the message:
pulse audio output error: PulseAudio server connection failure: Connection refused
of course, its not installed anymore (but sound is playing).
I use this function to load a file and create the madiaplayer + switching to alsa sound modul:
I have checked if the output module and the output device are present:
I get the following modules and devices:
So why does libvlc_audio_output_set and libvlc_audio_output_device_set not work as it should? PulseAudio should no longer be used when playing (and thus produce no error message).
I turn to you because I need help.
I'd like to tell the LibVLC library that Alsa Sound should be used instead of PulseAudio. But this does not work / take effect.
My project:
I use the RaspberryPi with Raspian and CodeLite and C ++ (gcc). In the project I use oled display, analogue audio, nfc, ky040 rotary encoders, lis3dh accel., Rgb led, etc and everything is already wired and the classes all work.
Except with the analog audio over LibVLC I still have problems.
First, LibVLC made crackling at the beginning of playback. In addition, I could not change the audio output to "analog audio". Something has set the output exclusively to HDMI (no matter if HDMI was connected / not connected).
After some searching (I am new on the RaspberryPi) I have identified and uninstalled PulseAudio as source. The problem was solved.
But: When playing mp3 files with LibVLC I get the message:
pulse audio output error: PulseAudio server connection failure: Connection refused
of course, its not installed anymore (but sound is playing).
I use this function to load a file and create the madiaplayer + switching to alsa sound modul:
Code: Select all
libvlc_media_t *media;
media = libvlc_media_new_path(inst, filename.c_str());// create a new item
if(media!=NULL){
mp = libvlc_media_player_new_from_media(media);// create a media play playing environment
libvlc_audio_output_set(mp, "alsa");
libvlc_audio_output_device_set(mp, "alsa", "default:CARD=ALSA");
}
I have checked if the output module and the output device are present:
Code: Select all
libvlc_audio_output_t* audio_output = libvlc_audio_output_list_get(inst);
while(audio_output!=NULL){
printf("AudioOutput: %s (%s)\n", audio_output->psz_name, audio_output->psz_description);
libvlc_audio_output_device_t* audio_output_device = libvlc_audio_output_device_list_get(inst, audio_output->psz_name);
while(audio_output_device!=NULL){
printf(" - %s (%s)\n", audio_output_device->psz_device, audio_output_device->psz_description);
audio_output_device = audio_output_device->p_next;
}
libvlc_audio_output_device_list_release(audio_output_device);
audio_output = audio_output->p_next;
}
libvlc_audio_output_list_release(audio_output);
I get the following modules and devices:
Code: Select all
AudioOutput: amem (Audio memory output)
AudioOutput: sndio (OpenBSD sndio audio output)
AudioOutput: pulse (Pulseaudio audio output)
AudioOutput: alsa (ALSA audio output)
- null (Discard all samples (playback) or generate zero samples (capture))
- default:CARD=ALSA (bcm2835 ALSA, bcm2835 ALSA Default Audio Device)
- sysdefault:CARD=ALSA (bcm2835 ALSA, bcm2835 ALSA Default Audio Device)
- dmix:CARD=ALSA,DEV=0 (bcm2835 ALSA, bcm2835 ALSA Direct sample mixing device)
- dmix:CARD=ALSA,DEV=1 (bcm2835 ALSA, bcm2835 IEC958/HDMI Direct sample mixing device)
- dsnoop:CARD=ALSA,DEV=0 (bcm2835 ALSA, bcm2835 ALSA Direct sample snooping device)
- dsnoop:CARD=ALSA,DEV=1 (bcm2835 ALSA, bcm2835 IEC958/HDMI Direct sample snooping device)
- hw:CARD=ALSA,DEV=0 (bcm2835 ALSA, bcm2835 ALSA Direct hardware device without any conversions)
- hw:CARD=ALSA,DEV=1 (bcm2835 ALSA, bcm2835 IEC958/HDMI Direct hardware device without any conversions)
- plughw:CARD=ALSA,DEV=0 (bcm2835 ALSA, bcm2835 ALSA Hardware device with all software conversions)
- plughw:CARD=ALSA,DEV=1 (bcm2835 ALSA, bcm2835 IEC958/HDMI Hardware device with all software conversions)
- default (Default)
AudioOutput: adummy (Dummy audio output)
AudioOutput: afile (File audio output)
So why does libvlc_audio_output_set and libvlc_audio_output_device_set not work as it should? PulseAudio should no longer be used when playing (and thus produce no error message).