mirror of
https://github.com/thestk/stk
synced 2026-04-19 14:06:55 +00:00
Removal of external data ptr functionality in StkFrames, as revert merge did not work.
This commit is contained in:
@@ -285,9 +285,6 @@ public:
|
|||||||
//! Overloaded constructor that initializes the frame data to the specified size with \c value.
|
//! Overloaded constructor that initializes the frame data to the specified size with \c value.
|
||||||
StkFrames( const StkFloat& value, unsigned int nFrames, unsigned int nChannels );
|
StkFrames( const StkFloat& value, unsigned int nFrames, unsigned int nChannels );
|
||||||
|
|
||||||
//! Overloaded constructor that wraps the provided pointer to \c data.
|
|
||||||
StkFrames( StkFloat* data, unsigned int nFrames, unsigned int nChannels = 1 );
|
|
||||||
|
|
||||||
//! The destructor.
|
//! The destructor.
|
||||||
~StkFrames();
|
~StkFrames();
|
||||||
|
|
||||||
@@ -443,7 +440,6 @@ private:
|
|||||||
unsigned int nChannels_;
|
unsigned int nChannels_;
|
||||||
size_t size_;
|
size_t size_;
|
||||||
size_t bufferSize_;
|
size_t bufferSize_;
|
||||||
bool ownData_;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
24
src/Stk.cpp
24
src/Stk.cpp
@@ -229,7 +229,7 @@ void Stk :: handleError( std::string message, StkError::Type type )
|
|||||||
//
|
//
|
||||||
|
|
||||||
StkFrames :: StkFrames( unsigned int nFrames, unsigned int nChannels )
|
StkFrames :: StkFrames( unsigned int nFrames, unsigned int nChannels )
|
||||||
: data_( 0 ), nFrames_( nFrames ), nChannels_( nChannels ), ownData_(true)
|
: data_( 0 ), nFrames_( nFrames ), nChannels_( nChannels )
|
||||||
{
|
{
|
||||||
size_ = nFrames_ * nChannels_;
|
size_ = nFrames_ * nChannels_;
|
||||||
bufferSize_ = size_;
|
bufferSize_ = size_;
|
||||||
@@ -248,7 +248,7 @@ StkFrames :: StkFrames( unsigned int nFrames, unsigned int nChannels )
|
|||||||
}
|
}
|
||||||
|
|
||||||
StkFrames :: StkFrames( const StkFloat& value, unsigned int nFrames, unsigned int nChannels )
|
StkFrames :: StkFrames( const StkFloat& value, unsigned int nFrames, unsigned int nChannels )
|
||||||
: data_( 0 ), nFrames_( nFrames ), nChannels_( nChannels ), ownData_(true)
|
: data_( 0 ), nFrames_( nFrames ), nChannels_( nChannels )
|
||||||
{
|
{
|
||||||
size_ = nFrames_ * nChannels_;
|
size_ = nFrames_ * nChannels_;
|
||||||
bufferSize_ = size_;
|
bufferSize_ = size_;
|
||||||
@@ -266,21 +266,13 @@ StkFrames :: StkFrames( const StkFloat& value, unsigned int nFrames, unsigned in
|
|||||||
dataRate_ = Stk::sampleRate();
|
dataRate_ = Stk::sampleRate();
|
||||||
}
|
}
|
||||||
|
|
||||||
StkFrames :: StkFrames( StkFloat* data, unsigned int nFrames, unsigned int nChannels )
|
|
||||||
: data_( data ), nFrames_( nFrames ), nChannels_( nChannels ), ownData_(false)
|
|
||||||
{
|
|
||||||
size_ = nFrames_ * nChannels_;
|
|
||||||
bufferSize_ = size_;
|
|
||||||
dataRate_ = Stk::sampleRate();
|
|
||||||
}
|
|
||||||
|
|
||||||
StkFrames :: ~StkFrames()
|
StkFrames :: ~StkFrames()
|
||||||
{
|
{
|
||||||
if ( data_ && ownData_ ) free( data_ );
|
if ( data_ ) free( data_ );
|
||||||
}
|
}
|
||||||
|
|
||||||
StkFrames :: StkFrames( const StkFrames& f )
|
StkFrames :: StkFrames( const StkFrames& f )
|
||||||
: data_(0), size_(0), bufferSize_(0), ownData_(true)
|
: data_(0), size_(0), bufferSize_(0)
|
||||||
{
|
{
|
||||||
resize( f.frames(), f.channels() );
|
resize( f.frames(), f.channels() );
|
||||||
dataRate_ = Stk::sampleRate();
|
dataRate_ = Stk::sampleRate();
|
||||||
@@ -289,7 +281,7 @@ StkFrames :: StkFrames( const StkFrames& f )
|
|||||||
|
|
||||||
StkFrames& StkFrames :: operator= ( const StkFrames& f )
|
StkFrames& StkFrames :: operator= ( const StkFrames& f )
|
||||||
{
|
{
|
||||||
if ( data_ && ownData_ ) free( data_ );
|
if ( data_ ) free( data_ );
|
||||||
data_ = 0;
|
data_ = 0;
|
||||||
size_ = 0;
|
size_ = 0;
|
||||||
bufferSize_ = 0;
|
bufferSize_ = 0;
|
||||||
@@ -306,19 +298,15 @@ void StkFrames :: resize( size_t nFrames, unsigned int nChannels )
|
|||||||
|
|
||||||
size_ = nFrames_ * nChannels_;
|
size_ = nFrames_ * nChannels_;
|
||||||
if ( size_ > bufferSize_ ) {
|
if ( size_ > bufferSize_ ) {
|
||||||
if ( data_ && ownData_ ) free( data_ );
|
if ( data_ ) free( data_ );
|
||||||
data_ = (StkFloat *) malloc( size_ * sizeof( StkFloat ) );
|
data_ = (StkFloat *) malloc( size_ * sizeof( StkFloat ) );
|
||||||
#if defined(_STK_DEBUG_)
|
#if defined(_STK_DEBUG_)
|
||||||
if ( data_ == NULL ) {
|
if ( data_ == NULL ) {
|
||||||
std::string error = "StkFrames::resize: memory allocation error!";
|
std::string error = "StkFrames::resize: memory allocation error!";
|
||||||
Stk::handleError( error, StkError::MEMORY_ALLOCATION );
|
Stk::handleError( error, StkError::MEMORY_ALLOCATION );
|
||||||
}
|
}
|
||||||
if ( ownData_ ) {
|
|
||||||
Stk::handleError( "Pointer to external data was lost after resize", StkError::WARNING );
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
bufferSize_ = size_;
|
bufferSize_ = size_;
|
||||||
ownData_ = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user