[Scummvm-cvs-logs] SF.net SVN: scummvm:[48611] tools
criezy at users.sourceforge.net
criezy at users.sourceforge.net
Sat Apr 10 22:39:41 CEST 2010
Revision: 48611
http://scummvm.svn.sourceforge.net/scummvm/?rev=48611&view=rev
Author: criezy
Date: 2010-04-10 20:39:41 +0000 (Sat, 10 Apr 2010)
Log Message:
-----------
Backport fix to bug #2905473: GUI Tools: cannot use lame
A lame path option has been added when using MP3 compression. For CLI it can be set using -lame-path. In the GUI it can be set in the advanced MP3 options page. There is also a check on lame in the GUI tools now.
Modified Paths:
--------------
tools/branches/branch-1-1-0/NEWS
tools/branches/branch-1-1-0/compress.cpp
tools/branches/branch-1-1-0/compress.h
tools/branches/branch-1-1-0/gui/configuration.cpp
tools/branches/branch-1-1-0/gui/configuration.h
tools/branches/branch-1-1-0/gui/gui_tools.cpp
tools/branches/branch-1-1-0/gui/pages.cpp
tools/trunk/NEWS
Modified: tools/branches/branch-1-1-0/NEWS
===================================================================
--- tools/branches/branch-1-1-0/NEWS 2010-04-10 20:37:06 UTC (rev 48610)
+++ tools/branches/branch-1-1-0/NEWS 2010-04-10 20:39:41 UTC (rev 48611)
@@ -4,6 +4,7 @@
1.1.1 (????-??-??)
First tools version to contain a NEWS file.
+ - Fix bug #2905473: "GUI Tools: cannot use lame with compress_scumm_sou"
- Patch #2982306: "set MP3 ABR bit rate in GUI Tools"
- Patch #2982090: "Tools: include unistd.h for unlink"
- Patch #2982091: "Tools: use $(INSTALL) instead of install".
\ No newline at end of file
Modified: tools/branches/branch-1-1-0/compress.cpp
===================================================================
--- tools/branches/branch-1-1-0/compress.cpp 2010-04-10 20:37:06 UTC (rev 48610)
+++ tools/branches/branch-1-1-0/compress.cpp 2010-04-10 20:39:41 UTC (rev 48611)
@@ -49,6 +49,7 @@
uint32 algqual;
uint32 vbrqual;
bool silent;
+ std::string lamePath;
};
struct oggencparams {
@@ -71,7 +72,7 @@
uint8 bitsPerSample;
};
-lameparams encparms = { minBitrDef, maxBitrDef, false, algqualDef, vbrqualDef, 0 };
+lameparams encparms = { minBitrDef, maxBitrDef, false, algqualDef, vbrqualDef, 0, "lame" };
oggencparams oggparms = { -1, -1, -1, (float)oggqualDef, 0 };
flaccparams flacparms = { flacCompressDef, flacBlocksizeDef, false, false };
rawtype rawAudioType = { false, false, 8 };
@@ -124,7 +125,7 @@
char *tmp = fbuf;
if (compmode == AUDIO_MP3) {
- tmp += sprintf(tmp, "lame -t ");
+ tmp += sprintf(tmp, "%s -t ", encparms.lamePath.c_str());
if (rawInput) {
tmp += sprintf(tmp, "-r ");
tmp += sprintf(tmp, "--bitwidth %d ", rawAudioType.bitsPerSample);
@@ -774,6 +775,10 @@
}
// mp3 settings
+void CompressionTool::setMp3LamePath(const std::string& arg) {
+ encparms.lamePath = arg;
+}
+
void CompressionTool::setMp3CompressionType(const std::string& arg) {
encparms.abr = (arg == "ABR");
}
@@ -899,6 +904,11 @@
encparms.abr = 0;
} else if (arg == "--abr") {
encparms.abr = 1;
+ } else if (arg == "-lame-path") {
+ if (_arguments.empty())
+ throw ToolException("Could not parse command line options, expected value after -lame-path");
+ setMp3LamePath(_arguments.front());
+ _arguments.pop_front();
} else if (arg == "-b") {
if (_arguments.empty())
@@ -1103,6 +1113,7 @@
if (_supportedFormats & AUDIO_MP3) {
os << "\nMP3 mode params:\n";
+ os << " -lame-path <path> Path to the lame excutable to use (default: lame)\n";
os << " -b <rate> <rate> is the target bitrate(ABR)/minimal bitrate(VBR) (default:" << minBitrDef << "%d)\n";
os << " -B <rate> <rate> is the maximum VBR/ABR bitrate (default:%" << maxBitrDef << ")\n";
os << " --vbr LAME uses the VBR mode (default)\n";
Modified: tools/branches/branch-1-1-0/compress.h
===================================================================
--- tools/branches/branch-1-1-0/compress.h 2010-04-10 20:37:06 UTC (rev 48610)
+++ tools/branches/branch-1-1-0/compress.h 2010-04-10 20:39:41 UTC (rev 48611)
@@ -89,6 +89,7 @@
// Settings
// These functions are used by the GUI Tools and by CLI argument parsing functions
// mp3 settings
+ void setMp3LamePath(const std::string&);
void setMp3CompressionType(const std::string&);
void setMp3MpegQuality(const std::string&);
void setMp3ABRBitrate(const std::string&);
Modified: tools/branches/branch-1-1-0/gui/configuration.cpp
===================================================================
--- tools/branches/branch-1-1-0/gui/configuration.cpp 2010-04-10 20:37:06 UTC (rev 48610)
+++ tools/branches/branch-1-1-0/gui/configuration.cpp 2010-04-10 20:39:41 UTC (rev 48611)
@@ -21,6 +21,7 @@
*/
#include <wx/config.h>
+#include <wx/utils.h>
#include "gui/configuration.h"
@@ -37,6 +38,7 @@
advancedAudioSettings = false;
// mp3 params
+ mp3LamePath = wxT("lame");
mp3CompressionType = wxT("VBR");
mp3MpegQuality = wxT("2");
@@ -67,6 +69,7 @@
filecnf->Read(wxT("outputpath"), &outputPath);
// mp3 params
+ filecnf->Read(wxT("mp3LamePath"), &mp3LamePath, mp3LamePath);
filecnf->Read(wxT("mp3CompressionType"), &mp3CompressionType, mp3CompressionType);
filecnf->Read(wxT("mp3MpegQuality"), &mp3MpegQuality, mp3MpegQuality);
filecnf->Read(wxT("mp3ABRBitrate"), &mp3ABRBitrate, mp3ABRBitrate);
@@ -92,6 +95,7 @@
wxFileName op(outputPath);
filecnf->Write(wxT("outputpath"), op.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR));
+ filecnf->Write(wxT("mp3LamePath"), mp3LamePath);
if (all) {
// mp3 params
@@ -139,3 +143,10 @@
if (selectedPlatform == wxT("Nintendo DS") || selectedPlatform == wxT("Dreamcast"))
selectedAudioFormat = AUDIO_MP3;
}
+
+bool Configuration::isLamePathValid(const wxString& mp3LamePath) {
+ wxString cmd = mp3LamePath + wxT(" --license");
+ int retval = wxExecute(cmd, wxEXEC_SYNC);
+ return retval == 0;
+}
+
Modified: tools/branches/branch-1-1-0/gui/configuration.h
===================================================================
--- tools/branches/branch-1-1-0/gui/configuration.h 2010-04-10 20:37:06 UTC (rev 48610)
+++ tools/branches/branch-1-1-0/gui/configuration.h 2010-04-10 20:39:41 UTC (rev 48611)
@@ -58,6 +58,13 @@
* Sets all the compression members to default values based on the 'selectedPlatform' member
*/
void setPlatformDefaults();
+
+ /**
+ * Utility functions that test the given lame path.
+ *
+ * @return false indicate that the given lame path does not point to a valid lame executable.
+ */
+ static bool isLamePathValid(const wxString& mp3LamePath);
// While prepending with _ would be in line with the coding conventions
// this class is just a glorified map with different types, so it seems
@@ -84,6 +91,7 @@
bool advancedAudioSettings;
// mp3 settings
+ wxString mp3LamePath;
wxString mp3CompressionType;
wxString mp3MpegQuality;
wxString mp3ABRBitrate;
Modified: tools/branches/branch-1-1-0/gui/gui_tools.cpp
===================================================================
--- tools/branches/branch-1-1-0/gui/gui_tools.cpp 2010-04-10 20:37:06 UTC (rev 48610)
+++ tools/branches/branch-1-1-0/gui/gui_tools.cpp 2010-04-10 20:39:41 UTC (rev 48611)
@@ -146,6 +146,7 @@
compression->_format = conf.selectedAudioFormat;
// mp3
+ compression->setMp3LamePath ( (const char *)conf.mp3LamePath.mb_str() );
compression->setMp3CompressionType( (const char *)conf.mp3CompressionType.mb_str() );
compression->setMp3MpegQuality ( (const char *)conf.mp3MpegQuality.mb_str() );
if (conf.mp3CompressionType == wxT("ABR"))
Modified: tools/branches/branch-1-1-0/gui/pages.cpp
===================================================================
--- tools/branches/branch-1-1-0/gui/pages.cpp 2010-04-10 20:37:06 UTC (rev 48610)
+++ tools/branches/branch-1-1-0/gui/pages.cpp 2010-04-10 20:39:41 UTC (rev 48611)
@@ -33,6 +33,8 @@
#include <wx/filepicker.h>
#include <wx/file.h>
#include <wx/process.h>
+#include <wx/msgdlg.h>
+#include <wx/scrolwin.h>
#include "main.h"
#include "pages.h"
@@ -820,6 +822,29 @@
else if (format->GetStringSelection() == wxT("MP3"))
switchPage(new ChooseAudioOptionsMp3Page(_configuration));
} else {
+
+ // For MP3 we check if the lame path is valid otherwise we let the choice
+ // tp the user to either change the audio format or to go to the MP3
+ // options page (to set the lame path).
+ if (
+ format->GetStringSelection() == wxT("MP3") &&
+ !Configuration::isLamePathValid(_configuration.mp3LamePath)
+ ) {
+ wxMessageDialog *msgDialog = new wxMessageDialog(
+ NULL,
+ wxT("The lame executable could not be found. It is needed to compress files to MP3. "
+ "You can either proceed to the advanced audio settings page and give the path to lame "
+ "or you can select another audio format to compress to.\n\n"
+ "Do you want to proceed to the advanced audio settings page?"),
+ wxT("lame not found"),
+ wxYES_NO | wxNO_DEFAULT | wxICON_EXCLAMATION
+ );
+ int retval = msgDialog->ShowModal();
+ if (retval == wxID_YES)
+ switchPage(new ChooseAudioOptionsMp3Page(_configuration));
+ return;
+ }
+
switchPage(new ProcessPage(_configuration));
}
}
@@ -833,10 +858,20 @@
wxWindow *ChooseAudioOptionsMp3Page::CreatePanel(wxWindow *parent) {
wxWindow *panel = WizardPage::CreatePanel(parent);
+
+ wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
+
+ // Add a ScrolledWindow in that panel as there is a lot of options
+ // and there might not be enough place to display them all.
+ wxScrolledWindow *scroll = new wxScrolledWindow(panel);
+ scroll->FitInside();
+ scroll->SetScrollRate(10, 10);
+
+ sizer->Add(scroll, 1, wxEXPAND | wxALL);
-
/*
"\nMP3 mode params:\n"
+ " -lame-path <path> Path to the lame excutable to use (default: lame)\n"
" -b <rate> <rate> is the target bitrate(ABR)/minimal bitrate(VBR) (default:" minBitrDef_str "%d)\n"
" -B <rate> <rate> is the maximum VBR/ABR bitrate (default:%" maxBitrDef_str ")\n"
" --vbr LAME uses the VBR mode (default)\n"
@@ -846,24 +881,37 @@
" --silent the output of LAME is hidden (default:disabled)\n"
*/
- wxFlexGridSizer *sizer = new wxFlexGridSizer(6, 2, 10, 25);
- sizer->AddGrowableCol(1);
+ // Grid
+ wxFlexGridSizer *gridSizer = new wxFlexGridSizer(7, 2, 10, 25);
+ gridSizer->AddGrowableCol(1);
+ // Create output selection
+ gridSizer->Add(new wxStaticText(scroll, wxID_ANY, wxT("Lame executable:")));
+ wxFilePickerCtrl *lamePicker = new wxFilePickerCtrl(
+ scroll, wxID_ANY, _configuration.outputPath, wxT("Select lame executable"),
+ wxT("lame"),
+ wxDefaultPosition, wxSize(250, -1),
+ wxFLP_USE_TEXTCTRL | wxFLP_OPEN, wxDefaultValidator,
+ wxT("LamePath")
+ );
+
+ gridSizer->Add(lamePicker, wxSizerFlags().Expand());
+
// Type of compression
- sizer->Add(new wxStaticText(panel, wxID_ANY, wxT("Compression Type:")));
+ gridSizer->Add(new wxStaticText(scroll, wxID_ANY, wxT("Compression Type:")));
- wxRadioButton *abrButton = new wxRadioButton(panel, wxID_ANY, wxT("ABR"),
+ wxRadioButton *abrButton = new wxRadioButton(scroll, wxID_ANY, wxT("ABR"),
wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxT("ABR"));
wxSizer *radioSizer = new wxBoxSizer(wxHORIZONTAL);
radioSizer->Add(abrButton);
- wxRadioButton *vbrButton = new wxRadioButton(panel, wxID_ANY, wxT("VBR"),
+ wxRadioButton *vbrButton = new wxRadioButton(scroll, wxID_ANY, wxT("VBR"),
wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxT("VBR"));
radioSizer->Add(vbrButton);
- sizer->Add(radioSizer, wxSizerFlags().Expand());
+ gridSizer->Add(radioSizer, wxSizerFlags().Expand());
// Bitrates
const int possibleBitrateCount = 160 / 8;
@@ -872,28 +920,28 @@
possibleBitrates[i] << (i+1)*8;
}
- sizer->Add(new wxStaticText(panel, wxID_ANY, wxT("Minimum Bitrate:")));
+ gridSizer->Add(new wxStaticText(scroll, wxID_ANY, wxT("Minimum Bitrate:")));
wxChoice *vbrMinBitrate = new wxChoice(
- panel, wxID_ANY, wxDefaultPosition, wxDefaultSize,
+ scroll, wxID_ANY, wxDefaultPosition, wxDefaultSize,
possibleBitrateCount, possibleBitrates, 0, wxDefaultValidator, wxT("MinimumBitrate"));
- sizer->Add(vbrMinBitrate, wxSizerFlags().Expand().Border(wxRIGHT, 100));
+ gridSizer->Add(vbrMinBitrate, wxSizerFlags().Expand().Border(wxRIGHT, 100));
- sizer->Add(new wxStaticText(panel, wxID_ANY, wxT("Maximum Bitrate:")));
+ gridSizer->Add(new wxStaticText(scroll, wxID_ANY, wxT("Maximum Bitrate:")));
wxChoice *vbrMaxBitrate = new wxChoice(
- panel, wxID_ANY, wxDefaultPosition, wxDefaultSize,
+ scroll, wxID_ANY, wxDefaultPosition, wxDefaultSize,
possibleBitrateCount, possibleBitrates, 0, wxDefaultValidator, wxT("MaximumBitrate"));
- sizer->Add(vbrMaxBitrate, wxSizerFlags().Expand().Border(wxRIGHT, 100));
+ gridSizer->Add(vbrMaxBitrate, wxSizerFlags().Expand().Border(wxRIGHT, 100));
- sizer->Add(new wxStaticText(panel, wxID_ANY, wxT("Average Bitrate:")));
+ gridSizer->Add(new wxStaticText(scroll, wxID_ANY, wxT("Average Bitrate:")));
wxChoice *abrAvgBitrate = new wxChoice(
- panel, wxID_ANY, wxDefaultPosition, wxDefaultSize,
+ scroll, wxID_ANY, wxDefaultPosition, wxDefaultSize,
possibleBitrateCount, possibleBitrates, 0, wxDefaultValidator, wxT("AverageBitrate"));
- sizer->Add(abrAvgBitrate, wxSizerFlags().Expand().Border(wxRIGHT, 100));
+ gridSizer->Add(abrAvgBitrate, wxSizerFlags().Expand().Border(wxRIGHT, 100));
abrButton->Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler(ChooseAudioOptionsMp3Page::onChangeCompressionType), NULL, this);
vbrButton->Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler(ChooseAudioOptionsMp3Page::onChangeCompressionType), NULL, this);
@@ -905,26 +953,28 @@
possibleQualities[i] << i;
}
- sizer->Add(new wxStaticText(panel, wxID_ANY, wxT("VBR Quality:")));
+ gridSizer->Add(new wxStaticText(scroll, wxID_ANY, wxT("VBR Quality:")));
wxChoice *vbrQuality = new wxChoice(
- panel, wxID_ANY, wxDefaultPosition, wxDefaultSize,
+ scroll, wxID_ANY, wxDefaultPosition, wxDefaultSize,
possibleQualityCount, possibleQualities, 0, wxDefaultValidator, wxT("VBRQuality"));
- sizer->Add(vbrQuality, wxSizerFlags().Expand().Border(wxRIGHT, 100));
+ gridSizer->Add(vbrQuality, wxSizerFlags().Expand().Border(wxRIGHT, 100));
- sizer->Add(new wxStaticText(panel, wxID_ANY, wxT("MPEG Quality:")));
+ gridSizer->Add(new wxStaticText(scroll, wxID_ANY, wxT("MPEG Quality:")));
wxChoice *mpegQuality = new wxChoice(
- panel, wxID_ANY, wxDefaultPosition, wxDefaultSize,
+ scroll, wxID_ANY, wxDefaultPosition, wxDefaultSize,
possibleQualityCount, possibleQualities, 0, wxDefaultValidator, wxT("MpegQuality"));
- sizer->Add(mpegQuality, wxSizerFlags().Expand().Border(wxRIGHT, 100));
+ gridSizer->Add(mpegQuality, wxSizerFlags().Expand().Border(wxRIGHT, 100));
// Finish the window
+ scroll->SetSizer(gridSizer);
SetAlignedSizer(panel, sizer);
// Load settings
+ lamePicker->SetPath(_configuration.mp3LamePath);
if (_configuration.mp3CompressionType == wxT("ABR"))
abrButton->SetValue(true);
else
@@ -941,6 +991,8 @@
}
void ChooseAudioOptionsMp3Page::save(wxWindow *panel) {
+ wxFilePickerCtrl *lamePath = static_cast<wxFilePickerCtrl *>(panel->FindWindowByName(wxT("LamePath")));
+
wxRadioButton *abr = static_cast<wxRadioButton *>(panel->FindWindowByName(wxT("ABR")));
// wxRadioButton *vbr = static_cast<wxRadioButton *>(panel->FindWindowByName(wxT("VBR")));
@@ -950,6 +1002,7 @@
wxChoice *vbrQuality = static_cast<wxChoice *>(panel->FindWindowByName(wxT("VBRQuality")));
wxChoice *mpegQuality = static_cast<wxChoice *>(panel->FindWindowByName(wxT("MpegQuality")));
+ _configuration.mp3LamePath = lamePath->GetPath();
_configuration.mp3VBRMinBitrate = vbrMinBitrate->GetStringSelection();
_configuration.mp3VBRMaxBitrate = vbrMaxBitrate->GetStringSelection();
_configuration.mp3ABRBitrate = abrAvgBitrate->GetStringSelection();
@@ -984,6 +1037,23 @@
}
void ChooseAudioOptionsMp3Page::onNext(wxWindow *panel) {
+ // Check if the lame path is valid.
+ // The configuration is updated when calling switchPage() and therefore
+ // is not yet up to date. So we get the path from the wxFilePickerCtrl
+ wxFilePickerCtrl *lamePath = static_cast<wxFilePickerCtrl *>(panel->FindWindowByName(wxT("LamePath")));
+ if (!Configuration::isLamePathValid(lamePath->GetPath())) {
+ wxMessageDialog *msgDialog = new wxMessageDialog(
+ NULL,
+ wxT("The lame executable could not be found. It is needed to compress files to MP3. "
+ "If you want to use MP3 compression you need to select a valid lame executable. "
+ "Otherwise you can go back to the audio format selection and select another format."),
+ wxT("lame not found"),
+ wxOK | wxICON_EXCLAMATION
+ );
+ msgDialog->ShowModal();
+ return;
+ }
+
switchPage(new ProcessPage(_configuration));
}
Modified: tools/trunk/NEWS
===================================================================
--- tools/trunk/NEWS 2010-04-10 20:37:06 UTC (rev 48610)
+++ tools/trunk/NEWS 2010-04-10 20:39:41 UTC (rev 48611)
@@ -9,6 +9,7 @@
1.1.1 (????-??-??)
First tools version to contain a NEWS file.
+ - Fix bug #2905473: "GUI Tools: cannot use lame with compress_scumm_sou"
- Patch #2982306: "set MP3 ABR bit rate in GUI Tools"
- Patch #2982090: "Tools: include unistd.h for unlink"
- Patch #2982091: "Tools: use $(INSTALL) instead of install".
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list