1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-20 22:30:05 +02:00

Fix: bug 2054

Windows: Macros - "ExportMP3 before" and "ExportMP3 after" overwrite
causing non-critical data loss.

Thanks to Mike Barker for locating the problem.

This fix also corrects the bit-rate for the ExportMP3_56k commands.
This commit is contained in:
Steve Daulton 2019-01-21 10:21:03 +00:00
parent 226851ab91
commit b3dafcedd1
3 changed files with 17 additions and 5 deletions

View File

@ -575,9 +575,12 @@ bool MacroCommands::WriteMp3File( const wxString & Name, int bitrate )
bool rc; bool rc;
long prevBitRate = gPrefs->Read(wxT("/FileFormats/MP3Bitrate"), 128); long prevBitRate = gPrefs->Read(wxT("/FileFormats/MP3Bitrate"), 128);
gPrefs->Write(wxT("/FileFormats/MP3Bitrate"), bitrate); gPrefs->Write(wxT("/FileFormats/MP3Bitrate"), bitrate);
int prevMode = gPrefs->Read(wxT("/FileFormats/MP3RateMode"), MODE_CBR);
gPrefs->Write(wxT("/FileFormats/MP3RateMode"), MODE_CBR);
auto cleanup = finally( [&] { auto cleanup = finally( [&] {
gPrefs->Write(wxT("/FileFormats/MP3Bitrate"), prevBitRate); gPrefs->Write(wxT("/FileFormats/MP3Bitrate"), prevBitRate);
gPrefs->Write(wxT("/FileFormats/MP3RateMode"), prevMode);
gPrefs->Flush(); gPrefs->Flush();
} ); } );
@ -643,10 +646,18 @@ bool MacroCommands::ApplySpecialCommand(
// historically this was in use, now ignored if there // historically this was in use, now ignored if there
return true; return true;
} else if (command == wxT("ExportMP3_56k_before")) { } else if (command == wxT("ExportMP3_56k_before")) {
#if defined(__WXMSW__)
filename.Replace(wxT("cleaned\\"), wxT("cleaned\\MasterBefore_"), false);
#else
filename.Replace(wxT("cleaned/"), wxT("cleaned/MasterBefore_"), false); filename.Replace(wxT("cleaned/"), wxT("cleaned/MasterBefore_"), false);
#endif
return WriteMp3File(filename, 56); return WriteMp3File(filename, 56);
} else if (command == wxT("ExportMP3_56k_after")) { } else if (command == wxT("ExportMP3_56k_after")) {
#if defined(__WXMSW__)
filename.Replace(wxT("cleaned\\"), wxT("cleaned\\MasterAfter_"), false);
#else
filename.Replace(wxT("cleaned/"), wxT("cleaned/MasterAfter_"), false); filename.Replace(wxT("cleaned/"), wxT("cleaned/MasterAfter_"), false);
#endif
return WriteMp3File(filename, 56); return WriteMp3File(filename, 56);
} else if (command == wxT("ExportMP3")) { } else if (command == wxT("ExportMP3")) {
return WriteMp3File(filename, 0); // 0 bitrate means use default/current return WriteMp3File(filename, 0); // 0 bitrate means use default/current

View File

@ -105,11 +105,6 @@
// ExportMP3Options // ExportMP3Options
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
#define MODE_SET 0
#define MODE_VBR 1
#define MODE_ABR 2
#define MODE_CBR 3
#define CHANNEL_JOINT 0 #define CHANNEL_JOINT 0
#define CHANNEL_STEREO 1 #define CHANNEL_STEREO 1
#define CHANNEL_MONO 2 #define CHANNEL_MONO 2

View File

@ -14,6 +14,12 @@
/* --------------------------------------------------------------------------*/ /* --------------------------------------------------------------------------*/
#include "../MemoryX.h" #include "../MemoryX.h"
#define MODE_SET 0
#define MODE_VBR 1
#define MODE_ABR 2
#define MODE_CBR 3
class ExportPlugin; class ExportPlugin;
class wxString; class wxString;
class wxWindow; class wxWindow;