NOOP - use PBD's std::string to number functions

This commit is contained in:
Robin Gareus 2013-06-08 09:03:26 +02:00
parent fea8e860c6
commit ce0aa96838
7 changed files with 46 additions and 40 deletions

View file

@ -999,7 +999,7 @@ RouteTimeAxisView::resolve_new_group_playlist_name(std::string &basename, vector
tmp = tmp.substr(idx + group_string.length()); tmp = tmp.substr(idx + group_string.length());
// and find the largest current number // and find the largest current number
int x = atoi(tmp.c_str()); int x = atoi(tmp);
if (x > maxnumber) { if (x > maxnumber) {
maxnumber = x; maxnumber = x;
} }

View file

@ -949,7 +949,7 @@ SoundFileBrowser::freesound_search()
XMLNode *res = root->child("num_pages"); XMLNode *res = root->child("num_pages");
if (res) { if (res) {
string result = res->child("text")->content(); string result = res->child("text")->content();
freesound_n_pages = atoi(result.c_str()); freesound_n_pages = atoi(result);
} }
int more_pages = freesound_n_pages - freesound_page; int more_pages = freesound_n_pages - freesound_page;
@ -1010,7 +1010,7 @@ SoundFileBrowser::freesound_search()
std::string r; std::string r;
// cerr << "id=" << id << ",uri=" << uri << ",ofn=" << ofn << ",dur=" << dur << endl; // cerr << "id=" << id << ",uri=" << uri << ",ofn=" << ofn << ",dur=" << dur << endl;
double duration_seconds = atof(dur.c_str()); double duration_seconds = atof(dur);
double h, m, s; double h, m, s;
char duration_hhmmss[16]; char duration_hhmmss[16];
if (duration_seconds >= 99 * 60 * 60) { if (duration_seconds >= 99 * 60 * 60) {
@ -1023,7 +1023,7 @@ SoundFileBrowser::freesound_search()
); );
} }
double size_bytes = atof(siz.c_str()); double size_bytes = atof(siz);
char bsize[32]; char bsize[32];
if (size_bytes < 1000) { if (size_bytes < 1000) {
sprintf(bsize, "%.0f %s", size_bytes, _("B")); sprintf(bsize, "%.0f %s", size_bytes, _("B"));

View file

@ -23,7 +23,7 @@
#include <sys/types.h> #include <sys/types.h>
#include "pbd/error.h" #include "pbd/error.h"
#include "pbd/file_utils.h" #include "pbd/convert.h"
#include "pbd/file_utils.h" #include "pbd/file_utils.h"
#include "gui_thread.h" #include "gui_thread.h"
@ -32,6 +32,8 @@
#include "i18n.h" #include "i18n.h"
using namespace PBD;
TranscodeFfmpeg::TranscodeFfmpeg (std::string f) TranscodeFfmpeg::TranscodeFfmpeg (std::string f)
: infile(f) : infile(f)
{ {
@ -48,7 +50,7 @@ TranscodeFfmpeg::TranscodeFfmpeg (std::string f)
#endif #endif
std::string ff_file_path; std::string ff_file_path;
if (find_file_in_search_path (PBD::SearchPath(Glib::getenv("PATH")), X_("ffmpeg_harvid"), ff_file_path)) { ffmpeg_exe = ff_file_path; } if (find_file_in_search_path (SearchPath(Glib::getenv("PATH")), X_("ffmpeg_harvid"), ff_file_path)) { ffmpeg_exe = ff_file_path; }
else if (Glib::file_test(X_("C:\\Program Files\\harvid\\ffmpeg.exe"), Glib::FILE_TEST_EXISTS)) { else if (Glib::file_test(X_("C:\\Program Files\\harvid\\ffmpeg.exe"), Glib::FILE_TEST_EXISTS)) {
ffmpeg_exe = X_("C:\\Program Files\\ffmpeg\\ffmpeg.exe"); ffmpeg_exe = X_("C:\\Program Files\\ffmpeg\\ffmpeg.exe");
} }
@ -56,7 +58,7 @@ TranscodeFfmpeg::TranscodeFfmpeg (std::string f)
ffmpeg_exe = X_("C:\\Program Files\\ffmpeg\\ffmpeg.exe"); ffmpeg_exe = X_("C:\\Program Files\\ffmpeg\\ffmpeg.exe");
} }
if (find_file_in_search_path (PBD::SearchPath(Glib::getenv("PATH")), X_("ffprobe_harvid"), ff_file_path)) { ffprobe_exe = ff_file_path; } if (find_file_in_search_path (SearchPath(Glib::getenv("PATH")), X_("ffprobe_harvid"), ff_file_path)) { ffprobe_exe = ff_file_path; }
else if (Glib::file_test(X_("C:\\Program Files\\harvid\\ffprobe.exe"), Glib::FILE_TEST_EXISTS)) { else if (Glib::file_test(X_("C:\\Program Files\\harvid\\ffprobe.exe"), Glib::FILE_TEST_EXISTS)) {
ffprobe_exe = X_("C:\\Program Files\\ffmpeg\\ffprobe.exe"); ffprobe_exe = X_("C:\\Program Files\\ffmpeg\\ffprobe.exe");
} }
@ -65,7 +67,7 @@ TranscodeFfmpeg::TranscodeFfmpeg (std::string f)
} }
if (ffmpeg_exe.empty() || ffprobe_exe.empty()) { if (ffmpeg_exe.empty() || ffprobe_exe.empty()) {
PBD::warning << _( warning << _(
"No ffprobe or ffmpeg executables could be found on this system.\n" "No ffprobe or ffmpeg executables could be found on this system.\n"
"Video import and export is not possible until you install those tools.\n" "Video import and export is not possible until you install those tools.\n"
"Ardour requires ffmpeg and ffprobe from ffmpeg.org - version 1.1 or newer.\n" "Ardour requires ffmpeg and ffprobe from ffmpeg.org - version 1.1 or newer.\n"
@ -128,10 +130,10 @@ TranscodeFfmpeg::probe ()
#define PARSE_FRACTIONAL_FPS(VAR) \ #define PARSE_FRACTIONAL_FPS(VAR) \
{ \ { \
std::string::size_type pos; \ std::string::size_type pos; \
VAR = atof(value.c_str()); \ VAR = atof(value); \
pos = value.find_first_of('/'); \ pos = value.find_first_of('/'); \
if (pos != std::string::npos) { \ if (pos != std::string::npos) { \
VAR = atof(value.substr(0, pos).c_str()) / atof(value.substr(pos+1).c_str()); \ VAR = atof(value.substr(0, pos)) / atof(value.substr(pos+1)); \
} \ } \
} }
@ -149,11 +151,11 @@ TranscodeFfmpeg::probe ()
std::string value = kv->substr(kvsep + 1); std::string value = kv->substr(kvsep + 1);
if (key == X_("index")) { if (key == X_("index")) {
m_videoidx = atoi(value.c_str()); m_videoidx = atoi(value);
} else if (key == X_("width")) { } else if (key == X_("width")) {
m_width = atoi(value.c_str()); m_width = atoi(value);
} else if (key == X_("height")) { } else if (key == X_("height")) {
m_height = atoi(value.c_str()); m_height = atoi(value);
} else if (key == X_("codec_name")) { } else if (key == X_("codec_name")) {
if (!m_codec.empty()) m_codec += " "; if (!m_codec.empty()) m_codec += " ";
m_codec += value; m_codec += value;
@ -180,14 +182,14 @@ TranscodeFfmpeg::probe ()
)); ));
} }
} else if (key == X_("duration_ts") && m_fps == 0 && timebase !=0 ) { } else if (key == X_("duration_ts") && m_fps == 0 && timebase !=0 ) {
m_duration = atof(value.c_str()) * m_fps * timebase; m_duration = atof(value) * m_fps * timebase;
} else if (key == X_("duration") && m_fps != 0 && m_duration == 0) { } else if (key == X_("duration") && m_fps != 0 && m_duration == 0) {
m_duration = atof(value.c_str()) * m_fps; m_duration = atof(value) * m_fps;
} else if (key == X_("display_aspect_ratio")) { } else if (key == X_("display_aspect_ratio")) {
std::string::size_type pos; std::string::size_type pos;
pos = value.find_first_of(':'); pos = value.find_first_of(':');
if (pos != std::string::npos && atof(value.substr(pos+1).c_str()) != 0) { if (pos != std::string::npos && atof(value.substr(pos+1)) != 0) {
m_aspect = atof(value.substr(0, pos).c_str()) / atof(value.substr(pos+1).c_str()); m_aspect = atof(value.substr(0, pos)) / atof(value.substr(pos+1));
} }
} }
} }
@ -205,7 +207,7 @@ TranscodeFfmpeg::probe ()
std::string value = kv->substr(kvsep + 1); std::string value = kv->substr(kvsep + 1);
if (key == X_("channels")) { if (key == X_("channels")) {
as.channels = atoi(value.c_str()); as.channels = atoi(value);
} else if (key == X_("index")) { } else if (key == X_("index")) {
as.stream_id = value; as.stream_id = value;
} else if (key == X_("codec_long_name")) { } else if (key == X_("codec_long_name")) {
@ -542,7 +544,7 @@ void
TranscodeFfmpeg::ffmpegparse_v (std::string d, size_t /* s */) TranscodeFfmpeg::ffmpegparse_v (std::string d, size_t /* s */)
{ {
if (strstr(d.c_str(), "ERROR") || strstr(d.c_str(), "Error") || strstr(d.c_str(), "error")) { if (strstr(d.c_str(), "ERROR") || strstr(d.c_str(), "Error") || strstr(d.c_str(), "error")) {
PBD::warning << "ffmpeg-error: " << d << endmsg; warning << "ffmpeg-error: " << d << endmsg;
} }
if (strncmp(d.c_str(), "frame=",6)) { if (strncmp(d.c_str(), "frame=",6)) {
#if 1 /* DEBUG */ #if 1 /* DEBUG */
@ -554,7 +556,7 @@ TranscodeFfmpeg::ffmpegparse_v (std::string d, size_t /* s */)
Progress(0, 0); /* EMIT SIGNAL */ Progress(0, 0); /* EMIT SIGNAL */
return; return;
} }
ARDOUR::framecnt_t f = atol(d.substr(6).c_str()); ARDOUR::framecnt_t f = atol(d.substr(6));
if (f == 0) { if (f == 0) {
Progress(0, 0); /* EMIT SIGNAL */ Progress(0, 0); /* EMIT SIGNAL */
} else { } else {

View file

@ -388,7 +388,7 @@ TranscodeVideoDialog::launch_transcode ()
if (scale_combo.get_active_row_number() == 0 ) { if (scale_combo.get_active_row_number() == 0 ) {
scale_width =0; scale_width =0;
} else { } else {
scale_width = atoi(scale_combo.get_active_text().c_str()); scale_width = atoi(scale_combo.get_active_text());
} }
if (!aspect_checkbox.get_active()) { if (!aspect_checkbox.get_active()) {
scale_height = 0; scale_height = 0;
@ -443,7 +443,7 @@ TranscodeVideoDialog::scale_combo_changed ()
if (scale_combo.get_active_row_number() == 0 ) { if (scale_combo.get_active_row_number() == 0 ) {
h = transcoder->get_height(); h = transcoder->get_height();
} else { } else {
h = floor(atof(scale_combo.get_active_text().c_str()) / m_aspect); h = floor(atof(scale_combo.get_active_text()) / m_aspect);
} }
height_spinner.set_value(h); height_spinner.set_value(h);
} }
@ -477,7 +477,7 @@ TranscodeVideoDialog::update_bitrate ()
if (scale_combo.get_active_row_number() == 0 ) { if (scale_combo.get_active_row_number() == 0 ) {
br *= transcoder->get_width(); br *= transcoder->get_width();
} else { } else {
br *= atof(scale_combo.get_active_text().c_str()); br *= atof(scale_combo.get_active_text());
} }
if (br != 0) { if (br != 0) {
bitrate_spinner.set_value(floor(br/10000.0)*10); bitrate_spinner.set_value(floor(br/10000.0)*10);

View file

@ -18,6 +18,7 @@
*/ */
#include "pbd/file_utils.h" #include "pbd/file_utils.h"
#include "pbd/convert.h"
#include "gui_thread.h" #include "gui_thread.h"
#include "ardour_ui.h" #include "ardour_ui.h"
@ -28,6 +29,7 @@
#include "i18n.h" #include "i18n.h"
using namespace std; using namespace std;
using namespace PBD;
VideoMonitor::VideoMonitor (PublicEditor *ed, std::string xjadeo_bin_path) VideoMonitor::VideoMonitor (PublicEditor *ed, std::string xjadeo_bin_path)
: editor (ed) : editor (ed)
@ -248,7 +250,7 @@ VideoMonitor::parse_output (std::string d, size_t /*s*/)
printf("xjadeo: '%s'\n", line.c_str()); printf("xjadeo: '%s'\n", line.c_str());
} }
#endif #endif
int status = atoi(line.substr(1,3).c_str()); int status = atoi(line.substr(1,3));
switch(status / 100) { switch(status / 100) {
case 4: /* errors */ case 4: /* errors */
if (status == 403) { if (status == 403) {
@ -295,7 +297,7 @@ VideoMonitor::parse_output (std::string d, size_t /*s*/)
knownstate |= 2; knownstate |= 2;
if (starting || xjadeo_settings["window ontop"] != value) { if (starting || xjadeo_settings["window ontop"] != value) {
if (!starting && _session) _session->set_dirty (); if (!starting && _session) _session->set_dirty ();
if (atoi(value.c_str())) { UiState("xjadeo-window-ontop-on"); } if (atoi(value)) { UiState("xjadeo-window-ontop-on"); }
else { UiState("xjadeo-window-ontop-off"); } else { UiState("xjadeo-window-ontop-off"); }
starting &= ~2; starting &= ~2;
} }
@ -304,7 +306,7 @@ VideoMonitor::parse_output (std::string d, size_t /*s*/)
knownstate |= 4; knownstate |= 4;
if (starting || xjadeo_settings["window zoom"] != value) { if (starting || xjadeo_settings["window zoom"] != value) {
if (!starting && _session) _session->set_dirty (); if (!starting && _session) _session->set_dirty ();
if (atoi(value.c_str())) { UiState("xjadeo-window-fullscreen-on"); } if (atoi(value)) { UiState("xjadeo-window-fullscreen-on"); }
else { UiState("xjadeo-window-fullscreen-off"); } else { UiState("xjadeo-window-fullscreen-off"); }
starting &= ~4; starting &= ~4;
} }
@ -313,15 +315,15 @@ VideoMonitor::parse_output (std::string d, size_t /*s*/)
knownstate |= 8; knownstate |= 8;
if (starting || xjadeo_settings["window letterbox"] != value) { if (starting || xjadeo_settings["window letterbox"] != value) {
if (!starting && _session) _session->set_dirty (); if (!starting && _session) _session->set_dirty ();
if (atoi(value.c_str())) { UiState("xjadeo-window-letterbox-on"); } if (atoi(value)) { UiState("xjadeo-window-letterbox-on"); }
else { UiState("xjadeo-window-letterbox-off"); } else { UiState("xjadeo-window-letterbox-off"); }
starting &= ~8; starting &= ~8;
} }
xjadeo_settings["window letterbox"] = value; xjadeo_settings["window letterbox"] = value;
} else if(key == "osdmode") { } else if(key == "osdmode") {
knownstate |= 1; knownstate |= 1;
osdmode = atoi(value.c_str()); osdmode = atoi(value);
if (starting || atoi(xjadeo_settings["osd mode"].c_str()) != osdmode) { if (starting || atoi(xjadeo_settings["osd mode"]) != osdmode) {
if (!starting && _session) _session->set_dirty (); if (!starting && _session) _session->set_dirty ();
if ((osdmode & 1) == 1) { UiState("xjadeo-window-osd-frame-on"); } if ((osdmode & 1) == 1) { UiState("xjadeo-window-osd-frame-on"); }
if ((osdmode & 1) == 0) { UiState("xjadeo-window-osd-frame-off"); } if ((osdmode & 1) == 0) { UiState("xjadeo-window-osd-frame-off"); }

View file

@ -22,6 +22,7 @@
#include "ardour/tempo.h" #include "ardour/tempo.h"
#include "pbd/file_utils.h" #include "pbd/file_utils.h"
#include "pbd/convert.h"
#include "ardour/session_directory.h" #include "ardour/session_directory.h"
#include "ardour_ui.h" #include "ardour_ui.h"
@ -156,29 +157,29 @@ VideoTimeLine::set_session (ARDOUR::Session *s)
const XMLProperty* proph = node->property (X_("Height")); const XMLProperty* proph = node->property (X_("Height"));
if (proph) { if (proph) {
editor->set_video_timeline_height(atoi(proph->value().c_str())); editor->set_video_timeline_height(atoi(proph->value()));
} }
#if 0 /* TODO THINK: set FPS first time only ?! */ #if 0 /* TODO THINK: set FPS first time only ?! */
const XMLProperty* propasfps = node->property (X_("AutoFPS")); const XMLProperty* propasfps = node->property (X_("AutoFPS"));
if (propasfps) { if (propasfps) {
auto_set_session_fps = atoi(propasfps->value().c_str())?true:false; auto_set_session_fps = atoi(propasfps->value())?true:false;
} }
#endif #endif
const XMLProperty* propoffset = node->property (X_("VideoOffset")); const XMLProperty* propoffset = node->property (X_("VideoOffset"));
if (propoffset) { if (propoffset) {
video_offset = atoll(propoffset->value().c_str()); video_offset = atoll(propoffset->value());
video_offset_p = video_offset; video_offset_p = video_offset;
} }
const XMLProperty* proplock = node->property (X_("VideoOffsetLock")); const XMLProperty* proplock = node->property (X_("VideoOffsetLock"));
if (proplock) { if (proplock) {
video_offset_lock = atoi(proplock->value().c_str())?true:false; video_offset_lock = atoi(proplock->value())?true:false;
} }
const XMLProperty* localfile = node->property (X_("LocalFile")); const XMLProperty* localfile = node->property (X_("LocalFile"));
if (localfile) { if (localfile) {
local_file = atoi(localfile->value().c_str())?true:false; local_file = atoi(localfile->value())?true:false;
} }
const XMLProperty* propf = node->property (X_("Filename")); const XMLProperty* propf = node->property (X_("Filename"));
@ -226,7 +227,7 @@ VideoTimeLine::set_state (const XMLNode& node, int /*version*/)
LocaleGuard lg (X_("POSIX")); LocaleGuard lg (X_("POSIX"));
const XMLProperty* propoffset = node.property (X_("VideoOffset")); const XMLProperty* propoffset = node.property (X_("VideoOffset"));
if (propoffset) { if (propoffset) {
video_offset = atoll(propoffset->value().c_str()); video_offset = atoll(propoffset->value());
} }
ARDOUR_UI::instance()->flush_videotimeline_cache(true); ARDOUR_UI::instance()->flush_videotimeline_cache(true);
return 0; return 0;
@ -714,7 +715,7 @@ VideoTimeLine::open_video_monitor() {
if (node) { if (node) {
const XMLProperty* prop = node->property (X_("mask")); const XMLProperty* prop = node->property (X_("mask"));
if (prop) { if (prop) {
xj_settings_mask = atoi(prop->value().c_str()); xj_settings_mask = atoi(prop->value());
} }
} }
} }

View file

@ -34,6 +34,7 @@
using std::string; using std::string;
using namespace WM; using namespace WM;
using namespace PBD;
Manager* Manager::_instance = 0; Manager* Manager::_instance = 0;
@ -218,16 +219,16 @@ ProxyBase::set_state (const XMLNode& node)
} }
if ((prop = (*i)->property (X_("x-off"))) != 0) { if ((prop = (*i)->property (X_("x-off"))) != 0) {
_x_off = atoi (prop->value().c_str()); _x_off = atoi (prop->value());
} }
if ((prop = (*i)->property (X_("y-off"))) != 0) { if ((prop = (*i)->property (X_("y-off"))) != 0) {
_y_off = atoi (prop->value().c_str()); _y_off = atoi (prop->value());
} }
if ((prop = (*i)->property (X_("x-size"))) != 0) { if ((prop = (*i)->property (X_("x-size"))) != 0) {
_width = atoi (prop->value().c_str()); _width = atoi (prop->value());
} }
if ((prop = (*i)->property (X_("y-size"))) != 0) { if ((prop = (*i)->property (X_("y-size"))) != 0) {
_height = atoi (prop->value().c_str()); _height = atoi (prop->value());
} }
} }