1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-03-07 15:05:38 +01:00

ExportPlugin::CreateMixer returns a smart pointer

This commit is contained in:
Paul Licameli
2016-03-31 01:33:17 -04:00
parent e6e7b73043
commit ff3e3d0e83
9 changed files with 61 additions and 75 deletions

View File

@@ -204,9 +204,9 @@ ExportMP2::ExportMP2()
}
int ExportMP2::Export(AudacityProject *project,
int channels, const wxString &fName,
bool selectionOnly, double t0, double t1, MixerSpec *mixerSpec, const Tags *metadata,
int WXUNUSED(subformat))
int channels, const wxString &fName,
bool selectionOnly, double t0, double t1, MixerSpec *mixerSpec, const Tags *metadata,
int WXUNUSED(subformat))
{
bool stereo = (channels == 2);
long bitrate = gPrefs->Read(wxT("/FileFormats/MP2Bitrate"), 160);
@@ -221,7 +221,7 @@ int ExportMP2::Export(AudacityProject *project,
twolame_set_in_samplerate(encodeOptions, (int)(rate + 0.5));
twolame_set_out_samplerate(encodeOptions, (int)(rate + 0.5));
twolame_set_bitrate(encodeOptions, bitrate);
twolame_set_num_channels(encodeOptions, stereo ? 2:1);
twolame_set_num_channels(encodeOptions, stereo ? 2 : 1);
if (twolame_init_params(encodeOptions) != 0)
{
@@ -247,11 +247,11 @@ int ExportMP2::Export(AudacityProject *project,
bool endOfFile;
id3len = AddTags(project, &id3buffer, &endOfFile, metadata);
if (id3len && !endOfFile)
outFile.Write(id3buffer, id3len);
outFile.Write(id3buffer, id3len);
// Values taken from the twolame simple encoder sample
const int pcmBufferSize = 9216 / 2; // number of samples
const int mp2BufferSize = 16384 ; // bytes
const int mp2BufferSize = 16384; // bytes
// We allocate a buffer which is twice as big as the
// input buffer, which should always be enough.
@@ -260,14 +260,14 @@ int ExportMP2::Export(AudacityProject *project,
const WaveTrackConstArray waveTracks =
tracks->GetWaveTrackConstArray(selectionOnly, false);
Mixer *mixer = CreateMixer(waveTracks,
tracks->GetTimeTrack(),
t0, t1,
stereo? 2: 1, pcmBufferSize, true,
rate, int16Sample, true, mixerSpec);
int updateResult = eProgressSuccess;
{
auto mixer = CreateMixer(waveTracks,
tracks->GetTimeTrack(),
t0, t1,
stereo ? 2 : 1, pcmBufferSize, true,
rate, int16Sample, true, mixerSpec);
ProgressDialog progress(wxFileName(fName).GetName(),
selectionOnly ?
wxString::Format(_("Exporting selected audio at %ld kbps"), bitrate) :
@@ -294,8 +294,6 @@ int ExportMP2::Export(AudacityProject *project,
}
}
delete mixer;
int mp2BufferNumBytes = twolame_encode_flush(
encodeOptions,
mp2Buffer,