Skip to content
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

[Bug]: AudioTransportSource::hasStreamFinished nullptr exception #1368

Open
1 task done
dobrikov91 opened this issue Mar 27, 2024 · 0 comments
Open
1 task done

[Bug]: AudioTransportSource::hasStreamFinished nullptr exception #1368

dobrikov91 opened this issue Mar 27, 2024 · 0 comments

Comments

@dobrikov91
Copy link

Detailed steps on how to reproduce the bug

Juce 7.0.11+

  1. Create empty AudioTransportSource instance
  2. Call hasStreamFinished method

App crashes with nullptr exception


All functions except hasStreamFinished() have nullptr checks, check stacktrace as example

What is the expected behaviour?

hasStreamFinished should return true in case of missing source

Operating systems

Windows

What versions of the operating systems?

Win10

Architectures

64-bit

Stacktrace

bool AudioTransportSource::hasStreamFinished() const noexcept
{
    return positionableSource->getNextReadPosition() > positionableSource->getTotalLength() + 1
              && ! positionableSource->isLooping();
}

void AudioTransportSource::setNextReadPosition (int64 newPosition)
{
    if (positionableSource != nullptr)
    {
        if (sampleRate > 0 && sourceSampleRate > 0)
            newPosition = (int64) ((double) newPosition * sourceSampleRate / sampleRate);

        positionableSource->setNextReadPosition (newPosition);

        if (resamplerSource != nullptr)
            resamplerSource->flushBuffers();
    }
}

int64 AudioTransportSource::getNextReadPosition() const
{
    const ScopedLock sl (callbackLock);

    if (positionableSource != nullptr)
    {
        const double ratio = (sampleRate > 0 && sourceSampleRate > 0) ? sampleRate / sourceSampleRate : 1.0;
        return (int64) ((double) positionableSource->getNextReadPosition() * ratio);
    }

    return 0;
}

Plug-in formats (if applicable)

No response

Plug-in host applications (DAWs) (if applicable)

No response

Testing on the develop branch

The bug is present on the develop branch

Code of Conduct

  • I agree to follow the Code of Conduct
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant