Remove naked new[] in: export
This commit is contained in:
parent
ea05fac870
commit
9bdc7b2cbf
|
@ -996,23 +996,20 @@ ExportMixerPanel::ExportMixerPanel( MixerSpec *mixerSpec,
|
|||
wxArrayString trackNames,wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos, const wxSize& size):
|
||||
wxPanelWrapper(parent, id, pos, size)
|
||||
, mMixerSpec{mixerSpec}
|
||||
, mChannelRects{ mMixerSpec->GetMaxNumChannels() }
|
||||
, mTrackRects{ mMixerSpec->GetNumTracks() }
|
||||
{
|
||||
mBitmap = NULL;
|
||||
mWidth = 0;
|
||||
mHeight = 0;
|
||||
mMixerSpec = mixerSpec;
|
||||
mSelectedTrack = mSelectedChannel = -1;
|
||||
|
||||
mTrackRects = new wxRect[ mMixerSpec->GetNumTracks() ];
|
||||
mChannelRects = new wxRect[ mMixerSpec->GetMaxNumChannels() ];
|
||||
|
||||
mTrackNames = trackNames;
|
||||
}
|
||||
|
||||
ExportMixerPanel::~ExportMixerPanel()
|
||||
{
|
||||
delete[] mTrackRects;
|
||||
delete[] mChannelRects;
|
||||
}
|
||||
|
||||
//set the font on memDC such that text can fit in specified width and height
|
||||
|
|
|
@ -234,8 +234,8 @@ private:
|
|||
int mWidth;
|
||||
int mHeight;
|
||||
MixerSpec *mMixerSpec;
|
||||
wxRect *mChannelRects;
|
||||
wxRect *mTrackRects;
|
||||
ArrayOf<wxRect> mChannelRects;
|
||||
ArrayOf<wxRect> mTrackRects;
|
||||
int mSelectedTrack, mSelectedChannel;
|
||||
wxArrayString mTrackNames;
|
||||
int mBoxWidth, mChannelHeight, mTrackHeight;
|
||||
|
|
|
@ -139,7 +139,7 @@ bool ExportFLACOptions::TransferDataFromWindow()
|
|||
// ExportFLAC Class
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#define SAMPLES_PER_RUN 8192
|
||||
#define SAMPLES_PER_RUN 8192u
|
||||
|
||||
/* FLACPP_API_VERSION_CURRENT is 6 for libFLAC++ from flac-1.1.3 (see <FLAC++/export.h>) */
|
||||
#if !defined FLACPP_API_VERSION_CURRENT || FLACPP_API_VERSION_CURRENT < 6
|
||||
|
@ -311,11 +311,7 @@ ProgressResult ExportFLAC::Export(AudacityProject *project,
|
|||
numChannels, SAMPLES_PER_RUN, false,
|
||||
rate, format, true, mixerSpec);
|
||||
|
||||
int i;
|
||||
FLAC__int32 **tmpsmplbuf = new FLAC__int32*[numChannels];
|
||||
for (i = 0; i < numChannels; i++) {
|
||||
tmpsmplbuf[i] = (FLAC__int32 *) calloc(SAMPLES_PER_RUN, sizeof(FLAC__int32));
|
||||
}
|
||||
ArraysOf<FLAC__int32> tmpsmplbuf{ numChannels, SAMPLES_PER_RUN, true };
|
||||
|
||||
{
|
||||
ProgressDialog progress(wxFileName(fName).GetName(),
|
||||
|
@ -329,7 +325,7 @@ ProgressResult ExportFLAC::Export(AudacityProject *project,
|
|||
break;
|
||||
}
|
||||
else {
|
||||
for (i = 0; i < numChannels; i++) {
|
||||
for (size_t i = 0; i < numChannels; i++) {
|
||||
samplePtr mixed = mixer->GetBuffer(i);
|
||||
if (format == int24Sample) {
|
||||
for (decltype(samplesThisRun) j = 0; j < samplesThisRun; j++) {
|
||||
|
@ -342,7 +338,7 @@ ProgressResult ExportFLAC::Export(AudacityProject *project,
|
|||
}
|
||||
}
|
||||
}
|
||||
encoder.process(tmpsmplbuf, samplesThisRun);
|
||||
encoder.process(reinterpret_cast<const FLAC__int32**>(tmpsmplbuf.get()), samplesThisRun);
|
||||
}
|
||||
updateResult = progress.Update(mixer->MixGetCurrentTime() - t0, t1 - t0);
|
||||
}
|
||||
|
@ -350,12 +346,6 @@ ProgressResult ExportFLAC::Export(AudacityProject *project,
|
|||
encoder.finish();
|
||||
}
|
||||
|
||||
for (i = 0; i < numChannels; i++) {
|
||||
free(tmpsmplbuf[i]);
|
||||
}
|
||||
|
||||
delete[] tmpsmplbuf;
|
||||
|
||||
return updateResult;
|
||||
}
|
||||
|
||||
|
|
|
@ -251,12 +251,12 @@ ProgressResult ExportMP2::Export(AudacityProject *project,
|
|||
|
||||
// Values taken from the twolame simple encoder sample
|
||||
const int pcmBufferSize = 9216 / 2; // number of samples
|
||||
const int mp2BufferSize = 16384; // bytes
|
||||
const size_t mp2BufferSize = 16384u; // bytes
|
||||
|
||||
// We allocate a buffer which is twice as big as the
|
||||
// input buffer, which should always be enough.
|
||||
// We have to multiply by 4 because one sample is 2 bytes wide!
|
||||
unsigned char* mp2Buffer = new unsigned char[mp2BufferSize];
|
||||
ArrayOf<unsigned char> mp2Buffer{ mp2BufferSize };
|
||||
|
||||
const WaveTrackConstArray waveTracks =
|
||||
tracks->GetWaveTrackConstArray(selectionOnly, false);
|
||||
|
@ -285,10 +285,10 @@ ProgressResult ExportMP2::Export(AudacityProject *project,
|
|||
encodeOptions,
|
||||
pcmBuffer,
|
||||
pcmNumSamples,
|
||||
mp2Buffer,
|
||||
mp2Buffer.get(),
|
||||
mp2BufferSize);
|
||||
|
||||
outFile.Write(mp2Buffer, mp2BufferNumBytes);
|
||||
outFile.Write(mp2Buffer.get(), mp2BufferNumBytes);
|
||||
|
||||
updateResult = progress.Update(mixer->MixGetCurrentTime() - t0, t1 - t0);
|
||||
}
|
||||
|
@ -296,16 +296,14 @@ ProgressResult ExportMP2::Export(AudacityProject *project,
|
|||
|
||||
int mp2BufferNumBytes = twolame_encode_flush(
|
||||
encodeOptions,
|
||||
mp2Buffer,
|
||||
mp2Buffer.get(),
|
||||
mp2BufferSize);
|
||||
|
||||
if (mp2BufferNumBytes > 0)
|
||||
outFile.Write(mp2Buffer, mp2BufferNumBytes);
|
||||
outFile.Write(mp2Buffer.get(), mp2BufferNumBytes);
|
||||
|
||||
twolame_close(&encodeOptions);
|
||||
|
||||
delete[] mp2Buffer;
|
||||
|
||||
/* Write ID3 tag if it was supposed to be at the end of the file */
|
||||
|
||||
if (id3len && endOfFile)
|
||||
|
|
|
@ -1808,8 +1808,8 @@ ProgressResult ExportMP3::Export(AudacityProject *project,
|
|||
auto updateResult = ProgressResult::Success;
|
||||
long bytes;
|
||||
|
||||
int bufferSize = exporter.GetOutBufferSize();
|
||||
unsigned char *buffer = new unsigned char[bufferSize];
|
||||
size_t bufferSize = std::max(0, exporter.GetOutBufferSize());
|
||||
ArrayOf<unsigned char> buffer{ bufferSize };
|
||||
wxASSERT(buffer);
|
||||
|
||||
const WaveTrackConstArray waveTracks =
|
||||
|
@ -1854,18 +1854,18 @@ ProgressResult ExportMP3::Export(AudacityProject *project,
|
|||
|
||||
if (blockLen < inSamples) {
|
||||
if (channels > 1) {
|
||||
bytes = exporter.EncodeRemainder(mixed, blockLen, buffer);
|
||||
bytes = exporter.EncodeRemainder(mixed, blockLen, buffer.get());
|
||||
}
|
||||
else {
|
||||
bytes = exporter.EncodeRemainderMono(mixed, blockLen, buffer);
|
||||
bytes = exporter.EncodeRemainderMono(mixed, blockLen, buffer.get());
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (channels > 1) {
|
||||
bytes = exporter.EncodeBuffer(mixed, buffer);
|
||||
bytes = exporter.EncodeBuffer(mixed, buffer.get());
|
||||
}
|
||||
else {
|
||||
bytes = exporter.EncodeBufferMono(mixed, buffer);
|
||||
bytes = exporter.EncodeBufferMono(mixed, buffer.get());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1876,16 +1876,16 @@ ProgressResult ExportMP3::Export(AudacityProject *project,
|
|||
break;
|
||||
}
|
||||
|
||||
outFile.Write(buffer, bytes);
|
||||
outFile.Write(buffer.get(), bytes);
|
||||
|
||||
updateResult = progress.Update(mixer->MixGetCurrentTime() - t0, t1 - t0);
|
||||
}
|
||||
}
|
||||
|
||||
bytes = exporter.FinishStream(buffer);
|
||||
bytes = exporter.FinishStream(buffer.get());
|
||||
|
||||
if (bytes) {
|
||||
outFile.Write(buffer, bytes);
|
||||
outFile.Write(buffer.get(), bytes);
|
||||
}
|
||||
|
||||
// Write ID3 tag if it was supposed to be at the end of the file
|
||||
|
@ -1908,8 +1908,6 @@ ProgressResult ExportMP3::Export(AudacityProject *project,
|
|||
// Close the file
|
||||
outFile.Close();
|
||||
|
||||
delete [] buffer;
|
||||
|
||||
return updateResult;
|
||||
}
|
||||
|
||||
|
|
|
@ -263,7 +263,7 @@ ProgressResult ExportOGG::Export(AudacityProject *project,
|
|||
}
|
||||
else {
|
||||
|
||||
for (int i = 0; i < numChannels; i++) {
|
||||
for (size_t i = 0; i < numChannels; i++) {
|
||||
float *temp = (float *)mixer->GetBuffer(i);
|
||||
memcpy(vorbis_buffer[i], temp, sizeof(float)*SAMPLES_PER_RUN);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue