From 50cc41a5a18f2f1dc5b7ec6d1f50e9cf61a01fbc Mon Sep 17 00:00:00 2001 From: Shmuel H Date: Mon, 6 Nov 2017 22:42:40 +0200 Subject: [PATCH] Mixer & PlayHandle: Support PlayHandle without audioPort and set audioPort as nullptr by default. --- src/core/AudioEngine.cpp | 10 +++++----- src/core/PlayHandle.cpp | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/core/AudioEngine.cpp b/src/core/AudioEngine.cpp index 0fb93462e..e81bf4f06 100644 --- a/src/core/AudioEngine.cpp +++ b/src/core/AudioEngine.cpp @@ -354,7 +354,7 @@ const surroundSampleFrame * AudioEngine::renderNextBuffer() if( it != m_playHandles.end() ) { - ( *it )->audioPort()->removePlayHandle( ( *it ) ); + if((*it)->audioPort()) { (*it)->audioPort()->removePlayHandle(*it); } if( ( *it )->type() == PlayHandle::TypeNotePlayHandle ) { NotePlayHandleManager::release( (NotePlayHandle*) *it ); @@ -402,7 +402,7 @@ const surroundSampleFrame * AudioEngine::renderNextBuffer() } if( ( *it )->isFinished() ) { - ( *it )->audioPort()->removePlayHandle( ( *it ) ); + if((*it)->audioPort()) { (*it)->audioPort()->removePlayHandle(*it); } if( ( *it )->type() == PlayHandle::TypeNotePlayHandle ) { NotePlayHandleManager::release( (NotePlayHandle*) *it ); @@ -675,7 +675,7 @@ bool AudioEngine::addPlayHandle( PlayHandle* handle ) if( criticalXRuns() == false ) { m_newPlayHandles.push( handle ); - handle->audioPort()->addPlayHandle( handle ); + if (handle->audioPort()) { handle->audioPort()->addPlayHandle(handle); } return true; } @@ -696,7 +696,7 @@ void AudioEngine::removePlayHandle(PlayHandle * ph) // which were created in a thread different than the audio engine thread if (ph->affinityMatters() && ph->affinity() == QThread::currentThread()) { - ph->audioPort()->removePlayHandle(ph); + if (ph->audioPort()) { ph->audioPort()->removePlayHandle(ph); } bool removedFromList = false; // Check m_newPlayHandles first because doing it the other way around // creates a race condition @@ -755,7 +755,7 @@ void AudioEngine::removePlayHandlesOfTypes(Track * track, const quint8 types) { if ((*it)->isFromTrack(track) && ((*it)->type() & types)) { - ( *it )->audioPort()->removePlayHandle( ( *it ) ); + if (( *it )->audioPort()) { (*it)->audioPort()->removePlayHandle(*it); } if( ( *it )->type() == PlayHandle::TypeNotePlayHandle ) { NotePlayHandleManager::release( (NotePlayHandle*) *it ); diff --git a/src/core/PlayHandle.cpp b/src/core/PlayHandle.cpp index 37149583f..93022a7d9 100644 --- a/src/core/PlayHandle.cpp +++ b/src/core/PlayHandle.cpp @@ -38,7 +38,8 @@ PlayHandle::PlayHandle(const Type type, f_cnt_t offset) : m_affinity(QThread::currentThread()), m_playHandleBuffer(BufferManager::acquire()), m_bufferReleased(true), - m_usesBuffer(true) + m_usesBuffer(true), + m_audioPort{nullptr} { }