From 59964e78fa258477e77b13c6c9141a43b25310bb 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/Mixer.cpp | 12 ++++++++---- src/core/PlayHandle.cpp | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/core/Mixer.cpp b/src/core/Mixer.cpp index c99d3ab8c..b961bad4a 100644 --- a/src/core/Mixer.cpp +++ b/src/core/Mixer.cpp @@ -451,7 +451,8 @@ const surroundSampleFrame * Mixer::renderNextBuffer() } if( ( *it )->isFinished() ) { - ( *it )->audioPort()->removePlayHandle( ( *it ) ); + if (( *it )->audioPort()) + ( *it )->audioPort()->removePlayHandle( ( *it ) ); if( ( *it )->type() == PlayHandle::TypeNotePlayHandle ) { NotePlayHandleManager::release( (NotePlayHandle*) *it ); @@ -653,7 +654,8 @@ bool Mixer::addPlayHandle( PlayHandle* handle ) if( criticalXRuns() == false ) { m_newPlayHandles.push( handle ); - handle->audioPort()->addPlayHandle( handle ); + if (handle->audioPort()) + handle->audioPort()->addPlayHandle( handle ); return true; } @@ -675,7 +677,8 @@ void Mixer::removePlayHandle( PlayHandle * _ph ) 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 @@ -735,7 +738,8 @@ void Mixer::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 9e92019a6..6f1424524 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} { }