1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-13 14:13:32 +02:00

Remove needless uses of wxString::c_str() in wxString::Format...

... and similar wx "variadics," which all treat wxString smartly enough that
you don't need this.

Don't need c_str either to convert wxString to const wxChar * because
wxString has a conversion operator that does the same.
This commit is contained in:
Paul Licameli
2017-10-09 01:03:14 -04:00
parent 0efbf6a190
commit 7fd78183d2
76 changed files with 500 additions and 504 deletions

View File

@@ -352,7 +352,7 @@ bool Importer::Import(const wxString &fName,
#ifdef USE_MIDI
// MIDI files must be imported, not opened
if (IsMidi(fName)) {
errorMessage.Printf(_("\"%s\" \nis a MIDI file, not an audio file. \nAudacity cannot open this type of file for playing, but you can\nedit it by clicking File > Import > MIDI."), fName.c_str());
errorMessage.Printf(_("\"%s\" \nis a MIDI file, not an audio file. \nAudacity cannot open this type of file for playing, but you can\nedit it by clicking File > Import > MIDI."), fName);
return false;
}
#endif
@@ -376,7 +376,7 @@ bool Importer::Import(const wxString &fName,
bool usersSelectionOverrides;
gPrefs->Read(wxT("/ExtendedImport/OverrideExtendedImportByOpenFileDialogChoice"), &usersSelectionOverrides, false);
wxLogDebug(wxT("LastOpenType is %s"),type.c_str());
wxLogDebug(wxT("LastOpenType is %s"),type);
wxLogDebug(wxT("OverrideExtendedImportByOpenFileDialogChoice is %i"),usersSelectionOverrides);
if (usersSelectionOverrides)
@@ -386,14 +386,14 @@ bool Importer::Import(const wxString &fName,
if (plugin->GetPluginFormatDescription().CompareTo(type) == 0)
{
// This plugin corresponds to user-selected filter, try it first.
wxLogDebug(wxT("Inserting %s"),plugin->GetPluginStringID().c_str());
wxLogDebug(wxT("Inserting %s"),plugin->GetPluginStringID());
importPlugins.insert(importPlugins.begin(), plugin.get());
}
}
}
wxLogMessage(wxT("File name is %s"),(const char *) fName.c_str());
wxLogMessage(wxT("Mime type is %s"),(const char *) mime_type.Lower().c_str());
wxLogMessage(wxT("File name is %s"), fName);
wxLogMessage(wxT("Mime type is %s"), mime_type.Lower());
for (const auto &uItem : mExtImportItems)
{
@@ -402,7 +402,7 @@ bool Importer::Import(const wxString &fName,
wxLogDebug(wxT("Testing extensions"));
for (size_t j = 0; j < item->extensions.Count(); j++)
{
wxLogDebug(wxT("%s"), (const char *) item->extensions[j].Lower().c_str());
wxLogDebug(wxT("%s"), item->extensions[j].Lower());
if (wxMatchWild (item->extensions[j].Lower(),fName.Lower(), false))
{
wxLogDebug(wxT("Match!"));
@@ -443,7 +443,7 @@ bool Importer::Import(const wxString &fName,
// is still ffmpeg in prefs from previous --with-ffmpeg builds
if (!(item->filter_objects[j]))
continue;
wxLogDebug(wxT("Inserting %s"),item->filter_objects[j]->GetPluginStringID().c_str());
wxLogDebug(wxT("Inserting %s"),item->filter_objects[j]->GetPluginStringID());
importPlugins.push_back(item->filter_objects[j]);
}
}
@@ -482,11 +482,11 @@ bool Importer::Import(const wxString &fName,
if (importPlugins.end() ==
std::find(importPlugins.begin(), importPlugins.end(), libsndfilePlugin))
{
wxLogDebug(wxT("Appending %s"),libsndfilePlugin->GetPluginStringID().c_str());
wxLogDebug(wxT("Appending %s"),libsndfilePlugin->GetPluginStringID());
importPlugins.push_back(libsndfilePlugin);
}
}
wxLogDebug(wxT("Appending %s"),plugin->GetPluginStringID().c_str());
wxLogDebug(wxT("Appending %s"),plugin->GetPluginStringID());
importPlugins.push_back(plugin.get());
}
}
@@ -504,7 +504,7 @@ bool Importer::Import(const wxString &fName,
if (importPlugins.end() ==
std::find(importPlugins.begin(), importPlugins.end(), plugin.get()))
{
wxLogDebug(wxT("Appending %s"),plugin->GetPluginStringID().c_str());
wxLogDebug(wxT("Appending %s"),plugin->GetPluginStringID());
importPlugins.push_back(plugin.get());
}
}
@@ -514,11 +514,11 @@ bool Importer::Import(const wxString &fName,
for (const auto plugin : importPlugins)
{
// Try to open the file with this plugin (probe it)
wxLogMessage(wxT("Opening with %s"),plugin->GetPluginStringID().c_str());
wxLogMessage(wxT("Opening with %s"),plugin->GetPluginStringID());
auto inFile = plugin->Open(fName);
if ( (inFile != NULL) && (inFile->GetStreamCount() > 0) )
{
wxLogMessage(wxT("Open(%s) succeeded"),(const char *) fName.c_str());
wxLogMessage(wxT("Open(%s) succeeded"), fName);
// File has more than one stream - display stream selector
if (inFile->GetStreamCount() > 1)
{
@@ -572,7 +572,7 @@ bool Importer::Import(const wxString &fName,
{
errorMessage.Printf(_("This version of Audacity was not compiled with %s support."),
unusableImportPlugin->
GetPluginFormatDescription().c_str());
GetPluginFormatDescription());
return false;
}
}
@@ -584,80 +584,80 @@ bool Importer::Import(const wxString &fName,
// if someone has sent us a .cda file, send them away
if (extension.IsSameAs(wxT("cda"), false)) {
/* i18n-hint: %s will be the filename */
errorMessage.Printf(_("\"%s\" is an audio CD track. \nAudacity cannot open audio CDs directly. \nExtract (rip) the CD tracks to an audio format that \nAudacity can import, such as WAV or AIFF."), fName.c_str());
errorMessage.Printf(_("\"%s\" is an audio CD track. \nAudacity cannot open audio CDs directly. \nExtract (rip) the CD tracks to an audio format that \nAudacity can import, such as WAV or AIFF."), fName);
return false;
}
// playlist type files
if ((extension.IsSameAs(wxT("m3u"), false))||(extension.IsSameAs(wxT("ram"), false))||(extension.IsSameAs(wxT("pls"), false))) {
errorMessage.Printf(_("\"%s\" is a playlist file. \nAudacity cannot open this file because it only contains links to other files. \nYou may be able to open it in a text editor and download the actual audio files."), fName.c_str());
errorMessage.Printf(_("\"%s\" is a playlist file. \nAudacity cannot open this file because it only contains links to other files. \nYou may be able to open it in a text editor and download the actual audio files."), fName);
return false;
}
//WMA files of various forms
if ((extension.IsSameAs(wxT("wma"), false))||(extension.IsSameAs(wxT("asf"), false))) {
errorMessage.Printf(_("\"%s\" is a Windows Media Audio file. \nAudacity cannot open this type of file due to patent restrictions. \nYou need to convert it to a supported audio format, such as WAV or AIFF."), fName.c_str());
errorMessage.Printf(_("\"%s\" is a Windows Media Audio file. \nAudacity cannot open this type of file due to patent restrictions. \nYou need to convert it to a supported audio format, such as WAV or AIFF."), fName);
return false;
}
//AAC files of various forms (probably not encrypted)
if ((extension.IsSameAs(wxT("aac"), false))||(extension.IsSameAs(wxT("m4a"), false))||(extension.IsSameAs(wxT("m4r"), false))||(extension.IsSameAs(wxT("mp4"), false))) {
errorMessage.Printf(_("\"%s\" is an Advanced Audio Coding file. \nAudacity cannot open this type of file. \nYou need to convert it to a supported audio format, such as WAV or AIFF."), fName.c_str());
errorMessage.Printf(_("\"%s\" is an Advanced Audio Coding file. \nAudacity cannot open this type of file. \nYou need to convert it to a supported audio format, such as WAV or AIFF."), fName);
return false;
}
// encrypted itunes files
if ((extension.IsSameAs(wxT("m4p"), false))) {
errorMessage.Printf(_("\"%s\" is an encrypted audio file. \nThese typically are from an online music store. \nAudacity cannot open this type of file due to the encryption. \nTry recording the file into Audacity, or burn it to audio CD then \nextract the CD track to a supported audio format such as WAV or AIFF."), fName.c_str());
errorMessage.Printf(_("\"%s\" is an encrypted audio file. \nThese typically are from an online music store. \nAudacity cannot open this type of file due to the encryption. \nTry recording the file into Audacity, or burn it to audio CD then \nextract the CD track to a supported audio format such as WAV or AIFF."), fName);
return false;
}
// Real Inc. files of various sorts
if ((extension.IsSameAs(wxT("ra"), false))||(extension.IsSameAs(wxT("rm"), false))||(extension.IsSameAs(wxT("rpm"), false))) {
errorMessage.Printf(_("\"%s\" is a RealPlayer media file. \nAudacity cannot open this proprietary format. \nYou need to convert it to a supported audio format, such as WAV or AIFF."), fName.c_str());
errorMessage.Printf(_("\"%s\" is a RealPlayer media file. \nAudacity cannot open this proprietary format. \nYou need to convert it to a supported audio format, such as WAV or AIFF."), fName);
return false;
}
// Other notes-based formats
if ((extension.IsSameAs(wxT("kar"), false))||(extension.IsSameAs(wxT("mod"), false))||(extension.IsSameAs(wxT("rmi"), false))) {
errorMessage.Printf(_("\"%s\" is a notes-based file, not an audio file. \nAudacity cannot open this type of file. \nTry converting it to an audio file such as WAV or AIFF and \nthen import it, or record it into Audacity."), fName.c_str());
errorMessage.Printf(_("\"%s\" is a notes-based file, not an audio file. \nAudacity cannot open this type of file. \nTry converting it to an audio file such as WAV or AIFF and \nthen import it, or record it into Audacity."), fName);
return false;
}
// MusePack files
if ((extension.IsSameAs(wxT("mp+"), false))||(extension.IsSameAs(wxT("mpc"), false))||(extension.IsSameAs(wxT("mpp"), false))) {
errorMessage.Printf(_("\"%s\" is a Musepack audio file. \nAudacity cannot open this type of file. \nIf you think it might be an mp3 file, rename it to end with \".mp3\" \nand try importing it again. Otherwise you need to convert it to a supported audio \nformat, such as WAV or AIFF."), fName.c_str());
errorMessage.Printf(_("\"%s\" is a Musepack audio file. \nAudacity cannot open this type of file. \nIf you think it might be an mp3 file, rename it to end with \".mp3\" \nand try importing it again. Otherwise you need to convert it to a supported audio \nformat, such as WAV or AIFF."), fName);
return false;
}
// WavPack files
if ((extension.IsSameAs(wxT("wv"), false))||(extension.IsSameAs(wxT("wvc"), false))) {
errorMessage.Printf(_("\"%s\" is a Wavpack audio file. \nAudacity cannot open this type of file. \nYou need to convert it to a supported audio format, such as WAV or AIFF."), fName.c_str());
errorMessage.Printf(_("\"%s\" is a Wavpack audio file. \nAudacity cannot open this type of file. \nYou need to convert it to a supported audio format, such as WAV or AIFF."), fName);
return false;
}
// AC3 files
if ((extension.IsSameAs(wxT("ac3"), false))) {
errorMessage.Printf(_("\"%s\" is a Dolby Digital audio file. \nAudacity cannot currently open this type of file. \nYou need to convert it to a supported audio format, such as WAV or AIFF."), fName.c_str());
errorMessage.Printf(_("\"%s\" is a Dolby Digital audio file. \nAudacity cannot currently open this type of file. \nYou need to convert it to a supported audio format, such as WAV or AIFF."), fName);
return false;
}
// Speex files
if ((extension.IsSameAs(wxT("spx"), false))) {
errorMessage.Printf(_("\"%s\" is an Ogg Speex audio file. \nAudacity cannot currently open this type of file. \nYou need to convert it to a supported audio format, such as WAV or AIFF."), fName.c_str());
errorMessage.Printf(_("\"%s\" is an Ogg Speex audio file. \nAudacity cannot currently open this type of file. \nYou need to convert it to a supported audio format, such as WAV or AIFF."), fName);
return false;
}
// Video files of various forms
if ((extension.IsSameAs(wxT("mpg"), false))||(extension.IsSameAs(wxT("mpeg"), false))||(extension.IsSameAs(wxT("avi"), false))||(extension.IsSameAs(wxT("wmv"), false))||(extension.IsSameAs(wxT("rv"), false))) {
errorMessage.Printf(_("\"%s\" is a video file. \nAudacity cannot currently open this type of file. \nYou need to extract the audio to a supported format, such as WAV or AIFF."), fName.c_str());
errorMessage.Printf(_("\"%s\" is a video file. \nAudacity cannot currently open this type of file. \nYou need to extract the audio to a supported format, such as WAV or AIFF."), fName);
return false;
}
// Audacity project
if (extension.IsSameAs(wxT("aup"), false)) {
errorMessage.Printf(_("\"%s\" is an Audacity Project file. \nUse the 'File > Open' command to open Audacity Projects."), fName.c_str());
errorMessage.Printf(_("\"%s\" is an Audacity Project file. \nUse the 'File > Open' command to open Audacity Projects."), fName);
return false;
}
// we were not able to recognize the file type
errorMessage.Printf(_("Audacity did not recognize the type of the file '%s'.\nTry installing FFmpeg. For uncompressed files, also try File > Import > Raw Data."),fName.c_str());
errorMessage.Printf(_("Audacity did not recognize the type of the file '%s'.\nTry installing FFmpeg. For uncompressed files, also try File > Import > Raw Data."),fName);
}
else
{
@@ -672,7 +672,7 @@ bool Importer::Import(const wxString &fName,
pluglist = pluglist + wxT(", ") + plugin->GetPluginFormatDescription();
}
errorMessage.Printf(_("Audacity recognized the type of the file '%s'.\nImporters supposedly supporting such files are:\n%s,\nbut none of them understood this file format."),fName.c_str(), pluglist.c_str());
errorMessage.Printf(_("Audacity recognized the type of the file '%s'.\nImporters supposedly supporting such files are:\n%s,\nbut none of them understood this file format."),fName, pluglist);
}
return false;

View File

@@ -365,7 +365,7 @@ bool FFmpegImportFileHandle::Init()
err = ufile_fopen_input(tempContext, mName);
if (err < 0)
{
wxLogError(wxT("FFmpeg : av_open_input_file() failed for file %s"), mName.c_str());
wxLogError(wxT("FFmpeg : av_open_input_file() failed for file %s"), mName);
return false;
}
wxASSERT(tempContext.get());
@@ -374,7 +374,7 @@ bool FFmpegImportFileHandle::Init()
err = avformat_find_stream_info(mFormatContext, NULL);
if (err < 0)
{
wxLogError(wxT("FFmpeg: avformat_find_stream_info() failed for file %s"),mName.c_str());
wxLogError(wxT("FFmpeg: avformat_find_stream_info() failed for file %s"),mName);
return false;
}
@@ -444,7 +444,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);
strinfo.Printf(_("Index[%02x] Codec[%s], Language[%s], Bitrate[%s], Channels[%d], Duration[%d]"),sc->m_stream->id,codec->name,lang,bitrate,sc->m_stream->codec->channels, duration);
mStreamInfo.Add(strinfo);
mScs->get()[mNumStreams++] = std::move(sc);
}

View File

@@ -286,7 +286,7 @@ GetGStreamerImportPlugin(ImportPluginList &importPluginList,
{
wxLogMessage(wxT("Failed to initialize GStreamer. Error %d: %s"),
error.get()->code,
wxString::FromUTF8(error.get()->message).c_str());
wxString::FromUTF8(error.get()->message));
return;
}
@@ -389,7 +389,7 @@ GStreamerImportPlugin::GetSupportedExtensions()
for (guint i = 0; extensions[i] != NULL; i++)
{
wxString extension = wxString::FromUTF8(extensions[i]);
if (mExtensions.Index(extension.c_str(), false) == wxNOT_FOUND)
if (mExtensions.Index(extension, false) == wxNOT_FOUND)
{
mExtensions.Add(extension);
}
@@ -407,7 +407,7 @@ GStreamerImportPlugin::GetSupportedExtensions()
{
extensions = extensions + wxT(" ") + mExtensions[i];
}
wxLogMessage(wxT("%s"), extensions.c_str());
wxLogMessage(wxT("%s"), extensions);
return mExtensions;
}
@@ -996,7 +996,7 @@ GStreamerImportFileHandle::Init()
wxString strinfo;
strinfo.Printf(wxT("Index[%02d], Type[%s], Channels[%d], Rate[%d]"),
(unsigned int) i,
wxString::FromUTF8(c->mType.get()).c_str(),
wxString::FromUTF8(c->mType.get()),
(int) c->mNumChannels,
(int) c->mSampleRate);
mStreamInfo.Add(strinfo);
@@ -1210,9 +1210,9 @@ GStreamerImportFileHandle::ProcessBusMessage(bool & success)
}
wxLogMessage(wxT("GStreamer: Got %s%s%s"),
wxString::FromUTF8(GST_MESSAGE_TYPE_NAME(msg.get())).c_str(),
wxString::FromUTF8(GST_MESSAGE_TYPE_NAME(msg.get())),
objname ? wxT(" from ") : wxT(""),
objname ? wxString::FromUTF8(objname.get()).c_str() : wxT(""));
objname ? wxString::FromUTF8(objname.get()) : wxT(""));
}
#endif
@@ -1231,13 +1231,13 @@ GStreamerImportFileHandle::ProcessBusMessage(bool & success)
wxString m;
m.Printf(wxT("%s%s%s"),
wxString::FromUTF8(err.get()->message).c_str(),
wxString::FromUTF8(err.get()->message),
debug ? wxT("\n") : wxT(""),
debug ? wxString::FromUTF8(debug.get()).c_str() : wxT(""));
debug ? wxString::FromUTF8(debug.get()) : wxT(""));
#if defined(_DEBUG)
AudacityMessageBox(wxString::Format(_("GStreamer Error: %s"), m));
#else
wxLogMessage(wxT("GStreamer Error: %s"), m.c_str());
wxLogMessage(wxT("GStreamer Error: %s"), m);
#endif
}
@@ -1256,9 +1256,9 @@ GStreamerImportFileHandle::ProcessBusMessage(bool & success)
if (err)
{
wxLogMessage(wxT("GStreamer Warning: %s%s%s"),
wxString::FromUTF8(err.get()->message).c_str(),
wxString::FromUTF8(err.get()->message),
debug ? wxT("\n") : wxT(""),
debug ? wxString::FromUTF8(debug.get()).c_str() : wxT(""));
debug ? wxString::FromUTF8(debug.get()) : wxT(""));
}
}
break;
@@ -1273,9 +1273,9 @@ GStreamerImportFileHandle::ProcessBusMessage(bool & success)
if (err)
{
wxLogMessage(wxT("GStreamer Info: %s%s%s"),
wxString::FromUTF8(err.get()->message).c_str(),
wxString::FromUTF8(err.get()->message),
debug ? wxT("\n") : wxT(""),
debug ? wxString::FromUTF8(debug.get()).c_str() : wxT(""));
debug ? wxString::FromUTF8(debug.get()) : wxT(""));
}
}
break;
@@ -1375,18 +1375,18 @@ GStreamerImportFileHandle::OnTag(GstAppSink * WXUNUSED(appsink), GstTagList *tag
{
GstDateTime *dt = (GstDateTime *) g_value_get_boxed(val);
GstString str{ gst_date_time_to_iso8601_string(dt) };
string = wxString::FromUTF8(str.get()).c_str();
string = wxString::FromUTF8(str.get());
}
else if (G_VALUE_HOLDS(val, G_TYPE_DATE))
{
GstString str{ gst_value_serialize(val) };
string = wxString::FromUTF8(str.get()).c_str();
string = wxString::FromUTF8(str.get());
}
else
{
wxLogMessage(wxT("Tag %s has unhandled type: %s"),
wxString::FromUTF8(name).c_str(),
wxString::FromUTF8(G_VALUE_TYPE_NAME(val)).c_str());
wxString::FromUTF8(name),
wxString::FromUTF8(G_VALUE_TYPE_NAME(val)));
continue;
}
@@ -1422,12 +1422,12 @@ GStreamerImportFileHandle::OnTag(GstAppSink * WXUNUSED(appsink), GstTagList *tag
}
else
{
tag = wxString::FromUTF8(name).c_str();
tag = wxString::FromUTF8(name);
}
if (jcnt > 1)
{
tag.Printf(wxT("%s:%d"), tag.c_str(), j);
tag.Printf(wxT("%s:%d"), tag, j);
}
// Store the tag

View File

@@ -325,7 +325,7 @@ ProgressResult OggImportFileHandle::Import(TrackFactory *trackFactory, TrackHold
if (bytesRead == OV_HOLE) {
wxFileName ff(mFilename);
wxLogError(wxT("Ogg Vorbis importer: file %s is malformed, ov_read() reported a hole"),
ff.GetFullName().c_str());
ff.GetFullName());
/* http://lists.xiph.org/pipermail/vorbis-dev/2001-February/003223.html
* is the justification for doing this - best effort for malformed file,
* hence the message.

View File

@@ -137,7 +137,7 @@ public:
wxFileName ff(mFilename);
wxString title;
title.Printf(_("Importing %s"), GetFileDescription().c_str());
title.Printf(_("Importing %s"), GetFileDescription());
mProgress.create(title, ff.GetFullName());
}

View File

@@ -238,7 +238,7 @@ void ImportRaw(wxWindow *parent, const wxString &fileName,
wxString msg;
msg.Printf(_("Importing %s"), wxFileName::FileName(fileName).GetFullName().c_str());
msg.Printf(_("Importing %s"), wxFileName::FileName(fileName).GetFullName());
/* i18n-hint: 'Raw' means 'unprocessed' here and should usually be tanslated.*/
ProgressDialog progress(_("Import Raw"), msg);