AudioTransportSource setSource not working when it is run a second time

Hi all,

I found this issue in another thread: PlayingSoundFiles tutorial - setSource method on the AudioTransportSource for seconds time leads to EXC_BAD_ACCESS

In my case I have a method where it determines the correct file to play based on parameters, then plays the audio file. However, when I run setSource a second time it seems to fail. Is there something that I’m doing wrong? If so please suggest alternatives to resolve my issue.


Hard to say whether you’re doing anything wrong without knowing more… Try actually debugging what happens and it might become obvious what’s wrong?

As it says in the thread that I linked, it seems to throw a EXC_BAD_ACCESS error when it tries to run the “releaseResource()” method, That is where I traced the issue to as well:

"All I could understand is that it seems like it fails to find an AudioSource to delete at some point in the setSource method, in juce_ResamplingAudioSource.cpp at:

void ResamplingAudioSource::releaseResources()
buffer.setSize (numChannels, 0);

Well that’s a dangling pointer - you’re probably doubly-deleting the input source yourself or something.

Hi Owen,

The tutorial was fixed:

Fabian explains the issue here:

Hope that helps in your use case.


Thank you so much that was exactly what I needed. I fixed my issue with the statement transportSource.setSource(nullptr); before I added a new scoped pointer.

1 Like