PortAudio / portaudio

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

application level debug output #423

Open w1hkj opened 3 years ago

w1hkj commented 3 years ago

I am having difficulty assigning a callback function for portaudio debug strings: CXX soundcard/fldigi-sound.o CXXLD fldigi /usr/bin/ld: soundcard/fldigi-sound.o: in function SoundPort::initialize()': /home/dave/SF/fldigi.git/src/soundcard/sound.cxx:1160: undefined reference toPaUtil_SetDebugPrintFunction(void ()(char const))'

Any help at all would be much appreciated.

Thank you.

David

philburk commented 3 years ago

Does your callback conform to this signature?

typedef void (*PaUtilLogCallback ) (const char *log);

If not then C++ will look for a different function and not find it.

The error message suggests your function may take (const char) instead of (const char *).

w1hkj commented 3 years ago

Thank you for the response Phil.  The code snippet for the debug interface is:

define FL_PA_DEBUG 1

typedef void (PaUtilLogCallback ) (const char log); extern void PaUtil_SetDebugPrintFunction(PaUtilLogCallback  cb);

void padump(const char *s) {        if (FL_PA_DEBUG)                LOG_INFO("%s", s); }

void SoundPort::initialize(void) {         if (pa_init)                 return;        PaUtil_SetDebugPrintFunction( padump );

where LOG_info(...) is defined for all logging functions in the application fldigi:

https://sourceforge.net/p/fldigi/fldigi/ci/master/tree/

David

On 1/4/21 2:58 PM, Phil Burk wrote:

Does your callback conform to this signature?

|typedef void (PaUtilLogCallback ) (const char log); |

If not then C++ will look for a different function and not find it.

The error message suggests your function may take (const char).

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/PortAudio/portaudio/issues/423#issuecomment-754215078, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADTOAC63EOJHQDAHM2AKAL3SYITY5ANCNFSM4VSKHBPA.

philburk commented 3 years ago

Hmm. The function definition looks good.

Can you verify that pa_debugprint.o is getting included in the library?

mmuetzel commented 3 years ago

We came across this in GNU Octave, too. See: https://octave.discourse.group/t/alsa-warnings-when-running-audiodevinfo-cc-tests/1025 I believe that the proposed change would export that symbol (and related ones) from the dynamic library.

philburk commented 3 years ago

It seems the core of the problem is that PaUtil_SetDebugPrintFunction() is not being exported from the dynamically linked library.

I believe that the proposed change would export that symbol

I did not see a proposed code change on that page. Could someone please submit a pull request, or a patch file, so we can see what is actually being proposed?

mmuetzel commented 3 years ago

Sorry. The workflow is still quite new to me. I think I've created pull request #546 now for this. Please, let me know if this is correct.

@jwe wrote this in the forum:

It would also be great if the typedef and function declaration were in a public header file, but having the symbol exported would be sufficient to allow this feature to work. Thanks.

Would that be something you would consider doing? Where would be a good location to make the declaration of that function public?

RossBencina commented 3 years ago

This raises a number of design issues that need to be worked through.

PaUtil_* functions are not public, as a rule. portaudio.h defines the public API.

On Windows PaUtil_SetDebugPrintFunction appears to be in the .def file, this is a hack. We don't want to make the hack official elsewhere.

Debug output shouldn't be enabled in release builds, so PaUtil_SetDebugPrintFunction() should only have effect with special debug builds of PortAudio anyway. Therefore it doesn't even make sense to export this function.

RossBencina commented 3 years ago

If we are going to add a public symbol it should be named Pa_SetDebugPrintFunction or PaDebug_SetDebugPrintFunction

Assuming that I'm correct in assuming that debug output is only present in debug builds of PortAudio, then the symbol should probably only be available in debug versions of the library. Alternatively we can return an error if debug print is not enabled.

mmuetzel commented 3 years ago

Thank you for looking into this.

IIUC, the original motivation for trying to use PaUtil_SetDebugPrintFunction in Octave was that we see a lot of output to stdout during initialization of PortAudio (at least) on some platforms (at least Debian/Ubuntu). See: https://octave.discourse.group/t/alsa-warnings-when-running-audiodevinfo-cc-tests/1025 Some users (mis)interpreted this to indicate an error.

Is there a supported way of suppressing or redirecting that output?

Tom-Evers commented 2 years ago

Has this been fixed yet? I'd love to be able to hard-suppress all the debug info that PortAudio throws at me, independent of the platform.