naudio / NAudio

Audio and MIDI library for .NET
MIT License
5.55k stars 1.1k forks source link

AsioDriver.ReleaseComAsioDriver() causes application to crash #518

Open Ano9506 opened 5 years ago

Ano9506 commented 5 years ago

I am trying to use to the "Generic Low Latency ASIO Driver", which is created by Steinberg and comes with their DAW software Cubase. This driver allows to use your internal sound card with ASIO. I create an instance of the AsioDriver class to get some info (like the current sample rate, ...). At the end I call the method ReleaseComAsioDriver(), but this causes the application to crash. I can't catch an error with a try-statement, the application just quits ...

This only happens with this Asio Driver, other drivers (from external sound cards) works perfectly.

EDIT: It seems this driver is a 64bit driver. If I run the application in 32bit, the method GetASIODriverNames() doesn't return this Asio Driver.

markheath commented 5 years ago

Not sure why that method would cause the problem. Possibly something that's been called beforehand has failed. Perhaps you can debug and see if the call to DisposeBuffers (in AsioDriverExt.ReleaseDriver) throws an exception (it currently silently swallows exceptions)

Ano9506 commented 5 years ago

So I'm running this code now, only with the ReleaseDriver in AsioDriverExt. This code doesn't throw any exception. The values from the capabilities class seems correct.

I tried using this driver with the NAudio Demo application to simply playback a WAV file. This also failed, but didn't result in an app crash. Play back just didn't start, with no error message. I don't have any clue what could cause this.

Dim driv As AsioDriver = AsioDriver.GetAsioDriverByName(driverName)
                Try
                    Dim extDriv As AsioDriverExt = New AsioDriverExt(driv)
                    Dim cap As AsioDriverCapability = extDriv.Capabilities
                    With cap
                        _inputLatency = .InputLatency
                        _outputLatency = .OutputLatency
                        _HWInputChannelsCount = .NbInputChannels
                        For i As Integer = 0 To .NbInputChannels - 1
                            _HWInputChannels.Add(.InputChannelInfos(i).name)
                            _InputChannels.Add(.InputChannelInfos(i).name)
                        Next
                        _HWOutputChannelsCount = .NbOutputChannels
                        For i As Integer = 0 To .NbOutputChannels - 1
                            _HWOutputChannels.Add(.OutputChannelInfos(i).name)
                            _OutputChannels.Add(.OutputChannelInfos(i).name)
                        Next

                        _HWSampleRate = .SampleRate
                        _HWBufferCapacity = .BufferPreferredSize
                    End With
                    extDriv.ReleaseDriver()

                    initiated = True
                    _state = AudioCoreDeviceState.Connected
                Catch ex As Exception
                    _state = AudioCoreDeviceState.NotConnected
                    RaiseEvent StateChanged(Me, EventArgs.Empty)
                End Try
markheath commented 5 years ago

Do you have any other ASIO devices you can try on? Maybe there is an issue just with this particular ASIO driver.

Ano9506 commented 5 years ago

I tried with 3 other ASIO devices (all external sound bords). No problems here. It seems this only occurs when using this particular driver. I used a program from Adobe with this driver (just to check if the Steinberg company didn't prevent other software from using this driver), and this program could communicate with this driver.

So no clue what is happening here ...