diff options
-rw-r--r-- | src/multimedia/audio/qaudiosystem_platform_stream_support.cpp | 17 | ||||
-rw-r--r-- | src/multimedia/audio/qaudiosystem_platform_stream_support_p.h | 8 |
2 files changed, 23 insertions, 2 deletions
diff --git a/src/multimedia/audio/qaudiosystem_platform_stream_support.cpp b/src/multimedia/audio/qaudiosystem_platform_stream_support.cpp index 3b59289af..07bc6bb06 100644 --- a/src/multimedia/audio/qaudiosystem_platform_stream_support.cpp +++ b/src/multimedia/audio/qaudiosystem_platform_stream_support.cpp @@ -224,6 +224,7 @@ std::chrono::microseconds QPlatformAudioSinkStream::processedDuration() const void QPlatformAudioSinkStream::pullFromQIODevice() { + Q_ASSERT(thread()->isCurrentThread()); Q_ASSERT(m_device); visitRingbuffer([&](auto &ringbuffer) { @@ -281,6 +282,13 @@ void QPlatformAudioSinkStream::stopIdleDetection() QObject::disconnect(m_streamIdleDetectionConnection); } +QThread *QPlatformAudioSinkStream::thread() const +{ + // QPlatformAudioSinkStream is not a QObject, but still has a notion of an application thread + // where it lives on. + return m_streamIdleDetectionNotifier.thread(); +} + // we limit alloca calls to 0.5MB. it's good enough for virtually all use cases (i.e. buffers // of 4092 frames / 32 channels) and well in the reasonable range of available stack memory on linux // (8MB) @@ -360,6 +368,8 @@ uint64_t QPlatformAudioSourceStream::process( void QPlatformAudioSourceStream::pushToIODevice() { + Q_ASSERT(thread()->isCurrentThread()); + qsizetype bytesPushed = visitRingbuffer([&](auto &ringbuffer) { return QtPrivate::pushToQIODeviceFromRingbuffer(*m_device, ringbuffer); }); @@ -396,6 +406,13 @@ void QPlatformAudioSourceStream::emptyRingbuffer() }); } +QThread *QPlatformAudioSourceStream::thread() const +{ + // QPlatformAudioSourceStream is not a QObject, but still has a notion of an application thread + // where it lives on. + return m_ringbufferHasData.thread(); +} + qsizetype QPlatformAudioSourceStream::bytesReady() const { return visitRingbuffer([](const auto &ringbuffer) { diff --git a/src/multimedia/audio/qaudiosystem_platform_stream_support_p.h b/src/multimedia/audio/qaudiosystem_platform_stream_support_p.h index 090d52097..17537ae8a 100644 --- a/src/multimedia/audio/qaudiosystem_platform_stream_support_p.h +++ b/src/multimedia/audio/qaudiosystem_platform_stream_support_p.h @@ -166,7 +166,7 @@ protected: void handleIOError(ParentType *parent) { if (parent) { - Q_ASSERT(parent->thread()->isCurrentThread()); + Q_ASSERT(thread()->isCurrentThread()); parent->setError(QAudio::IOError); parent->updateStreamState(QtAudio::State::StoppedState); @@ -174,6 +174,8 @@ protected: } } + QThread *thread() const; + private: // qiodevice QIODevice *m_device = nullptr; @@ -237,7 +239,7 @@ protected: void handleIOError(ParentType *parent) { if (parent) { - Q_ASSERT(parent->thread()->isCurrentThread()); + Q_ASSERT(thread()->isCurrentThread()); parent->setError(QAudio::IOError); parent->updateStreamState(QtAudio::State::StoppedState); @@ -250,6 +252,8 @@ protected: } } + QThread *thread() const; + private: // qiodevice QIODevice *m_device = nullptr; |