thestk / rtaudio

A set of C++ classes that provide a common API for realtime audio input/output across Linux (native ALSA, JACK, PulseAudio and OSS), Macintosh OS X (CoreAudio and JACK), and Windows (DirectSound, ASIO, and WASAPI) operating systems.
Other
1.49k stars 317 forks source link

Unstable ASIO support? #409

Open sinosoidal opened 1 year ago

sinosoidal commented 1 year ago

I was wondering how much stable is ASIO support? I have been trying to implement a switch between ASIO and WASAPI without having one or another compatibility hard coded.

One problem I have is that when starting the application with the ASIO API driver selected it crashes when starting the DAC stream

asio.cpp line 115

ASIOError ASIOStart(void)
{
    if(!theAsioDriver)
        return ASE_NotPresent;
    return theAsioDriver->start(); // the crash happens here
}

Also, since version 5.X.Y I need to have the folllowing modifications in order to compile the code with ASIO support:

diff --git a/RtAudio.cpp b/RtAudio.cpp
index b13f04e..99c1908 100644
--- a/RtAudio.cpp
+++ b/RtAudio.cpp
@@ -3318,6 +3318,7 @@ bool RtApiJack :: callbackEvent( unsigned long nframes )
 #include "asio.h"
 #include "iasiothiscallresolver.h"
 #include "asiodrivers.h"
+#include "objbase.h"
 #include <cmath>
 static AsioDrivers drivers;
diff --git a/include/iasiodrv.h b/include/iasiodrv.h
index 64d2dbb..5a32adb 100644
--- a/include/iasiodrv.h
+++ b/include/iasiodrv.h
@@ -1,10 +1,12 @@
 #include "asiosys.h"
 #include "asio.h"
+#include "unknwn.h"^M
 /* Forward Declarations */
 #ifndef __ASIODRIVER_FWD_DEFINED__
 #define __ASIODRIVER_FWD_DEFINED__
+#define interface struct^M
 typedef interface IASIO IASIO;
 #endif         /* __ASIODRIVER_FWD_DEFINED__ */

Am I failing something obvious here?

I was really looking forward to have a driver selection mode that could allow selection between ASIO and WASAPI under Windows

garyscavone commented 1 year ago

I use the autogen.sh script and mingw64 to create the Makefiles on Windows and have not had any troubles compiling or running the ASIO API in RtAudio. I do not see why you would need to modify the #includes in those header files but perhaps you are using a different build approach?

sinosoidal commented 1 year ago

@garyscavone thanks for your reply. I use Visual Studio to compile directly from the source. But apart from that, the biggest problem is that I get crashes when using ASIO. Do you think this might be related with the introduced changes? I want to be able to switch between WASAPI and ASIO if the user intends so. Therefore I need to be able to delete the RtAudio object, and instantiate a new one using the required API. Was RtAudio designed to work this way?

garyscavone commented 11 months ago

RtAudio was definitely designed to allow instances to be deleted and newly instantiated to support a different API, so that should be fine. Exactly why you are having problems with ASIO is not clear. What sort of audio device are you using? Does it have a native ASIO driver?

sinosoidal commented 11 months ago

@garyscavone I have found the culprit in the mean while. It seems to crash with the "Generic Low Latency ASIO driver" provided with Windows. I have simply decided to ignore that device.