-
Notifications
You must be signed in to change notification settings - Fork 12
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
Possible issue with FlexASIO #26
Comments
Just tried with flexasio 1.9, I can render audio without problems. Also just out of curiosity what's your use case for flexasio? That driver is internally backed by portaudio with it's most likely output being wasapi. So your full stack now looks like xtaudio->flexasio->portaudio->wasapi. Why not just go for xtaudio->wasapi or portaudio->wasapi? Just curious, obviously the thing shouldn't crash in any case. |
Hi Everything looks normal compared to the ASIO4ALL v2 report I downloaded an ASIO driver tester from this link, and I'm getting this message (in both 32 and 64bit version of the app): Since Xt.Gui.exe is also crashing, it confirms my suspicions about the |
Ok, so I can confirm the crash now. Just tested with XtGui and it's busted immediately. Can you test it and see if it at least works for you ? The GUI thing i still have to work out yet. To be continued.
|
Request for clarification over at FlexASIO dechamps/FlexASIO#230. Hoping they can help out. |
Seems like a hard crash is caused by opening FlexASIO twice (i.e. XtServiceOpenDevice). Any chance that's the problem ? |
<< I can open and destroy the FlexASIO device multiple times without any issue The gui crash is caused by opening multiple FlexASIO devices at the same time, i.e. opening FlexASIO twice in a row without destroying it. Although that's not officially supported by the ASIO sdk, most asio drivers allow it. It's probably not what's causing you problems, though. << your code is not returning correctly (didn't touch anything): I assume its still crashing in XtDeviceOpenStream? Any chance you can produce a stacktrace? |
Btw, it seems like your taking a stack overflow. [EDIT] actually i misread. Thats not a stack overflow, it's STATUS_STACK_BUFFER_OVERRUN. I.e., either xt-audio or flexasio is corrupting memory somewhere. |
|
…although now that I think about it, this bug can only be triggered after |
ok I did a multiple open device (without destroying the device) on the following drivers I have:
I'm unable to do a stacktrace (I'm a novice programer) |
In order to grab a stacktrace you have to run a debug build of your program linked to a debug build of xt-audio. The .zip download provides both debug binaries and pdb files (necessary for stacktrace) in /core/xt/x64/Debug. If you run that under the debugger (for example visual studio), it should report you a stacktrace of the crash. But still, XtServiceOpenDevice() is probably not the problem. Your crash is not on XtServiceOpenDevice() but rather on XtDeviceOpenStream(). I hope, a stracktrace gives some insight. Let me know if you need more help with it. |
<< this bug can only be triggered after CreateBuffers() actually yes, XtServiceOpenDevice corresponds to CoCreateInstance<IASIO> as well as IASIO->init().
Then XtDeviceOpenStream corresponds to IASIO->createBuffers().
Although, @AGENTE44 gets the crash on the above demo code, which opens the device only once. I tried with both x64 and x86 versions, no problems. Of course this is sort of a "works on my machine" scenario, but it's really difficult for me to operate without a clue. I have attached a visual studio solution of the above sample code including all xt-audio debug binaries and pdb files (64-bit only). I'm assuming you can run visual studio, there's a fully-functional free community edition also. See here: ConsoleApplication4.zip Can you maybe give that a try? If it crashes, you can grab the stacktrace from the debug callstack window, see screenshot below (I intentionally made it crash by opening multiple FlexASIO's at once, your stacktrace will hopefully look different). |
Hi I don't want to lie by giving you inexact information, I can perform some logical and very superficial tests to locate the conflictive function (of the xt library) but I'm unable to go further or deal with the bare metal after the multiple I can try to look for another unstable function with the FlexASIO device if that helps did you tried the ASIO driver tester? it was able to detect the error before operating with the flexASIO (without crashing of course), error that I'm still trying to detect with the xt library |
<< did you tried the ASIO driver tester? Just did. Absolutely no problems whatsoever, not with FlexASIO nor any other ASIO driver, x86 and x64. Does any of this stuff ring a bell for you? I mean with the VB-Audio ASIO tester, xt-audio is completely out of the equation, but I'm hoping that "unanticipated host error" might be an a-ha moment for you. |
Well, that just means FlexASIO failed to initialize, why can be caused by any number of things, most of which are purely backend-side and have nothing to do with user code. I would need a FlexASIO log to understand why FlexASIO failed to initialize in this particular case. This is usually not indicative of an issue with the application, which should handle this error just like any other runtime failure. |
Any chance you could produce that log? |
you mean executing ConsoleApplication4.exe? VCRUNTIME140_1D.dll can you provide a link to a MS instaler? |
Ok I gather some more info I'm currently using an external audio interface to capture microphone, and the internal soundcard of a laptop as playback device, and I had to disable anything else to be able to work with some real-time audio effect software This is the settings I have with FlexASIO I did read about the FlexASIO.log, so I generate one file for the sjoerdvankreel 's first test code it's probably that my selected output device is not working, or is not a good entry point (or something like that...) |
<< I dont have the libraries: You need this thing https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170#visual-studio-2015-2017-2019-and-2022. Alternatively if that doesn't work out i can do a static linked build. Btw just curious, you say you're a novice programmer but then why use all those non-native toolchains like codeblocks and gcc? Are you just switching to windows from another platform? << it may have something to do with the WDM-KS backend Maybe. You should test them in this order from least to most user-hostile :)
Anything interesting in that log above? |
@AGENTE44 You should really take things one step at a time. If FlexASIO itself is not working, then obviously it won't work regardless of which ASIO application you try to use it in (be it the VB-Audio ASIO Tester, the xt sample app, your code, or even FlexASIOTest). Before you can try your own app with FlexASIO, you need to make sure FlexASIO itself works, regardless of the app. The default configuration of FlexASIO (i.e. no config file at all, or an empty one), is usually the most reliable one. So I'd suggest you start with that. WDM-KS is the least reliable FlexASIO backend by far, and it's known to be broken in various ways. Starting right off the bat with WDM-KS is an odd thing to do, and is really asking for trouble. (From your log I suspect the reason why WDM-KS doesn't work is because you are trying to use it on your default Windows audio device, a case that is explicitly documented to not work. But that's besides the point.) If you can't get FlexASIO to work in a released ASIO app, then it's a bug in FlexASIO (or a known FlexASIO issue such as the one I just mentioned), and you should report it against FlexASIO, not here. If you can get FlexASIO to work in a released ASIO app, but it doesn't work with your own app, then it makes sense to start debugging your app (and perhaps xt-audio). In any case, the FlexASIO log can be quite effective as a convenient debugging aid. Also, just to make sure things are clear: crashing when more than one instance of FlexASIO exists at any given time is to be expected, and is not a use case that FlexASIO intends to support - see dechamps/FlexASIO#230. My understanding from the linked discussion with @sjoerdvankreel is that xt-audio will not be changed to avoid this situation, either. In other words it is not considered a bug in FlexASIO nor in xt-audio. Which is a bit sad, but that's the way it is for now. So, if you want to avoid this problem, you're gonna have to work around it yourself in your code, i.e. make sure that the way you use xt-audio in your app does not result in more than one instance of a single ASIO driver existing at any given time. I'm worried that this thread is all over the place, to the point where I'm not even sure which issue we're discussing anymore. |
<< Starting right off the bat with WDM-KS is an odd thing to do, and is really asking for trouble. Second that. << My understanding from the linked discussion with @sjoerdvankreel is that xt-audio will not be changed to avoid this situation, either True, but also not the cause of the demo code crashing. To be absolutely clear, that sample opens FlexASIO exactly 1 time, and neatly closes it. << I'm worried that this thread is all over the place, to the point where I'm not even sure which issue we're discussing anymore. The issue at hand is a crash in the above mentioned sample code for xt-audio with FlexASIO as a backend. That sample code opens and closes FlexASIO exactly once. However I do agree with you that things are getting fuzzy, especially with problems popping up with multiple hosts. If you're up for it, we can try to pinpoint this together. |
no problem sjoerdvankreel, please take all your time you need I did more tests with FlexASIO GUI, and everything is normal in all combinations with DirectSound, WASAPI and MME: I got between "supported" and "not supported" messages, but NO CRASHES.... however, the only crashes I got is when you select both input and output devices as "None" (your test code stop at XtServiceOpenDevice() , and returning 0x3), I think FlexASIO should protect you from the "None" option I discover that I'm having problem only with WDM-KS, in the following output devices only when one of those output devices is selected (and only with the WDM-KS backend) I got the 0xC0000409 crash I can summarize the following crash conditions:
by the way, Xt.Gui still crashing me for all FlexASIO backends options greetings |
That definitely shouldn't happen. There are two possibilities:
A stack trace would be ideal to understand exactly what code is crashing. You should be able to obtain one if you trigger the crash under a debugger. Failing that, a FlexASIO log would at least show if the crash happens before or after FlexASIO returns control to the caller. In the log you posted in #26 (comment) the crash happens after, which suggests FlexASIO is not at fault, but I don't know if that log refers to the same scenario or not.
That one is expected if you didn't close the previous instance before opening a new one, see dechamps/FlexASIO#230. The next release of FlexASIO won't have that problem, but I still wouldn't recommend doing this because ASIO drivers are not required to support this scenario. (And please definitely don't do that kind of stuff concurrently from multiple threads - dechamps/FlexASIO#185.)
From what I understand (@sjoerdvankreel will correct me if I'm wrong), this is also because of dechamps/FlexASIO#230 and is therefore expected. |
I guess the 2nd call to XtServiceOpenDevice() is just a confirmation of the unstability of the xt-lib or FlexASIO, after the 1rst call no intention to do that practice in my program anyway, I understand ASIO works with 1 input and 1 output device at the time greetings |
Ok so I just figured it out, and the hard crash is, in fact, a bug in the xt-audio library proper. But first, @AGENTE44 Actually neither and also unrelated to your crash.
@dechamps Actually xt-audio is so strict here that that's not even possible. Whatever calls XtAudioInit() becomes the main thread and all API calls must be made through the main thread, with the exception of a very select set of audio stream functions. Probably for precisely the same reasons that portaudio is thread-hostile. A lot of audio COM stuff requires to run in the single-threaded apartment. WASAPI docs are full of comments like "final release must be from the same thread that first created the object" etc etc. I hope that clarifies. Now on to my next post which should actually describe what's going on ;) |
Ok, so here goes. I should have understood this from the FlexASIO logfile alone last time, but alas.
Following the demo code and the FlexASIO log, here's the sequence of events:
So from here, it's clear that FlexASIO returns ASE_HWMalfunction back to xt-audio, buffers are not successfully initialized, yet xt-audio calls disposeBuffers() anyway. Then that freaks out with ASE_InvalidMode, causing xt-audio to take down the process. Note to self: the problematic code is over here
@AGENTE44
And the whole issue would probably been cleared out in a matter of hours, not weeks. So, to summarize:
|
Nice catch! Yeah, in order to facilitate debugging FlexASIO will take every opportunity to tell the host application it's doing something that it thinks is wrong, and calling The silver lining is FlexASIO successfully surfaced a bug in your library :D Which is indeed the whole point. Who knows, maybe other drivers would have crashed on |
Just (hopefully) implemented the fix. Turned out to be as simple as this: @AGENTE44 @dechamps @AGENTE44 @dechamps @AGENTE44 Thanks again to the both of you. |
FYI FlexASIO 1.10, which I just released, should work with multiple instances at the same time. |
Ok I confirm the error code for XtDeviceOpenStream() with no crash (and FlexASIO 1.9) Then I Tried to use the new dll with the current Xt.Gui without success (but I understand that it was expected) I know FlexASIO belongs to another thread, but I'll post this extra info anyway I realized dechamps released another verion FlexASIO 1.10a
I think dechamps should put some attention on this?
as I mentioned before, I have no particular preference over these drivers and backends because I'm not the final user! I'm doing all hard-testing to ensure everything runs as smooth as possible in all scenarios (by the way, do you know more generic ASIO drivers out there to test?) in fact, I'm kind of disappointed about ASIO because I'm interested in multi device streaming (guess WASAPI is the only reliable option now), but who knows... some ASIO developer may change that in the future... I think the new dll fixed this little bug greetings |
Yeah this is dechamps/FlexASIO#231, which is the reason why I released 1.10a.
This is almost certainly a FlexASIO issue and you should report it against FlexASIO (along with a log). Since it affects VB-Audio tester it has nothing to do with your app. But again, I'm not too surprised you're seeing issues with FlexASIO WDM-KS, which is known to be quite buggy, sadly. |
<< I have no particular preference over these drivers and backends because I'm not the final user! << do you know more generic ASIO drivers out there to test? << in fact, I'm kind of disappointed about ASIO because I'm interested in multi device streaming << (guess WASAPI is the only reliable option now) << some ASIO developer may change that in the future << let me know if you want to sign this issue as resolved And now, on to some unsolicited advice! There's a BIG reason why ASIO in principle disallows multi-driver setups. In short, it's called "hardware clock". Anything that tries to pass off many different devices as a "single big device" is bound to glitch eventually, if you just stream it long enough. This goes for xt-audio's stream aggregation feature, and I'm 99% sure it also pertains to generic ASIO drivers such as FlexASIO or ASIO4ALL, and also convenience features like this https://learn.microsoft.com/en-us/previous-versions/windows/desktop/ee416764(v=vs.85)?redirectedfrom=MSDN. Thing is, different pieces of hardware (usb, firewire, PCI, whatever) each come with their own internal clock. Those clocks are 99.999% perfect, but never 100%. So clock drift and skew will occur eventually. If you open separate audio streams on those, one will for example run at 47999.999 Hz and the other one at 48000.001Hz. Even worse, those values are not even constant over time. The way xt-audio deals with this is to designate one of many streams as "master", and zero-pad or drop samples on the other one. I wouldn't be surprised if other systems take similar measures. After all, this problem is generally not solvable except for creating a hypothetical "infinite delay line". I have to admit there's one function in the ASIO sdk that I never quite grasped, and it's called "setClockSource". Surely it has something todo with the aforementioned stuff, but I find it hard to correlate with ASIO's (in principle) single driver model. @dechamps how's that one implemented in FlexASIO? |
No, it can't. See dechamps/FlexASIO#58.
You can do it by resampling the audio on-the-fly, but that makes things way more complicated, more computationally intensive, and also slightly lossy.
I think it has to do with hardware devices that have multiple user-selectable clocks. For example, a given interface with lots of I/O could get its clock from an embedded clock, from USB Audio, from one of its S/PDIF or AES/EBU ports, or from a dedicated word clock port. This ASIO API would provide a way for an application to show the available clocks to the user for a particular device so that they can switch between them. I suspect it's never used in practice, though - I've never seen an ASIO Host Application surface a UI for this. Most likely a device manufacturer would want to surface this through their ASIO Control Panel instead. Universal ASIO drivers do not get to pick which clock they use (the underlying system APIs do not offer this functionality), so it doesn't make sense for FlexASIO to implement this function. |
<< You can do it by resampling the audio on-the-fly, but that makes things way more complicated and more computationally intensive. This is clever! However doesn't that rely on the hardware being able to accurately report skew and drift? I always assumed drivers would just say "yeah sure I'm at 48k". Are you saying it's actually possible to pick up minor deviations like that through the ASIO API? Or would this involve resampling by timing on the host side? That'd be a major PITA. << I think it has to do with hardware devices that have multiple user-selectable clocks A-ha! So it's about 1 hardware with multiple clocks. I always thought it was about multiple hardware with 1 clock, used for syncing. Explains my confusion. And so, you learn something new every day :) << Universal ASIO drivers do not get to pick which clock they use |
Yes, that's what I mean. I don't know if that has ever been done to combine realt-time audio streams with different clocks, but that has definitely been done many times with great success to synchronize an audio stream to a video stream: see e.g. ReClock, JRiver VideoClock, MPDN Rate Tuner, Obviously this is very tricky to do correctly. Must be a very fun project for someone motivated though!
Yeah, and ASIO4ALL does not do anything clever in this case - the audio will glitch eventually. In FlexASIO, you can still get in this situation if the input and output devices have different clocks. |
@dechamps Yeah... I'm not that motivated :) In fact subsample syncing like that strikes me as way more complicated than even my runtime code generation endeavour. Meanwhile, stuff went south over here just like I expected. Long lost my nuget keys, mvn-central, and apparently something gnu-gpg is expired, too. It's been years since i touched that stuff. @AGENTE44 |
It's a project that's been a little sluggish and dormant for a while, I still need to do some fine tunning, but I'll let you know when is back on track with your library, which by the way, I'll put it to work under stress (I want to use your dll to replace my old OpenAL library) I am aware of the sync issue among separated clocks, and that there's no solution without introducing some delays, but I want to try a few ideas now that I have a little more control over the streams greetings |
Just FYI I'm in contact with sonatype/nexus. They're in a bit of a restructuring so it'll take some time for me to publish the java version of the library. Once that's settled I can do a proper 2.1 release and close this issue. |
Closed with 2.2. Just FYI: 2.2 contains this bugfix and another minor (glibc related) one, but it also drops x86 support and (probably of no interest to you) maven support. |
Hi I'm working with your nice library on my project (dll)
I'm testing different ASIO drivers but I'm getting a crash with FlexASIO (v1.9)
This is the simple sequence of code (C code):
error = XtServiceOpenDevice(service, id, &device); // no error detected here, device not NULL
error = XtDeviceGetBufferSize(device, format, &bufferInfo); // no error detected here
// Set the XtDeviceStreamParams here
error = XtDeviceOpenStream(device, &deviceParams, userpointer, &stream); // it crash!!!
I can read some info from FlexASIO, but I haven't had a chance to detect the error with
device
before opening a stream with this driver, so my program inevitably crashesits possible that bad device params may collapse the library? (I'm not using any exotic parameter)
since I installed the FlexASIO 1.9, the Xt.Gui.exe is also crashing before initializing!!!
thanks in advance
The text was updated successfully, but these errors were encountered: