PulseAudio Errors with LibVNC...

This forum is about all development around libVLC.
MattDralle
New Cone
New Cone
Posts: 2
Joined: 23 Nov 2021 01:44

PulseAudio Errors with LibVNC...

Postby MattDralle » 23 Nov 2021 03:43

I'm building a C application on a HardKernel Odroid C4 with Ubuntu. My LibVLC specific code is below. I have uninstall PulseAudio as I don't need it's functionality. I have a generic USB 2.0 audio speaker plugged in that works great with aplay and other Alsa aware apps. In fact, I've got the lvlc library working and .wav sounds playing as needed over the USB 2.0 speakers. The problem is that the lvlc library seems to really wants to see the PulseAudio driver and complains that its not there, despite that it plays the audio files just fine. It dumps tons of error to stdout which I use for my Apps output, so it's quite a cluttered mess. My Questions are these: are there flags I can send to lvlc to 1) not look for PulseAudio, and 2) disable debug output?

I'm calling the PlaySound_xxx() functions in a thread so that the sound playing doesn't block my main program.

The Errors I'm seeing whenever I play a .wav file is:

On Init:
Initializing: VLC Sound System...
Loading Sound: "./Sounds/BubbleClick1.wav"
[xxx] vlcpulse audio output error: PulseAudio server connection failure: Connection refused
Loading Sound: "./Sounds/ChimesSound.wav"
[xxx] vlcpulse audio output error: PulseAudio server connection failure: Connection refused
Loading Sound: "./Sounds/Beep_1000Hz_3000Hz_.25s.wav"
[xxx] vlcpulse audio output error: PulseAudio server connection failure: Connection refused
Loading Sound: "./Sounds/Blast_1000Hz_3000Hz_1s.wav"
[xxx] vlcpulse audio output error: PulseAudio server connection failure: Connection refused
Initializing: Sound System Complete.
When playing a .wav:

[xxx] vlcpulse audio output error: PulseAudio server connection failure: Connection refused


Occasionally I get this wad (and more) of errors, but .wav's still play....
[xxx] alsa audio output error: cannot open ALSA device "default": Device or resource busy
[xxx] main audio output error: Audio output failed
[xxx] main audio output error: The audio device "default" could not be used:
Device or resource busy.
[xxx] main audio output error: module not functional
[xxx] main decoder error: failed to create audio output
[xxx] alsa audio output error: cannot open ALSA device "default": Device or resource busy
[xxx] main audio output error: Audio output failed
[xxx] main audio output error: The audio device "default" could not be used:
My Sound.c

Code: Select all

#include <stdio.h> #include <stdlib.h> #include <vlc/vlc.h> #include <unistd.h> libvlc_instance_t * VLCInstance; int SoundsCount = 0; char MySounds[TOTAL_NUMBER_OF_SOUNDS][MAX_SOUND_NAME_LEN] = { "Button Click", "Chimes Sound", "Sound Beep", "Sound Blast", "Mode Select" }; struct SoundStructures Sounds[ MAX_SOUND_COUNT ]; int InitSoundSystem( void ) { farprintfDebugInfoHeader( DEBUG ); printf( "Initializing: VLC Sound System...\n"); /* Load the VLC engine */ VLCInstance = libvlc_new (0, NULL); LoadSoundFile( Sound_ButtonClick, Sound_ButtonClick, 250, "./Sounds/BubbleClick1.wav" ); LoadSoundFile( Sound_Chimes, Sound_Chimes, 5000, "./Sounds/ChimesSound.wav" ); LoadSoundFile( Sound_Beep, Sound_Beep, 600, "./Sounds/Beep_1000Hz_3000Hz_.25s.wav" ); LoadSoundFile( Sound_Blast, Sound_Blast, 1500, "./Sounds/Blast_1000Hz_3000Hz_1s.wav" ); farprintfDebugInfoHeader( DEBUG ); printf( "Initializing: Sound System Complete.\r\n"); return 0; } int LoadSoundFile( unsigned char SoundID, unsigned char SoundsCount, unsigned int Length, unsigned char * FileName ) { farprintfDebugInfoHeader( DEBUG ); printf( "Loading Sound: \"%s\"\r\n", FileName ); Sounds[ SoundsCount ].SoundID = SoundID; Sounds[ SoundsCount ].Length = Length; strcpy( Sounds[ SoundsCount ].FileName, FileName ); Sounds[ SoundsCount ].SoundFileObject = libvlc_media_new_path( VLCInstance, Sounds[ SoundsCount ].FileName ); Sounds[ SoundsCount ].MediaPlayerObject = libvlc_media_player_new_from_media( Sounds[ SoundsCount ].SoundFileObject ); libvlc_media_release( Sounds[ SoundsCount ].SoundFileObject ); return 1; } void PlaySound( unsigned int SoundsIndex ) { if( Sounds[ SoundsIndex ].Playing ) return; Sounds[ SoundsIndex ].Playing = TRUE; /* play the media_player */ libvlc_media_player_play( Sounds[ SoundsIndex ].MediaPlayerObject ); usleep( Sounds[ SoundsIndex ].Length * 1000 ); /* Let it play a bit */ /* Stop playing */ libvlc_media_player_stop( Sounds[ SoundsIndex ].MediaPlayerObject ); Sounds[ SoundsIndex ].Playing = FALSE; /* Free the media_player */ // libvlc_media_player_release (mp); // libvlc_release (inst); } void * PlaySound_ButtonClick( void * peram ) { PlaySound( Sound_ButtonClick ); } void * PlaySound_Chimes( void * peram ) { PlaySound( Sound_Chimes ); } void * PlaySound_Beep( void * peram ) { PlaySound( Sound_Beep ); } void * PlaySound_Blast( void * peram ) { PlaySound( Sound_Blast ); }

Thank you for your help,

Matt Dralle

Rémi Denis-Courmont
Developer
Developer
Posts: 15267
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: PulseAudio Errors with LibVNC...

Postby Rémi Denis-Courmont » 23 Nov 2021 20:17

Another application is monopolising the ALSA device. This is what happens when you remove PulseAudio. Not sure what you expect.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

MattDralle
New Cone
New Cone
Posts: 2
Joined: 23 Nov 2021 01:44

Re: PulseAudio Errors with LibVNC...

Postby MattDralle » 23 Nov 2021 20:40

I added the following right after "VLCInstance = libvlc_new (0, NULL);":

libvlc_log_unset( VLCInstance );

No more stderr log messages. Everything's working great now. Whew.

Matt Dralle

chubinou
Developer
Developer
Posts: 521
Joined: 23 Jul 2015 15:19

Re: PulseAudio Errors with LibVNC...

Postby chubinou » 25 Nov 2021 11:39

you can force the audio output to use alsa by default by passing "--aout=alsa" to libvlc_new


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 18 guests