PortAudio / portaudio

PortAudio is a cross-platform, open-source C language library for real-time audio input and output.
Other
1.45k stars 302 forks source link

pa_linux_alsa.c: Hide debug infos. #555

Open fredvs opened 3 years ago

fredvs commented 3 years ago

When running a application via terminal that uses PortAudio, there are lot of debug infos. How to do to hide all that infos?

Here for example the infos when running release version of "audacity" via terminal:

fred@fiens ~> audacity ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side ALSA lib pcm_route.c:869:(find_matching_chmap) Found no matching channel map ALSA lib pcm_route.c:869:(find_matching_chmap) Found no matching channel map ALSA lib pcm_route.c:869:(find_matching_chmap) Found no matching channel map ALSA lib pcm_route.c:869:(find_matching_chmap) Found no matching channel map Cannot connect to server socket err = Aucun fichier ou dossier de ce type 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 Cannot connect to server socket err = Aucun fichier ou dossier de ce type 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 ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port ALSA lib pcm_a52.c:823:(_snd_pcm_a52_open) a52 is only for playback ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card Cannot connect to server socket err = Aucun fichier ou dossier de ce type 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 12:24:16: Debug: ScreenToClient cannot work when toplevel window is not shown ALSA lib pcm_dsnoop.c:638:(snd_pcm_dsnoop_open) unable to open slave Expression 'ret' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1736 Expression 'AlsaOpen( &alsaApi->baseHostApiRep, params, streamDir, &self->pcm )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1904 Expression 'PaAlsaStreamComponent_Initialize( &self->capture, alsaApi, inParams, StreamDirection_In, NULL != callback )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2171 Expression 'PaAlsaStream_Initialize( stream, alsaHostApi, inputParameters, outputParameters, sampleRate, framesPerBuffer, callback, streamFlags, userData )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2840 Expression 'ret' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1736 Expression 'AlsaOpen( &alsaApi->baseHostApiRep, params, streamDir, &self->pcm )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1904 Expression 'PaAlsaStreamComponent_Initialize( &self->capture, alsaApi, inParams, StreamDirection_In, NULL != callback )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2171 Expression 'PaAlsaStream_Initialize( stream, alsaHostApi, inputParameters, outputParameters, sampleRate, framesPerBuffer, callback, streamFlags, userData )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2840 Expression 'ret' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1736 Expression 'AlsaOpen( &alsaApi->baseHostApiRep, params, streamDir, &self->pcm )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1904 Expression 'PaAlsaStreamComponent_Initialize( &self->capture, alsaApi, inParams, StreamDirection_In, NULL != callback )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2171 Expression 'PaAlsaStream_Initialize( stream, alsaHostApi, inputParameters, outputParameters, sampleRate, framesPerBuffer, callback, streamFlags, userData )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2840 Expression 'stream->playback.pcm' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 4628 Expression 'stream->playback.pcm' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 4628 Expression 'ret' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1736 Expression 'AlsaOpen( &alsaApi->baseHostApiRep, params, streamDir, &self->pcm )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1904 Expression 'PaAlsaStreamComponent_Initialize( &self->capture, alsaApi, inParams, StreamDirection_In, NULL != callback )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2171 Expression 'PaAlsaStream_Initialize( stream, alsaHostApi, inputParameters, outputParameters, sampleRate, framesPerBuffer, callback, streamFlags, userData )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2840 Expression 'ret' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1736 Expression 'AlsaOpen( &alsaApi->baseHostApiRep, params, streamDir, &self->pcm )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1904 Expression 'PaAlsaStreamComponent_Initialize( &self->capture, alsaApi, inParams, StreamDirection_In, NULL != callback )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2171 Expression 'PaAlsaStream_Initialize( stream, alsaHostApi, inputParameters, outputParameters, sampleRate, framesPerBuffer, callback, streamFlags, userData )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2840 Expression 'stream->playback.pcm' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 4628 Expression '*idev = open( idevName, flags )' failed in 'src/hostapi/oss/pa_unix_oss.c', line: 832 Expression 'OpenDevices( idevName, odevName, &idev, &odev )' failed in 'src/hostapi/oss/pa_unix_oss.c', line: 878 Expression 'PaOssStream_Initialize( stream, inputParameters, outputParameters, streamCallback, userData, > streamFlags, ossHostApi )' failed in 'src/hostapi/oss/pa_unix_oss.c', line: 1249 fred@fiens ~>

Many thanks.

Fre;D

fredvs commented 3 years ago

Re-hello.

This was already asked here: https://github.com/PortAudio/portaudio/issues/163

Imho, it would be very great if PortAudio could, for example, add a new _PaNowarning method that user can do just before _Pa_Initialize_ and avoid all that (not funny) warnings that scare all end users.

Or something else but, really, all that debug infos should not be visible (or have the possibility to not see it).

Many thanks.

Fre;D

strawmanninen commented 3 years ago

I used this "fix" to get rid of them, at least temporarily:

#include <stdio.h>

freopen("log.txt", "w", stderr);

This way I can use stdout for my own logging and if I need to see portaudio's messages they're in log.txt.

Not optimal, but at least it's a workaround.

fredvs commented 3 years ago

Hello @strawmanninen

Thanks for the tip.

Yes, of course, you may redirect stderr.

You may even do via treminal:

$ myportaudioapp 2>> warning.log

But it is also a workaround.

dtromb commented 3 years ago

If I'm understanding this correctly this has been an open issue for 10 years now. Is there any way to get it addressed? (Happy to try it? The suggestion above does not seem incredibly complex...) It's a "little" thing but is preventing me from effectively using the library altogether right now.

fredvs commented 3 years ago

Hello.

You may also use Dup2 and pipes: https://stackoverflow.com/questions/955962/how-to-buffer-stdout-in-memory-and-write-it-from-a-dedicated-thread

But it is a work-around.

RossBencina commented 2 years ago

There appears to be two problems here:

  1. ALSA lib warnings, also covered by #163
  2. A bunch of Expression ? failed in 'src/hostapi/alsa/pa_linux_alsa.c' errors, which are concerning, but may be specific to machine configuration. It would be good to get some more system info. Is anyone else seeing these errors?