mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-01 16:39:30 +02:00
Remove some naked new amd delete in: import and export
This commit is contained in:
parent
b47bcb548e
commit
f82ff73578
@ -293,9 +293,6 @@ Exporter::Exporter()
|
||||
|
||||
Exporter::~Exporter()
|
||||
{
|
||||
if (mMixerSpec) {
|
||||
delete mMixerSpec;
|
||||
}
|
||||
}
|
||||
|
||||
void Exporter::SetFileDialogTitle( const wxString & DialogTitle )
|
||||
@ -367,10 +364,7 @@ bool Exporter::Process(AudacityProject *project, bool selectedOnly, double t0, d
|
||||
bool success = ExportTracks();
|
||||
|
||||
// Get rid of mixerspec
|
||||
if (mMixerSpec) {
|
||||
delete mMixerSpec;
|
||||
mMixerSpec = NULL;
|
||||
}
|
||||
mMixerSpec.reset();
|
||||
|
||||
return success;
|
||||
}
|
||||
@ -738,10 +732,7 @@ void Exporter::DisplayOptions(int index)
|
||||
bool Exporter::CheckMix()
|
||||
{
|
||||
// Clean up ... should never happen
|
||||
if (mMixerSpec) {
|
||||
delete mMixerSpec;
|
||||
mMixerSpec = NULL;
|
||||
}
|
||||
mMixerSpec.reset();
|
||||
|
||||
// Detemine if exported file will be stereo or mono or multichannel,
|
||||
// and if mixing will occur.
|
||||
@ -806,7 +797,7 @@ bool Exporter::CheckMix()
|
||||
return false;
|
||||
}
|
||||
|
||||
mMixerSpec = new MixerSpec(*(md.GetMixerSpec()));
|
||||
mMixerSpec = std::make_unique<MixerSpec>(*(md.GetMixerSpec()));
|
||||
mChannels = mMixerSpec->GetNumChannels();
|
||||
}
|
||||
|
||||
@ -828,7 +819,7 @@ bool Exporter::ExportTracks()
|
||||
mSelectedOnly,
|
||||
mT0,
|
||||
mT1,
|
||||
mMixerSpec,
|
||||
mMixerSpec.get(),
|
||||
NULL,
|
||||
mSubFormat);
|
||||
|
||||
@ -939,10 +930,7 @@ bool Exporter::ProcessFromTimerRecording(AudacityProject *project,
|
||||
bool success = ExportTracks();
|
||||
|
||||
// Get rid of mixerspec
|
||||
if (mMixerSpec) {
|
||||
delete mMixerSpec;
|
||||
mMixerSpec = NULL;
|
||||
}
|
||||
mMixerSpec.reset();
|
||||
|
||||
return success;
|
||||
}
|
||||
@ -1011,10 +999,6 @@ ExportMixerPanel::~ExportMixerPanel()
|
||||
{
|
||||
delete[] mTrackRects;
|
||||
delete[] mChannelRects;
|
||||
|
||||
if (mBitmap) {
|
||||
delete mBitmap;
|
||||
}
|
||||
}
|
||||
|
||||
//set the font on memDC such that text can fit in specified width and height
|
||||
@ -1048,12 +1032,9 @@ void ExportMixerPanel::OnPaint(wxPaintEvent & WXUNUSED(event))
|
||||
|
||||
if( !mBitmap || mWidth != width || mHeight != height )
|
||||
{
|
||||
if( mBitmap )
|
||||
delete mBitmap;
|
||||
|
||||
mWidth = width;
|
||||
mHeight = height;
|
||||
mBitmap = new wxBitmap( mWidth, mHeight );
|
||||
mBitmap = std::make_unique<wxBitmap>( mWidth, mHeight );
|
||||
}
|
||||
|
||||
wxColour bkgnd = GetBackgroundColour();
|
||||
@ -1281,14 +1262,14 @@ ExportMixerDialog::ExportMixerDialog( const TrackList *tracks, bool selectedOnly
|
||||
if (maxNumChannels > 32)
|
||||
maxNumChannels = 32;
|
||||
|
||||
mMixerSpec = new MixerSpec(numTracks, maxNumChannels);
|
||||
mMixerSpec = std::make_unique<MixerSpec>(numTracks, maxNumChannels);
|
||||
|
||||
wxBoxSizer *vertSizer;
|
||||
{
|
||||
auto uVertSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
|
||||
vertSizer = uVertSizer.get();
|
||||
|
||||
wxWindow *mixerPanel = safenew ExportMixerPanel(mMixerSpec, mTrackNames, this,
|
||||
wxWindow *mixerPanel = safenew ExportMixerPanel(mMixerSpec.get(), mTrackNames, this,
|
||||
ID_MIXERPANEL, wxDefaultPosition, wxSize(400, -1));
|
||||
mixerPanel->SetName(_("Mixer Panel"));
|
||||
vertSizer->Add(mixerPanel, 1, wxEXPAND | wxALIGN_CENTRE | wxALL, 5);
|
||||
@ -1326,11 +1307,6 @@ ExportMixerDialog::ExportMixerDialog( const TrackList *tracks, bool selectedOnly
|
||||
|
||||
ExportMixerDialog::~ExportMixerDialog()
|
||||
{
|
||||
if( mMixerSpec )
|
||||
{
|
||||
delete mMixerSpec;
|
||||
mMixerSpec = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void ExportMixerDialog::OnSize(wxSizeEvent &event)
|
||||
|
@ -188,7 +188,7 @@ private:
|
||||
FileDialog *mDialog;
|
||||
wxString mFileDialogTitle;
|
||||
AudacityProject *mProject;
|
||||
MixerSpec *mMixerSpec;
|
||||
std::unique_ptr<MixerSpec> mMixerSpec;
|
||||
|
||||
ExportPluginArray mPlugins;
|
||||
|
||||
@ -227,7 +227,7 @@ public:
|
||||
void OnPaint(wxPaintEvent & event);
|
||||
|
||||
private:
|
||||
wxBitmap *mBitmap;
|
||||
std::unique_ptr<wxBitmap> mBitmap;
|
||||
wxRect mEnvRect;
|
||||
int mWidth;
|
||||
int mHeight;
|
||||
@ -259,11 +259,11 @@ public:
|
||||
long style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER );
|
||||
virtual ~ExportMixerDialog();
|
||||
|
||||
MixerSpec* GetMixerSpec() { return mMixerSpec; }
|
||||
MixerSpec* GetMixerSpec() { return mMixerSpec.get(); }
|
||||
|
||||
private:
|
||||
wxStaticText *mChannelsText;
|
||||
MixerSpec *mMixerSpec;
|
||||
std::unique_ptr<MixerSpec> mMixerSpec;
|
||||
wxArrayString mTrackNames;
|
||||
|
||||
private:
|
||||
|
@ -522,18 +522,16 @@ void FFmpegPresets::ExportPresets(wxString &filename)
|
||||
WriteXML(writer);
|
||||
}
|
||||
|
||||
wxArrayString *FFmpegPresets::GetPresetList()
|
||||
void FFmpegPresets::GetPresetList(wxArrayString &list)
|
||||
{
|
||||
wxArrayString *list = new wxArrayString();
|
||||
list.Clear();
|
||||
FFmpegPresetMap::iterator iter;
|
||||
for (iter = mPresets.begin(); iter != mPresets.end(); ++iter)
|
||||
{
|
||||
list->Add(iter->second.mPresetName);
|
||||
list.Add(iter->second.mPresetName);
|
||||
}
|
||||
|
||||
list->Sort();
|
||||
|
||||
return list;
|
||||
list.Sort();
|
||||
}
|
||||
|
||||
void FFmpegPresets::DeletePreset(wxString &name)
|
||||
@ -1297,8 +1295,6 @@ const wxChar *ExportFFmpegOptions::PredictionOrderMethodNames[] = { _("Estimate"
|
||||
|
||||
ExportFFmpegOptions::~ExportFFmpegOptions()
|
||||
{
|
||||
delete mPresets;
|
||||
delete mPresetNames;
|
||||
DropFFmpegLibs();
|
||||
}
|
||||
|
||||
@ -1311,8 +1307,8 @@ ExportFFmpegOptions::ExportFFmpegOptions(wxWindow *parent)
|
||||
PickFFmpegLibs();
|
||||
//FFmpegLibsInst()->LoadLibs(NULL,true); //Loaded at startup or from Prefs now
|
||||
|
||||
mPresets = new FFmpegPresets();
|
||||
mPresetNames = mPresets->GetPresetList();
|
||||
mPresets = std::make_unique<FFmpegPresets>();
|
||||
mPresets->GetPresetList(mPresetNames);
|
||||
|
||||
if (FFmpegLibsInst()->ValidLibsLoaded())
|
||||
{
|
||||
@ -1397,7 +1393,7 @@ void ExportFFmpegOptions::PopulateOrExchange(ShuttleGui & S)
|
||||
S.StartMultiColumn(7, wxEXPAND);
|
||||
{
|
||||
S.SetStretchyCol(1);
|
||||
mPresetCombo = S.Id(FEPresetID).AddCombo(_("Preset:"), gPrefs->Read(wxT("/FileFormats/FFmpegPreset"),wxEmptyString), mPresetNames);
|
||||
mPresetCombo = S.Id(FEPresetID).AddCombo(_("Preset:"), gPrefs->Read(wxT("/FileFormats/FFmpegPreset"),wxEmptyString), &mPresetNames);
|
||||
mLoadPreset = S.Id(FELoadPresetID).AddButton(_("Load Preset"));
|
||||
mSavePreset = S.Id(FESavePresetID).AddButton(_("Save Preset"));
|
||||
mDeletePreset = S.Id(FEDeletePresetID).AddButton(_("Delete Preset"));
|
||||
@ -1754,7 +1750,7 @@ void ExportFFmpegOptions::OnDeletePreset(wxCommandEvent& WXUNUSED(event))
|
||||
long index = preset->FindString(presetname);
|
||||
preset->SetValue(wxEmptyString);
|
||||
preset->Delete(index);
|
||||
mPresetNames->Remove(presetname);
|
||||
mPresetNames.Remove(presetname);
|
||||
}
|
||||
|
||||
///
|
||||
@ -1769,13 +1765,13 @@ void ExportFFmpegOptions::OnSavePreset(wxCommandEvent& WXUNUSED(event))
|
||||
return;
|
||||
}
|
||||
mPresets->SavePreset(this,name);
|
||||
int index = mPresetNames->Index(name.c_str(),false);
|
||||
int index = mPresetNames.Index(name.c_str(),false);
|
||||
if (index == -1)
|
||||
{
|
||||
mPresetNames->Add(name);
|
||||
mPresetNames.Add(name);
|
||||
mPresetCombo->Clear();
|
||||
mPresetCombo->Append(*mPresetNames);
|
||||
mPresetCombo->Select(mPresetNames->Index(name,false));
|
||||
mPresetCombo->Append(mPresetNames);
|
||||
mPresetCombo->Select(mPresetNames.Index(name,false));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1816,10 +1812,9 @@ void ExportFFmpegOptions::OnImportPresets(wxCommandEvent& WXUNUSED(event))
|
||||
if (dlg.ShowModal() == wxID_CANCEL) return;
|
||||
path = dlg.GetPath();
|
||||
mPresets->ImportPresets(path);
|
||||
delete mPresetNames;
|
||||
mPresetNames = mPresets->GetPresetList();
|
||||
mPresets->GetPresetList(mPresetNames);
|
||||
mPresetCombo->Clear();
|
||||
mPresetCombo->Append(*mPresetNames);
|
||||
mPresetCombo->Append(mPresetNames);
|
||||
}
|
||||
|
||||
///
|
||||
|
@ -262,9 +262,9 @@ private:
|
||||
int mBitRateFromChoice;
|
||||
int mSampleRateFromChoice;
|
||||
|
||||
FFmpegPresets *mPresets;
|
||||
std::unique_ptr<FFmpegPresets> mPresets;
|
||||
|
||||
wxArrayString *mPresetNames;
|
||||
wxArrayString mPresetNames;
|
||||
|
||||
/// Finds the format currently selected and returns it's name and description
|
||||
void FindSelectedFormat(wxString **name, wxString **longname);
|
||||
@ -324,7 +324,7 @@ public:
|
||||
FFmpegPresets();
|
||||
~FFmpegPresets();
|
||||
|
||||
wxArrayString *GetPresetList();
|
||||
void GetPresetList(wxArrayString &list);
|
||||
void LoadPreset(ExportFFmpegOptions *parent, wxString &name);
|
||||
void SavePreset(ExportFFmpegOptions *parent, wxString &name);
|
||||
void DeletePreset(wxString &name);
|
||||
|
@ -79,7 +79,7 @@ FormatClassifier::FormatClassifier(const char* filename) :
|
||||
// Build a debug writer
|
||||
char dfile [1024];
|
||||
sprintf(dfile, "%s.sig", filename);
|
||||
mpWriter = new DebugWriter(dfile);
|
||||
mpWriter = std::make_unique<DebugWriter>(dfile);
|
||||
#endif
|
||||
|
||||
// Run it
|
||||
@ -102,10 +102,6 @@ FormatClassifier::~FormatClassifier()
|
||||
|
||||
delete[] mMonoFeat;
|
||||
delete[] mStereoFeat;
|
||||
|
||||
#ifdef FORMATCLASSIFIER_SIGNAL_DEBUG
|
||||
delete mpWriter;
|
||||
#endif
|
||||
}
|
||||
|
||||
FormatClassifier::FormatClassT FormatClassifier::GetResultFormat()
|
||||
|
@ -72,7 +72,7 @@ private:
|
||||
SpecPowerMeter mMeter;
|
||||
|
||||
#ifdef FORMATCLASSIFIER_SIGNAL_DEBUG
|
||||
DebugWriter* mpWriter;
|
||||
std::unique_ptr<DebugWriter> mpWriter;
|
||||
#endif
|
||||
|
||||
float* mSigBuffer;
|
||||
|
@ -168,7 +168,7 @@ public:
|
||||
|
||||
private:
|
||||
sampleFormat mFormat;
|
||||
MyFLACFile *mFile;
|
||||
std::unique_ptr<MyFLACFile> mFile;
|
||||
wxFFile mHandle;
|
||||
unsigned long mSampleRate;
|
||||
unsigned long mNumChannels;
|
||||
@ -343,7 +343,7 @@ FLACImportFileHandle::FLACImportFileHandle(const wxString & name)
|
||||
{
|
||||
mFormat = (sampleFormat)
|
||||
gPrefs->Read(wxT("/SamplingRate/DefaultProjectSampleFormat"), floatSample);
|
||||
mFile = new MyFLACFile(this);
|
||||
mFile = std::make_unique<MyFLACFile>(this);
|
||||
}
|
||||
|
||||
bool FLACImportFileHandle::Init()
|
||||
@ -554,7 +554,6 @@ FLACImportFileHandle::~FLACImportFileHandle()
|
||||
//don't DELETE mFile if we are using OD.
|
||||
#ifndef EXPERIMENTAL_OD_FLAC
|
||||
mFile->finish();
|
||||
delete mFile;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -293,17 +293,14 @@ GetGStreamerImportPlugin(ImportPluginList *importPluginList,
|
||||
nano);
|
||||
|
||||
// Instantiate plugin
|
||||
GStreamerImportPlugin *plug = new GStreamerImportPlugin();
|
||||
auto plug = make_movable<GStreamerImportPlugin>();
|
||||
|
||||
// No supported extensions...no gstreamer plugins installed
|
||||
if (plug->GetSupportedExtensions().GetCount() == 0)
|
||||
{
|
||||
delete plug;
|
||||
return;
|
||||
}
|
||||
|
||||
// Add to list of importers
|
||||
importPluginList->Append(plug);
|
||||
importPluginList->push_back(std::move(plug));
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
@ -120,7 +120,7 @@ public:
|
||||
class LOFImportFileHandle final : public ImportFileHandle
|
||||
{
|
||||
public:
|
||||
LOFImportFileHandle(const wxString & name, wxTextFile *file);
|
||||
LOFImportFileHandle(const wxString & name, std::unique_ptr<wxTextFile> &&file);
|
||||
~LOFImportFileHandle();
|
||||
|
||||
wxString GetFileDescription();
|
||||
@ -144,7 +144,7 @@ private:
|
||||
void doDuration();
|
||||
void doScrollOffset();
|
||||
|
||||
wxTextFile *mTextFile;
|
||||
std::unique_ptr<wxTextFile> mTextFile;
|
||||
wxFileName mLOFFileName; /**< The name of the LOF file, which is used to
|
||||
interpret relative paths in it */
|
||||
AudacityProject *mProject;
|
||||
@ -161,9 +161,10 @@ private:
|
||||
double scrollOffset;
|
||||
};
|
||||
|
||||
LOFImportFileHandle::LOFImportFileHandle(const wxString & name, wxTextFile *file)
|
||||
LOFImportFileHandle::LOFImportFileHandle
|
||||
(const wxString & name, std::unique_ptr<wxTextFile> &&file)
|
||||
: ImportFileHandle(name),
|
||||
mTextFile(file)
|
||||
mTextFile(std::move(file))
|
||||
, mLOFFileName{name}
|
||||
{
|
||||
mProject = GetActiveProject();
|
||||
@ -211,16 +212,13 @@ std::unique_ptr<ImportFileHandle> LOFImportPlugin::Open(const wxString &filename
|
||||
binaryFile.Close();
|
||||
|
||||
// Now open the file again as text file
|
||||
wxTextFile *file = new wxTextFile(filename);
|
||||
auto file = std::make_unique<wxTextFile>(filename);
|
||||
file->Open();
|
||||
|
||||
if (!file->IsOpened())
|
||||
{
|
||||
delete file;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return std::make_unique<LOFImportFileHandle>(filename, file);
|
||||
return std::make_unique<LOFImportFileHandle>(filename, std::move(file));
|
||||
}
|
||||
|
||||
wxString LOFImportFileHandle::GetFileDescription()
|
||||
@ -501,10 +499,4 @@ void LOFImportFileHandle::doScrollOffset()
|
||||
|
||||
LOFImportFileHandle::~LOFImportFileHandle()
|
||||
{
|
||||
if(mTextFile)
|
||||
{
|
||||
if (mTextFile->IsOpened())
|
||||
mTextFile->Close();
|
||||
delete mTextFile;
|
||||
}
|
||||
}
|
||||
|
@ -120,9 +120,9 @@ public:
|
||||
class MP3ImportFileHandle final : public ImportFileHandle
|
||||
{
|
||||
public:
|
||||
MP3ImportFileHandle(wxFile *file, wxString filename):
|
||||
MP3ImportFileHandle(std::unique_ptr<wxFile> &&file, wxString filename):
|
||||
ImportFileHandle(filename),
|
||||
mFile(file)
|
||||
mFile(std::move(file))
|
||||
{
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ public:
|
||||
private:
|
||||
void ImportID3(Tags *tags);
|
||||
|
||||
wxFile *mFile;
|
||||
std::unique_ptr<wxFile> mFile;
|
||||
void *mUserData;
|
||||
struct private_data mPrivateData;
|
||||
mad_decoder mDecoder;
|
||||
@ -182,17 +182,15 @@ wxString MP3ImportPlugin::GetPluginFormatDescription()
|
||||
|
||||
std::unique_ptr<ImportFileHandle> MP3ImportPlugin::Open(const wxString &Filename)
|
||||
{
|
||||
wxFile *file = new wxFile(Filename);
|
||||
auto file = std::make_unique<wxFile>(Filename);
|
||||
|
||||
if (!file->IsOpened()) {
|
||||
delete file;
|
||||
if (!file->IsOpened())
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* There's no way to tell if this is a valid mp3 file before actually
|
||||
* decoding, so we return a valid FileHandle. */
|
||||
|
||||
return std::make_unique<MP3ImportFileHandle>(file, Filename);
|
||||
return std::make_unique<MP3ImportFileHandle>(std::move(file), Filename);
|
||||
}
|
||||
|
||||
wxString MP3ImportFileHandle::GetFileDescription()
|
||||
@ -215,7 +213,7 @@ int MP3ImportFileHandle::Import(TrackFactory *trackFactory, TrackHolders &outTra
|
||||
|
||||
/* Prepare decoder data, initialize decoder */
|
||||
|
||||
mPrivateData.file = mFile;
|
||||
mPrivateData.file = mFile.get();
|
||||
mPrivateData.inputBuffer = new unsigned char [INPUT_BUFFER_SIZE];
|
||||
mPrivateData.progress = mProgress.get();
|
||||
mPrivateData.updateResult= eProgressSuccess;
|
||||
@ -260,12 +258,6 @@ int MP3ImportFileHandle::Import(TrackFactory *trackFactory, TrackHolders &outTra
|
||||
|
||||
MP3ImportFileHandle::~MP3ImportFileHandle()
|
||||
{
|
||||
if(mFile) {
|
||||
if (mFile->IsOpened()) {
|
||||
mFile->Close();
|
||||
}
|
||||
delete mFile;
|
||||
}
|
||||
}
|
||||
|
||||
void MP3ImportFileHandle::ImportID3(Tags *tags)
|
||||
|
@ -100,20 +100,20 @@ class OggImportFileHandle final : public ImportFileHandle
|
||||
{
|
||||
public:
|
||||
OggImportFileHandle(const wxString & filename,
|
||||
wxFFile *file,
|
||||
OggVorbis_File *vorbisFile)
|
||||
std::unique_ptr<wxFFile> &&file,
|
||||
std::unique_ptr<OggVorbis_File> &&vorbisFile)
|
||||
: ImportFileHandle(filename),
|
||||
mFile(file),
|
||||
mVorbisFile(vorbisFile)
|
||||
mFile(std::move(file)),
|
||||
mVorbisFile(std::move(vorbisFile))
|
||||
{
|
||||
mFormat = (sampleFormat)
|
||||
gPrefs->Read(wxT("/SamplingRate/DefaultProjectSampleFormat"), floatSample);
|
||||
|
||||
mStreamUsage = new int[vorbisFile->links];
|
||||
for (int i = 0; i < vorbisFile->links; i++)
|
||||
mStreamUsage = new int[mVorbisFile->links];
|
||||
for (int i = 0; i < mVorbisFile->links; i++)
|
||||
{
|
||||
wxString strinfo;
|
||||
strinfo.Printf(wxT("Index[%02x] Version[%d], Channels[%d], Rate[%ld]"), (unsigned int) i,vorbisFile->vi[i].version,vorbisFile->vi[i].channels,vorbisFile->vi[i].rate);
|
||||
strinfo.Printf(wxT("Index[%02x] Version[%d], Channels[%d], Rate[%ld]"), (unsigned int) i,mVorbisFile->vi[i].version,mVorbisFile->vi[i].channels,mVorbisFile->vi[i].rate);
|
||||
mStreamInfo.Add(strinfo);
|
||||
mStreamUsage[i] = 0;
|
||||
}
|
||||
@ -149,8 +149,8 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
wxFFile *mFile;
|
||||
OggVorbis_File *mVorbisFile;
|
||||
std::unique_ptr<wxFFile> mFile;
|
||||
std::unique_ptr<OggVorbis_File> mVorbisFile;
|
||||
|
||||
int *mStreamUsage;
|
||||
wxArrayString mStreamInfo;
|
||||
@ -178,17 +178,15 @@ std::unique_ptr<ImportFileHandle> OggImportPlugin::Open(const wxString &filename
|
||||
wxUnusedVar(OV_CALLBACKS_STREAMONLY);
|
||||
wxUnusedVar(OV_CALLBACKS_STREAMONLY_NOCLOSE);
|
||||
|
||||
OggVorbis_File *vorbisFile = new OggVorbis_File;
|
||||
wxFFile *file = new wxFFile(filename, wxT("rb"));
|
||||
auto vorbisFile = std::make_unique<OggVorbis_File>();
|
||||
auto file = std::make_unique<wxFFile>(filename, wxT("rb"));
|
||||
|
||||
if (!file->IsOpened()) {
|
||||
// No need for a message box, it's done automatically (but how?)
|
||||
delete vorbisFile;
|
||||
delete file;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int err = ov_open(file->fp(), vorbisFile, NULL, 0);
|
||||
int err = ov_open(file->fp(), vorbisFile.get(), NULL, 0);
|
||||
|
||||
if (err < 0) {
|
||||
wxString message;
|
||||
@ -213,12 +211,10 @@ std::unique_ptr<ImportFileHandle> OggImportPlugin::Open(const wxString &filename
|
||||
|
||||
// what to do with message?
|
||||
file->Close();
|
||||
delete vorbisFile;
|
||||
delete file;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return std::make_unique<OggImportFileHandle>(filename, file, vorbisFile);
|
||||
return std::make_unique<OggImportFileHandle>(filename, std::move(file), std::move(vorbisFile));
|
||||
}
|
||||
|
||||
wxString OggImportFileHandle::GetFileDescription()
|
||||
@ -258,7 +254,7 @@ int OggImportFileHandle::Import(TrackFactory *trackFactory, TrackHolders &outTra
|
||||
continue;
|
||||
}
|
||||
|
||||
vorbis_info *vi = ov_info(mVorbisFile, i);
|
||||
vorbis_info *vi = ov_info(mVorbisFile.get(), i);
|
||||
|
||||
link.resize(vi->channels);
|
||||
|
||||
@ -314,11 +310,11 @@ int OggImportFileHandle::Import(TrackFactory *trackFactory, TrackHolders &outTra
|
||||
// my hard drive that have malformed headers, and this added call
|
||||
// causes them to be read correctly. Otherwise they have lots of
|
||||
// zeros inserted at the beginning
|
||||
ov_pcm_seek(mVorbisFile, 0);
|
||||
ov_pcm_seek(mVorbisFile.get(), 0);
|
||||
|
||||
do {
|
||||
/* get data from the decoder */
|
||||
bytesRead = ov_read(mVorbisFile, (char *) mainBuffer,
|
||||
bytesRead = ov_read(mVorbisFile.get(), (char *) mainBuffer,
|
||||
CODEC_TRANSFER_SIZE,
|
||||
endian,
|
||||
2, // word length (2 for 16 bit samples)
|
||||
@ -359,8 +355,8 @@ int OggImportFileHandle::Import(TrackFactory *trackFactory, TrackHolders &outTra
|
||||
|
||||
samplesSinceLastCallback += samplesRead;
|
||||
if (samplesSinceLastCallback > SAMPLES_PER_CALLBACK) {
|
||||
updateResult = mProgress->Update(ov_time_tell(mVorbisFile),
|
||||
ov_time_total(mVorbisFile, bitstream));
|
||||
updateResult = mProgress->Update(ov_time_tell(mVorbisFile.get()),
|
||||
ov_time_total(mVorbisFile.get(), bitstream));
|
||||
samplesSinceLastCallback -= SAMPLES_PER_CALLBACK;
|
||||
|
||||
}
|
||||
@ -406,12 +402,10 @@ int OggImportFileHandle::Import(TrackFactory *trackFactory, TrackHolders &outTra
|
||||
|
||||
OggImportFileHandle::~OggImportFileHandle()
|
||||
{
|
||||
ov_clear(mVorbisFile);
|
||||
ov_clear(mVorbisFile.get());
|
||||
mFile->Detach(); // so that it doesn't try to close the file (ov_clear()
|
||||
// did that already)
|
||||
delete[] mStreamUsage;
|
||||
delete mVorbisFile;
|
||||
delete mFile;
|
||||
}
|
||||
|
||||
#endif /* USE_LIBVORBIS */
|
||||
|
Loading…
x
Reference in New Issue
Block a user