# Odd, jassert (currentCallback == nullptr) in ASIOAudioIODevice::Open asserts

**URL:** <https://forum.juce.com/t/odd-jassert-currentcallback-nullptr-in-asioaudioiodevice-open-asserts/36478>\
**Category:** General JUCE discussion\
**Created:** [December 3, 2019, 6:17pm UTC](https://forum.juce.com/t/odd-jassert-currentcallback-nullptr-in-asioaudioiodevice-open-asserts/36478 "2019-12-03T18:17:10Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![rMidi](https://avatars.discourse-cdn.com/v4/letter/r/ee59a6/32.png) [@rMidi](https://forum.juce.com/u/rMidi)\
**Post date:** [December 3, 2019, 6:17pm UTC](https://forum.juce.com/t/odd-jassert-currentcallback-nullptr-in-asioaudioiodevice-open-asserts/36478/1 "2019-12-03T18:17:10Z")

</div>

This has been bothering me for awhile.  
Windowsx64  
ASIO4ALL Driver  
Juce 5.4.5  
ASIOAudioIODevice::Open()  
Line 397 juce\_win32\_asio.CPP  
jassert (currentCallback == nullptr); //always asserts!

My currentCallBack is valid (It is an \* AudioIODeviceCallback)

Everything works as expected (::audioDeviceIOCallback, ::audioDeviceAboutToStart and ::audioDeviceStopped are called as expected).

I cannot for the life of me figure out why the assert evaluates to true?

I am sure there are persons here smarter than I am!

---

<div class="post-metadata">

**Author:** ![cpr2323](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/cpr2323/32/18682_2.png) [@cpr2323](https://forum.juce.com/u/cpr2323)\
**Post date:** [December 3, 2019, 6:41pm UTC](https://forum.juce.com/t/odd-jassert-currentcallback-nullptr-in-asioaudioiodevice-open-asserts/36478/2 "2019-12-03T18:41:02Z")

</div>

Without seeing some code, it will be very difficult for anyone to help you. Please post relevant snippets, surrounded by triple tic (3 of these `)

```auto
code stays formatted within these areas

```

---

<div class="post-metadata">

**Author:** ![rMidi](https://avatars.discourse-cdn.com/v4/letter/r/ee59a6/32.png) [@rMidi](https://forum.juce.com/u/rMidi)\
**Post date:** [December 3, 2019, 7:45pm UTC](https://forum.juce.com/t/odd-jassert-currentcallback-nullptr-in-asioaudioiodevice-open-asserts/36478/3 "2019-12-03T19:45:05Z")

</div>

I am sorry but the code is within juce modules.  
Specifically as I have stated:  
Juce 5.4.5  
ASIOAudioIODevice::Open()  
Line 397 juce\_win32\_ASIO.cpp  
jassert (currentCallback == nullptr);

Since we all have the code I assume that anyone can open juce\_win32\_ASIO.cpp and go to line 397.  
Just in case:

```auto
jassert (currentCallback == nullptr);

```

🙂

If I do this:

```auto
        if(currentCallback==nullptr)
        {
         jassert (currentCallback == nullptr);
         }

```

Then the jassert is never hit.  
::currentCallback is valid every where else in the entire file ( juce\_win32\_ASIO.cpp) when running as I have set a break point on every reference to it.

I am debugging under VS 2017.  
I have a hard time with #define’s such as jassert as one can not really step into them.

So, I believe this is happening:  
(currentCallback == nullptr) evaluates to false (currentCallback IS valid).

jassert is located in juce\modules\juce\_core\system\juce\_PlatformDefs.h

```auto
#define jassert(expression) JUCE_BLOCK_WITH_FORCED_SEMICOLON (if (! (expression)) jassertfalse;)

```

if(!(currentCallback == nullptr)) evaluates to true, so jassertfalse is called.

so the assertion occurs.

Again, I am at a loss and am hoping someone can point out my issue.

---

<div class="post-metadata">

**Author:** ![cpr2323](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/cpr2323/32/18682_2.png) [@cpr2323](https://forum.juce.com/u/cpr2323)\
**Post date:** [December 3, 2019, 8:03pm UTC](https://forum.juce.com/t/odd-jassert-currentcallback-nullptr-in-asioaudioiodevice-open-asserts/36478/4 "2019-12-03T20:03:16Z")

</div>

Not the library code, your code! lol… If you are doing something wrong, we can’t help figure that out without seeing your code.

Asserts are meant to tell you when something is wrong. They are not meant to be ignored.

---

<div class="post-metadata">

**Author:** ![rMidi](https://avatars.discourse-cdn.com/v4/letter/r/ee59a6/32.png) [@rMidi](https://forum.juce.com/u/rMidi)\
**Post date:** [December 3, 2019, 8:37pm UTC](https://forum.juce.com/t/odd-jassert-currentcallback-nullptr-in-asioaudioiodevice-open-asserts/36478/5 "2019-12-03T20:37:05Z")

</div>

I am very sorry if I am not getting my point across.  
This is not my code, it is JUCE code.

The source file in question is located at:  
\JUCE\modules\juce\_audio\_devices\native\juce\_win32\_ASIO.cpp

Again, this is not my code.  
If you are not building under Windows you probably will not have this file.

The point I am attempting to get across is that within the JUCE 5.4.5 code, the source file specified, the line specified I believe should be:

```auto
jassert (currentCallback != nullptr);

```

Perhaps you where confused because I modified the JUCE source code to show that currentCallback actually has a value.

Why don’t we just let this lie and wait for someone else respond to my question.

Thanks, and I have no intention of offending anyone here.

---

<div class="post-metadata">

**Author:** ![cpr2323](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/cpr2323/32/18682_2.png) [@cpr2323](https://forum.juce.com/u/cpr2323)\
**Post date:** [December 3, 2019, 8:42pm UTC](https://forum.juce.com/t/odd-jassert-currentcallback-nullptr-in-asioaudioiodevice-open-asserts/36478/6 "2019-12-03T20:42:17Z")

</div>

I am sorry if I am not getting my point across. 🙂 Often times when you get an assert from JUCE, it is because of how the client code is using it. Without seeing how you are using it, it is hard to help discern if it is a user error, or something wrong with JUCE. The library tends to be pretty robust, and so we first suspect user code. Maybe this relates to an object lifetime issue? Maybe something else. Anyways, I’m glad to let this lie. Best of luck. 🙂

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [December 3, 2019, 8:48pm UTC](https://forum.juce.com/t/odd-jassert-currentcallback-nullptr-in-asioaudioiodevice-open-asserts/36478/7 "2019-12-03T20:48:50Z")

</div>

If you look, what the ASIO wrapper does here, it is:

- close() if it was open()
- in close it calls stop()
- in stop() it sets the currentCallback to nullptr

When all that happened, the code concludes in the jassert to see, that the closing actually happened.

So if you want to dig in, check if close() was actually called…

The condition to catch here is, that a currentCallback was set, but the ASIO was not running.

But I have no further information, why the assert fires in your setup.

---

<div class="post-metadata">

**Author:** ![rMidi](https://avatars.discourse-cdn.com/v4/letter/r/ee59a6/32.png) [@rMidi](https://forum.juce.com/u/rMidi)\
**Post date:** [December 3, 2019, 10:09pm UTC](https://forum.juce.com/t/odd-jassert-currentcallback-nullptr-in-asioaudioiodevice-open-asserts/36478/8 "2019-12-03T22:09:44Z")

</div>

Thanks Daniel,

I have no idea why my currentCallback has a value in open() as I have not called start(). It reeks of a wild pointer. I am to the point where I am going to start re-installing things (ASIO4ALL, Juce,…) and do a clean and build.

Thanks to everyone so far for the help.
