Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stderr flooded with debugging messages #739

Open
uti5 opened this issue Oct 17, 2022 · 12 comments
Open

Stderr flooded with debugging messages #739

uti5 opened this issue Oct 17, 2022 · 12 comments
Labels
P3 Priority: Normal src-alsa ALSA Host API /src/hostapi/alsa src-jack JACK Audio Connection Kit Host API /src/hostapi/jack

Comments

@uti5
Copy link

uti5 commented Oct 17, 2022

Is there a way to use portaudio in a command-line program without getting stderr flooded with debugging messages?

@RossBencina
Copy link
Collaborator

There are multiple ways:

  1. Make sure that PA_ENABLE_DEBUG_OUTPUT is not defined when you build PortAudio.
    or
  2. Redirect error logging by registering a callback with PaUtil_SetDebugPrintFunction see padebugprint.h

@uti5
Copy link
Author

uti5 commented Oct 18, 2022

Doesn't (1) correspond to ./configure --enable-debug-output=no,
which is the default? As for (2), the user doesn't seem to have
access to that function.

To be specific, my problem is that, even with the above configure
option, just

#include <portaudio.h>

int main()
{
	Pa_Initialize();
	Pa_Terminate();
}

prints this

ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_route.c:877:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:877:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:877:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:877:(find_matching_chmap) Found no matching channel map
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock

to stderr.

@RossBencina
Copy link
Collaborator

Those messages are not generated by PortAudio. You would need to work out how to make ALSA and JACK be quiet -- for example by fixing the configuration issues that result in those errors.

@RossBencina
Copy link
Collaborator

Seems like a duplicate of this: #555

@uti5
Copy link
Author

uti5 commented Oct 24, 2022

I thought it was the role of portaudio to talk to alsa and jack for the user? (In case you meant to dismiss this as not a portaudio issue.) It seems that there is an alsa ``debug'' option that can be set to 0, but I'm having a hard time figuring out how.

@RossBencina
Copy link
Collaborator

RossBencina commented Nov 7, 2022

I thought it was the role of portaudio to talk to alsa and jack for the user?

As far as I understand, the error messages arise because ALSA is misconfigured (i.e. your system-level ALSA config files are borked). PortAudio does not take responsibility at that level.

If you think that PortAudio could somehow do something better in this situation, please could you explain.

@RossBencina RossBencina added src-alsa ALSA Host API /src/hostapi/alsa src-jack JACK Audio Connection Kit Host API /src/hostapi/jack labels Nov 7, 2022
@uti5
Copy link
Author

uti5 commented Nov 8, 2022

Would it be possible to add an option to redirect these warnings away
from stderr, and, if necessary, everything printed to stderr while
Portaudio does the things that would trigger them?

If ALSA is misconfigured, it is so on both Void Linux and Kubuntu (and
probably Ubuntu and other distributions). And I suppose Jack must be
misconfigured too.

@fredvs
Copy link

fredvs commented Nov 13, 2022

@uti5 : If you want a fast-clean solution for your C applications: #555 (comment)
and for your Pascal applications: fredvs/uos#33 (comment)

@RossBencina
Copy link
Collaborator

First, please keep in mind that although I am a maintainer of PortAudio I do not generally work with ALSA or Linux. We have a lack of contributors in this area, which is why I am responding.

Regarding the ALSA messages there's some discussion here:

https://stackoverflow.com/questions/31603555/unknown-pcm-cards-pcm-rear-pyaudio
https://stackoverflow.com/questions/7088672/pyaudio-working-but-spits-out-error-messages-each-time

Which mentions the ALSA function snd_lib_error_set_handler, documented here:
https://www.alsa-project.org/alsa-doc/alsa-lib/group___error.html#gae71d39953bf482ba487d811a69a9175c

So you could try using that function in your own code and see whether it works.

Just thinking out loud here: PortAudio could do one of:

  1. Keep current behavior (i.e. use the default ALSA behavior of printing errors to stderr)
  2. Suppress all ALSA errors using snd_lib_error_set_handler
  3. Provide an ALSA-specific API that maps to snd_lib_error_set_handler somehow

The problem with (2) is that perhaps some errors should not be suppressed. How do we know which? Perhaps when PA_ENABLE_DEBUG_OUTPUT is not defined PortAudio should suppress all ALSA output.

For (3) I'm not sure what advantage there is vs. user directly calling snd_lib_error_set_handler. Perhaps there could be some kind of PaAlsa_Enable/DisableErrorPrinting type thing.

@fredvs
Copy link

fredvs commented Nov 14, 2022

Many thanks for this.

I will deeply study it ( even that I am happy with redirecting the error messages to a log file, as I do for the moment ).

Fre;D

@Chum4k3r
Copy link

Chum4k3r commented Nov 15, 2022 via email

@RossBencina RossBencina added the P3 Priority: Normal label Dec 5, 2022
@RossBencina
Copy link
Collaborator

@Chum4k3r thanks for the feedback, I think you've made a good argument that (3) is a reasonable approach.

If someone would like to make a patch we can review it. In the mean time, as a work around, clients can call snd_lib_error_set_handler directly.

Not sure what we can do about the JACK messages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 Priority: Normal src-alsa ALSA Host API /src/hostapi/alsa src-jack JACK Audio Connection Kit Host API /src/hostapi/jack
Projects
None yet
Development

No branches or pull requests

4 participants