mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-01 08:29:27 +02:00
Break cycle of ODDecodeBlockFile and ODDecodeTask
This commit is contained in:
parent
395f169bad
commit
586eb0d4cb
@ -533,3 +533,32 @@ static DirManager::RegisteredBlockFileDeserializer sRegistration {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
///This should handle unicode converted to UTF-8 on mac/linux, but OD TODO:check on windows
|
||||||
|
ODFileDecoder::ODFileDecoder(const wxString & fName)
|
||||||
|
: mFName{ fName }
|
||||||
|
{
|
||||||
|
mInited = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ODFileDecoder::~ODFileDecoder()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ODFileDecoder::IsInitialized()
|
||||||
|
{
|
||||||
|
bool ret;
|
||||||
|
mInitedLock.Lock();
|
||||||
|
ret = mInited;
|
||||||
|
mInitedLock.Unlock();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
///Derived classes should call this after they have parsed the header.
|
||||||
|
void ODFileDecoder::MarkInitialized()
|
||||||
|
{
|
||||||
|
mInitedLock.Lock();
|
||||||
|
mInited=true;
|
||||||
|
mInitedLock.Unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -28,9 +28,10 @@ Also, see ODPCMAliasBlockFile for a similar file.
|
|||||||
#define __AUDACITY_ODDecodeBlockFile__
|
#define __AUDACITY_ODDecodeBlockFile__
|
||||||
|
|
||||||
#include "SimpleBlockFile.h"
|
#include "SimpleBlockFile.h"
|
||||||
#include "../ondemand/ODDecodeTask.h"
|
|
||||||
#include <wx/atomic.h> // member variable
|
#include <wx/atomic.h> // member variable
|
||||||
|
|
||||||
|
class ODFileDecoder;
|
||||||
|
|
||||||
/// An AliasBlockFile that references uncompressed data in an existing file
|
/// An AliasBlockFile that references uncompressed data in an existing file
|
||||||
class ODDecodeBlockFile final : public SimpleBlockFile
|
class ODDecodeBlockFile final : public SimpleBlockFile
|
||||||
{
|
{
|
||||||
@ -188,5 +189,47 @@ class ODDecodeBlockFile final : public SimpleBlockFile
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
///class to decode a particular file (one per file). Saves info such as filename and length (after the header is read.)
|
||||||
|
class ODFileDecoder /* not final */
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
///This should handle unicode converted to UTF-8 on mac/linux, but OD TODO:check on windows
|
||||||
|
ODFileDecoder(const wxString& fName);
|
||||||
|
virtual ~ODFileDecoder();
|
||||||
|
|
||||||
|
///Read header. Subclasses must override. Probably should save the info somewhere.
|
||||||
|
///Ideally called once per decoding of a file. This complicates the task because
|
||||||
|
virtual bool ReadHeader()=0;
|
||||||
|
virtual bool Init(){return ReadHeader();}
|
||||||
|
|
||||||
|
virtual bool SeekingAllowed(){return true;}
|
||||||
|
|
||||||
|
///Decodes the samples for this blockfile from the real file into a float buffer.
|
||||||
|
///This is file specific, so subclasses must implement this only.
|
||||||
|
///the buffer should be created by the ODFileDecoder implementing this method.
|
||||||
|
///It should set the format parameter so that the client code can deal with it.
|
||||||
|
///This class should call ReadHeader() first, so it knows the length, and can prepare
|
||||||
|
///the file object if it needs to.
|
||||||
|
///returns negative value for failure, 0 or positive value for success.
|
||||||
|
virtual int Decode(SampleBuffer & data, sampleFormat & format, sampleCount start, size_t len, unsigned int channel) = 0;
|
||||||
|
|
||||||
|
const wxString &GetFileName(){return mFName;}
|
||||||
|
|
||||||
|
bool IsInitialized();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
///Derived classes should call this after they have parsed the header.
|
||||||
|
void MarkInitialized();
|
||||||
|
|
||||||
|
bool mInited;
|
||||||
|
ODLock mInitedLock;
|
||||||
|
|
||||||
|
const wxString mFName;
|
||||||
|
|
||||||
|
unsigned int mSampleRate;
|
||||||
|
unsigned int mNumSamples;//this may depend on the channel - so TODO: we should probably let the decoder create/modify the track info directly.
|
||||||
|
unsigned int mNumChannels;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -90,6 +90,7 @@ class ODFLACFile final : public FLAC::Decoder::File
|
|||||||
void error_callback(FLAC__StreamDecoderErrorStatus status) override;
|
void error_callback(FLAC__StreamDecoderErrorStatus status) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#include "../blockfile/ODDecodeBlockFile.h" // to inherit
|
||||||
|
|
||||||
///class to decode a particular file (one per file). Saves info such as filename and length (after the header is read.)
|
///class to decode a particular file (one per file). Saves info such as filename and length (after the header is read.)
|
||||||
class ODFlacDecoder final : public ODFileDecoder
|
class ODFlacDecoder final : public ODFileDecoder
|
||||||
|
@ -291,34 +291,3 @@ int ODDecodeTask::GetNumFileDecoders()
|
|||||||
{
|
{
|
||||||
return mDecoders.size();
|
return mDecoders.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///This should handle unicode converted to UTF-8 on mac/linux, but OD TODO:check on windows
|
|
||||||
ODFileDecoder::ODFileDecoder(const wxString & fName)
|
|
||||||
: mFName{ fName }
|
|
||||||
{
|
|
||||||
mInited = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ODFileDecoder::~ODFileDecoder()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ODFileDecoder::IsInitialized()
|
|
||||||
{
|
|
||||||
bool ret;
|
|
||||||
mInitedLock.Lock();
|
|
||||||
ret = mInited;
|
|
||||||
mInitedLock.Unlock();
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
///Derived classes should call this after they have parsed the header.
|
|
||||||
void ODFileDecoder::MarkInitialized()
|
|
||||||
{
|
|
||||||
mInitedLock.Lock();
|
|
||||||
mInited=true;
|
|
||||||
mInitedLock.Unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -95,48 +95,6 @@ protected:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
///class to decode a particular file (one per file). Saves info such as filename and length (after the header is read.)
|
|
||||||
class ODFileDecoder /* not final */
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
///This should handle unicode converted to UTF-8 on mac/linux, but OD TODO:check on windows
|
|
||||||
ODFileDecoder(const wxString& fName);
|
|
||||||
virtual ~ODFileDecoder();
|
|
||||||
|
|
||||||
///Read header. Subclasses must override. Probably should save the info somewhere.
|
|
||||||
///Ideally called once per decoding of a file. This complicates the task because
|
|
||||||
virtual bool ReadHeader()=0;
|
|
||||||
virtual bool Init(){return ReadHeader();}
|
|
||||||
|
|
||||||
virtual bool SeekingAllowed(){return true;}
|
|
||||||
|
|
||||||
///Decodes the samples for this blockfile from the real file into a float buffer.
|
|
||||||
///This is file specific, so subclasses must implement this only.
|
|
||||||
///the buffer should be created by the ODFileDecoder implementing this method.
|
|
||||||
///It should set the format parameter so that the client code can deal with it.
|
|
||||||
///This class should call ReadHeader() first, so it knows the length, and can prepare
|
|
||||||
///the file object if it needs to.
|
|
||||||
///returns negative value for failure, 0 or positive value for success.
|
|
||||||
virtual int Decode(SampleBuffer & data, sampleFormat & format, sampleCount start, size_t len, unsigned int channel) = 0;
|
|
||||||
|
|
||||||
const wxString &GetFileName(){return mFName;}
|
|
||||||
|
|
||||||
bool IsInitialized();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
///Derived classes should call this after they have parsed the header.
|
|
||||||
void MarkInitialized();
|
|
||||||
|
|
||||||
bool mInited;
|
|
||||||
ODLock mInitedLock;
|
|
||||||
|
|
||||||
const wxString mFName;
|
|
||||||
|
|
||||||
unsigned int mSampleRate;
|
|
||||||
unsigned int mNumSamples;//this may depend on the channel - so TODO: we should probably let the decoder create/modify the track info directly.
|
|
||||||
unsigned int mNumChannels;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user