mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-24 16:20:05 +02:00
ImportFileHandle::GetStreamInfo returns reference. Don't dereference NULLs.
This commit is contained in:
parent
eb6e093912
commit
9c18d3853d
@ -757,8 +757,8 @@ wxDialog( parent, id, title, position, size, style | wxRESIZE_BORDER )
|
||||
auto uVertSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
|
||||
vertSizer = uVertSizer.get();
|
||||
|
||||
wxArrayString *choices = mFile->GetStreamInfo();
|
||||
StreamList = safenew wxListBox(this, -1, wxDefaultPosition, wxDefaultSize, *choices, wxLB_EXTENDED | wxLB_ALWAYS_SB);
|
||||
auto choices = mFile->GetStreamInfo();
|
||||
StreamList = safenew wxListBox(this, -1, wxDefaultPosition, wxDefaultSize, choices, wxLB_EXTENDED | wxLB_ALWAYS_SB);
|
||||
|
||||
vertSizer->Add(StreamList, 1, wxEXPAND | wxALIGN_LEFT | wxALL, 5);
|
||||
|
||||
|
@ -246,7 +246,7 @@ public:
|
||||
|
||||
///! Called by Import.cpp
|
||||
///\return array of strings - descriptions of the streams
|
||||
wxArrayString *GetStreamInfo()
|
||||
const wxArrayString &GetStreamInfo() override
|
||||
{
|
||||
return mStreamInfo;
|
||||
}
|
||||
@ -266,7 +266,7 @@ private:
|
||||
AVFormatContext *mFormatContext; //!< Format description, also contains metadata and some useful info
|
||||
int mNumStreams; //!< mNumstreams is less or equal to mFormatContext->nb_streams
|
||||
ScsPtr mScs; //!< Points to array of pointers to stream contexts, which may be shared with a decoder task.
|
||||
wxArrayString *mStreamInfo; //!< Array of stream descriptions. Length is mNumStreams
|
||||
wxArrayString mStreamInfo; //!< Array of stream descriptions. Length is mNumStreams
|
||||
|
||||
wxInt64 mProgressPos; //!< Current timestamp, file position or whatever is used as first argument for Update()
|
||||
wxInt64 mProgressLen; //!< Duration, total length or whatever is used as second argument for Update()
|
||||
@ -341,7 +341,6 @@ FFmpegImportFileHandle::FFmpegImportFileHandle(const wxString & name)
|
||||
{
|
||||
PickFFmpegLibs();
|
||||
|
||||
mStreamInfo = new wxArrayString();
|
||||
mFormatContext = NULL;
|
||||
mNumStreams = 0;
|
||||
mCancelled = false;
|
||||
@ -442,7 +441,7 @@ bool FFmpegImportFileHandle::InitCodecs()
|
||||
lang.FromUTF8(tag->value);
|
||||
}
|
||||
strinfo.Printf(_("Index[%02x] Codec[%s], Language[%s], Bitrate[%s], Channels[%d], Duration[%d]"),sc->m_stream->id,codec->name,lang.c_str(),bitrate.c_str(),sc->m_stream->codec->channels, duration);
|
||||
mStreamInfo->Add(strinfo);
|
||||
mStreamInfo.Add(strinfo);
|
||||
mScs->get()[mNumStreams++] = std::move(sc);
|
||||
}
|
||||
//for video and unknown streams do nothing
|
||||
@ -864,8 +863,6 @@ FFmpegImportFileHandle::~FFmpegImportFileHandle()
|
||||
// Do this before unloading the libraries
|
||||
mContext.reset();
|
||||
|
||||
delete mStreamInfo;
|
||||
|
||||
DropFFmpegLibs();
|
||||
}
|
||||
|
||||
|
@ -158,7 +158,11 @@ public:
|
||||
|
||||
wxInt32 GetStreamCount(){ return 1; }
|
||||
|
||||
wxArrayString *GetStreamInfo(){ return NULL; }
|
||||
const wxArrayString &GetStreamInfo() override
|
||||
{
|
||||
static wxArrayString empty;
|
||||
return empty;
|
||||
}
|
||||
|
||||
void SetStreamUsage(wxInt32 WXUNUSED(StreamID), bool WXUNUSED(Use)){}
|
||||
|
||||
|
@ -120,7 +120,7 @@ public:
|
||||
|
||||
///! Called by Import.cpp
|
||||
///\return array of strings - descriptions of the streams
|
||||
wxArrayString *GetStreamInfo();
|
||||
const wxArrayString &GetStreamInfo() override;
|
||||
|
||||
///! Called by Import.cpp
|
||||
///\param index - index of the stream in mStreamInfo and mStreams arrays
|
||||
@ -870,10 +870,10 @@ GStreamerImportFileHandle::GetStreamCount()
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Return array of strings - descriptions of the streams
|
||||
wxArrayString *
|
||||
const wxArrayString &
|
||||
GStreamerImportFileHandle::GetStreamInfo()
|
||||
{
|
||||
return &mStreamInfo;
|
||||
return mStreamInfo;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -130,7 +130,11 @@ public:
|
||||
|
||||
wxInt32 GetStreamCount(){ return 1; }
|
||||
|
||||
wxArrayString *GetStreamInfo(){ return NULL; }
|
||||
const wxArrayString &GetStreamInfo() override
|
||||
{
|
||||
static wxArrayString empty;
|
||||
return empty;
|
||||
}
|
||||
|
||||
void SetStreamUsage(wxInt32 WXUNUSED(StreamID), bool WXUNUSED(Use)){}
|
||||
|
||||
|
@ -135,7 +135,11 @@ public:
|
||||
|
||||
wxInt32 GetStreamCount(){ return 1; }
|
||||
|
||||
wxArrayString *GetStreamInfo(){ return NULL; }
|
||||
const wxArrayString &GetStreamInfo() override
|
||||
{
|
||||
static wxArrayString empty;
|
||||
return empty;
|
||||
}
|
||||
|
||||
void SetStreamUsage(wxInt32 WXUNUSED(StreamID), bool WXUNUSED(Use)){}
|
||||
|
||||
|
@ -109,13 +109,12 @@ public:
|
||||
mFormat = (sampleFormat)
|
||||
gPrefs->Read(wxT("/SamplingRate/DefaultProjectSampleFormat"), floatSample);
|
||||
|
||||
mStreamInfo = new wxArrayString();
|
||||
mStreamUsage = new int[vorbisFile->links];
|
||||
for (int i = 0; i < vorbisFile->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);
|
||||
mStreamInfo->Add(strinfo);
|
||||
mStreamInfo.Add(strinfo);
|
||||
mStreamUsage[i] = 0;
|
||||
}
|
||||
|
||||
@ -135,7 +134,7 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
wxArrayString *GetStreamInfo()
|
||||
const wxArrayString &GetStreamInfo() override
|
||||
{
|
||||
return mStreamInfo;
|
||||
}
|
||||
@ -154,7 +153,7 @@ private:
|
||||
OggVorbis_File *mVorbisFile;
|
||||
|
||||
int *mStreamUsage;
|
||||
wxArrayString *mStreamInfo;
|
||||
wxArrayString mStreamInfo;
|
||||
std::list<TrackHolders> mChannels;
|
||||
|
||||
sampleFormat mFormat;
|
||||
@ -410,7 +409,6 @@ OggImportFileHandle::~OggImportFileHandle()
|
||||
ov_clear(mVorbisFile);
|
||||
mFile->Detach(); // so that it doesn't try to close the file (ov_clear()
|
||||
// did that already)
|
||||
delete mStreamInfo;
|
||||
delete[] mStreamUsage;
|
||||
delete mVorbisFile;
|
||||
delete mFile;
|
||||
|
@ -99,7 +99,11 @@ public:
|
||||
|
||||
wxInt32 GetStreamCount(){ return 1; }
|
||||
|
||||
wxArrayString *GetStreamInfo(){ return NULL; }
|
||||
const wxArrayString &GetStreamInfo() override
|
||||
{
|
||||
static wxArrayString empty;
|
||||
return empty;
|
||||
}
|
||||
|
||||
void SetStreamUsage(wxInt32 WXUNUSED(StreamID), bool WXUNUSED(Use)){}
|
||||
|
||||
|
@ -161,7 +161,7 @@ public:
|
||||
virtual wxInt32 GetStreamCount() = 0;
|
||||
|
||||
// Return stream descriptions list
|
||||
virtual wxArrayString *GetStreamInfo() = 0;
|
||||
virtual const wxArrayString &GetStreamInfo() = 0;
|
||||
|
||||
// Set stream "import/don't import" flag
|
||||
virtual void SetStreamUsage(wxInt32 StreamID, bool Use) = 0;
|
||||
|
@ -142,9 +142,10 @@ class QTImportFileHandle final : public ImportFileHandle
|
||||
return 1;
|
||||
}
|
||||
|
||||
wxArrayString *GetStreamInfo()
|
||||
const wxArrayString &GetStreamInfo() override
|
||||
{
|
||||
return NULL;
|
||||
static wxArrayString empty;
|
||||
return empty;
|
||||
}
|
||||
|
||||
void SetStreamUsage(wxInt32 StreamID, bool Use)
|
||||
|
Loading…
x
Reference in New Issue
Block a user