diff --git a/include/SamplePlayHandle.h b/include/SamplePlayHandle.h index 9a051ec7b..d10c44837 100644 --- a/include/SamplePlayHandle.h +++ b/include/SamplePlayHandle.h @@ -1,8 +1,9 @@ + /* * SamplePlayHandle.h - play-handle for playing a sample * * Copyright (c) 2005-2014 Tobias Doerffel - * + * * This file is part of LMMS - https://lmms.io * * This program is free software; you can redistribute it and/or @@ -38,7 +39,7 @@ class AudioPort; class SamplePlayHandle : public PlayHandle { public: - SamplePlayHandle( SampleBuffer* sampleBuffer ); + SamplePlayHandle( SampleBuffer* sampleBuffer , bool ownAudioPort = true ); SamplePlayHandle( const QString& sampleFile ); SamplePlayHandle( SampleTCO* tco ); virtual ~SamplePlayHandle(); diff --git a/src/core/SamplePlayHandle.cpp b/src/core/SamplePlayHandle.cpp index 549a6c3a5..cae2f3cde 100644 --- a/src/core/SamplePlayHandle.cpp +++ b/src/core/SamplePlayHandle.cpp @@ -32,35 +32,37 @@ -SamplePlayHandle::SamplePlayHandle( SampleBuffer* sampleBuffer ) : +SamplePlayHandle::SamplePlayHandle( SampleBuffer* sampleBuffer , bool ownAudioPort ) : PlayHandle( TypeSamplePlayHandle ), m_sampleBuffer( sharedObject::ref( sampleBuffer ) ), m_doneMayReturnTrue( true ), m_frame( 0 ), - m_ownAudioPort( true ), + m_ownAudioPort( ownAudioPort ), m_defaultVolumeModel( DefaultVolume, MinVolume, MaxVolume, 1 ), m_volumeModel( &m_defaultVolumeModel ), m_track( NULL ), m_bbTrack( NULL ) { - setAudioPort( new AudioPort( "SamplePlayHandle", false ) ); + if (ownAudioPort) + { + setAudioPort( new AudioPort( "SamplePlayHandle", false ) ); + } } SamplePlayHandle::SamplePlayHandle( const QString& sampleFile ) : - SamplePlayHandle( new SampleBuffer( sampleFile ) ) + SamplePlayHandle( new SampleBuffer( sampleFile ) , true) { sharedObject::unref( m_sampleBuffer ); - setAudioPort( new AudioPort( "SamplePlayHandle", false ) ); } SamplePlayHandle::SamplePlayHandle( SampleTCO* tco ) : - SamplePlayHandle( tco->sampleBuffer() ) + SamplePlayHandle( tco->sampleBuffer() , false) { m_track = tco->getTrack(); setAudioPort( ( (SampleTrack *)tco->getTrack() )->audioPort() );