PulseAudio Errors with LibVNC...
Posted: 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:
Occasionally I get this wad (and more) of errors, but .wav's still play....
Thank you for your help,
Matt Dralle
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:
When playing a .wav: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.
[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....
My Sound.c[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:
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