Fix sample track playback crash (#4586)

Fixes double-freeing `AudioPort` which is a regression in #4310.

Co-authored-by: Shmuel H <shmuelhazan0@gmail.com>
Co-authored-by: Hyunjin Song <tteu.ingog@gmail.com>
This commit is contained in:
Z3R0C
2018-09-18 04:21:45 +02:00
committed by Hyunjin Song
parent 78142cee3d
commit 00cc6dc22b
2 changed files with 11 additions and 8 deletions

View File

@@ -1,8 +1,9 @@
/*
* SamplePlayHandle.h - play-handle for playing a sample
*
* Copyright (c) 2005-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
*
* 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();

View File

@@ -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() );