summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2015-10-05 21:43:44 +0200
committerRobin Gareus <robin@gareus.org>2015-10-05 22:15:17 +0200
commit97bd6db2b7c52d636fca9dc340aeb3f6cef7de4d (patch)
treeaa1d81caf3c4bbb83c4c4f0d225f4c2a3db22433
parentb9c8814959eb184fff3e5552e2928a156b62602d (diff)
remove i/ofstream from libardour
except: * audio-unit (ifstream is known to work on OSX) * evoral curve algorithm debugger * cycle-timer debug code * export_handler's CDMarker -> TODO
-rw-r--r--libs/ardour/ardour/cycle_timer.h2
-rw-r--r--libs/ardour/audioanalyser.cc30
-rw-r--r--libs/ardour/automatable.cc18
-rw-r--r--libs/ardour/cycle_timer.cc3
-rw-r--r--libs/ardour/recent_sessions.cc8
-rw-r--r--libs/ardour/source.cc26
-rw-r--r--libs/backends/jack/jack_utils.cc10
-rw-r--r--libs/gtkmm2ext/cursors.cc14
-rw-r--r--libs/surfaces/osc/osc.cc11
9 files changed, 42 insertions, 80 deletions
diff --git a/libs/ardour/ardour/cycle_timer.h b/libs/ardour/ardour/cycle_timer.h
index ac19abda1e..54a2d1d8f2 100644
--- a/libs/ardour/ardour/cycle_timer.h
+++ b/libs/ardour/ardour/cycle_timer.h
@@ -70,7 +70,9 @@ public:
StoringTimer (int);
void ref ();
void check (int);
+#ifndef NDEBUG
void dump (std::string const &);
+#endif
private:
cycles_t _current_ref;
diff --git a/libs/ardour/audioanalyser.cc b/libs/ardour/audioanalyser.cc
index ac00a55ead..24aaa51437 100644
--- a/libs/ardour/audioanalyser.cc
+++ b/libs/ardour/audioanalyser.cc
@@ -102,7 +102,7 @@ AudioAnalyser::reset ()
int
AudioAnalyser::analyse (const string& path, Readable* src, uint32_t channel)
{
- ofstream ofile;
+ stringstream outss;
Plugin::FeatureSet features;
int ret = -1;
bool done = false;
@@ -110,20 +110,6 @@ AudioAnalyser::analyse (const string& path, Readable* src, uint32_t channel)
framecnt_t len = src->readable_length();
framepos_t pos = 0;
float* bufs[1] = { 0 };
- string tmp_path;
-
- if (!path.empty()) {
-
- /* store data in tmp file, not the real one */
-
- tmp_path = path;
- tmp_path += ".tmp";
-
- ofile.open (tmp_path.c_str());
- if (!ofile) {
- goto out;
- }
- }
data = new Sample[bufsize];
bufs[0] = data;
@@ -148,7 +134,7 @@ AudioAnalyser::analyse (const string& path, Readable* src, uint32_t channel)
features = plugin->process (bufs, RealTime::fromSeconds ((double) pos / sample_rate));
- if (use_features (features, (path.empty() ? 0 : &ofile))) {
+ if (use_features (features, (path.empty() ? 0 : &outss))) {
goto out;
}
@@ -163,21 +149,15 @@ AudioAnalyser::analyse (const string& path, Readable* src, uint32_t channel)
features = plugin->getRemainingFeatures ();
- if (use_features (features, (path.empty() ? &ofile : 0))) {
+ if (use_features (features, (path.empty() ? 0 : &outss))) {
goto out;
}
ret = 0;
out:
- /* works even if it has not been opened */
- ofile.close ();
-
- if (ret) {
- g_remove (tmp_path.c_str());
- } else if (!path.empty()) {
- /* move the data file to the requested path */
- g_rename (tmp_path.c_str(), path.c_str());
+ if (!ret) {
+ g_file_set_contents (path.c_str(), outss.str().c_str(), -1, NULL);
}
delete [] data;
diff --git a/libs/ardour/automatable.cc b/libs/ardour/automatable.cc
index a2ce81acca..b26052d59b 100644
--- a/libs/ardour/automatable.cc
+++ b/libs/ardour/automatable.cc
@@ -17,10 +17,10 @@
*/
-#include <fstream>
#include <cstdio>
#include <errno.h>
+#include <pbd/gstdio_compat.h>
#include <glibmm/miscutils.h>
#include "pbd/error.h"
@@ -98,7 +98,8 @@ Automatable::load_automation (const string& path)
fullpath = _a_session.automation_dir();
fullpath += path;
}
- ifstream in (fullpath.c_str());
+
+ FILE * in = g_fopen (fullpath.c_str (), "rb");
if (!in) {
warning << string_compose(_("cannot open %2 to load automation data (%3)")
@@ -110,14 +111,17 @@ Automatable::load_automation (const string& path)
set<Evoral::Parameter> tosave;
controls().clear ();
- while (in) {
+ while (!feof(in)) {
double when;
double value;
uint32_t port;
- in >> port; if (!in) break;
- in >> when; if (!in) goto bad;
- in >> value; if (!in) goto bad;
+ if (3 != fscanf (in, "%d %lf %lf", &port, &when, &value)) {
+ if (feof(in)) {
+ break;
+ }
+ goto bad;
+ }
Evoral::Parameter param(PluginAutomation, 0, port);
/* FIXME: this is legacy and only used for plugin inserts? I think? */
@@ -125,12 +129,14 @@ Automatable::load_automation (const string& path)
c->list()->add (when, value);
tosave.insert (param);
}
+ ::fclose (in);
return 0;
bad:
error << string_compose(_("cannot load automation data from %2"), fullpath) << endmsg;
controls().clear ();
+ ::fclose (in);
return -1;
}
diff --git a/libs/ardour/cycle_timer.cc b/libs/ardour/cycle_timer.cc
index ad91fa6874..a86124c555 100644
--- a/libs/ardour/cycle_timer.cc
+++ b/libs/ardour/cycle_timer.cc
@@ -86,7 +86,7 @@ StoringTimer::StoringTimer (int N)
_points = 0;
}
-
+#ifndef NDEBUG
void
StoringTimer::dump (string const & file)
{
@@ -98,6 +98,7 @@ StoringTimer::dump (string const & file)
f << _point[i] << " " << _ref[i] << " " << _value[i] << "\n";
}
}
+#endif
void
StoringTimer::ref ()
diff --git a/libs/ardour/recent_sessions.cc b/libs/ardour/recent_sessions.cc
index 22244c80ba..d08ebfec00 100644
--- a/libs/ardour/recent_sessions.cc
+++ b/libs/ardour/recent_sessions.cc
@@ -19,8 +19,6 @@
#include <cstring>
#include <cerrno>
-#include <fstream>
-#include <iostream>
#include <sstream>
#include <algorithm>
@@ -163,12 +161,6 @@ ARDOUR::write_recent_sessions (RecentSessions& rs)
{
stringstream recent;
- //ofstream recent (fout);
-
- // if (!recent) {
- // fclose (fout);
- // return -1;
- // }
for (RecentSessions::iterator i = rs.begin(); i != rs.end(); ++i) {
recent << (*i).first << '\n' << (*i).second << endl;
diff --git a/libs/ardour/source.cc b/libs/ardour/source.cc
index b9ea6ee78a..b3476ec8f4 100644
--- a/libs/ardour/source.cc
+++ b/libs/ardour/source.cc
@@ -25,8 +25,8 @@
#include <cmath>
#include <iomanip>
#include <algorithm>
-#include <fstream>
+#include <pbd/gstdio_compat.h>
#include <glibmm/threads.h>
#include <glibmm/miscutils.h>
#include <glibmm/fileutils.h>
@@ -187,27 +187,23 @@ Source::set_been_analysed (bool yn)
int
Source::load_transients (const string& path)
{
- ifstream file (path.c_str());
-
- if (!file) {
+ FILE *tf;
+ if (! (tf = g_fopen (path.c_str (), "rb"))) {
return -1;
}
transients.clear ();
-
- stringstream strstr;
- double val;
-
- while (file.good()) {
- file >> val;
-
- if (!file.fail()) {
- framepos_t frame = (framepos_t) floor (val * _session.frame_rate());
- transients.push_back (frame);
+ while (!feof (tf) && !ferror(tf)) {
+ double val;
+ if (1 != fscanf (tf, "%lf", &val)) {
+ break;
}
+
+ framepos_t frame = (framepos_t) floor (val * _session.frame_rate());
+ transients.push_back (frame);
}
- return 0;
+ ::fclose (tf);
}
string
diff --git a/libs/backends/jack/jack_utils.cc b/libs/backends/jack/jack_utils.cc
index 029b922f73..fa8a1aee14 100644
--- a/libs/backends/jack/jack_utils.cc
+++ b/libs/backends/jack/jack_utils.cc
@@ -38,10 +38,9 @@
#include <portaudio.h>
#endif
-#include <fstream>
-
#include <boost/scoped_ptr.hpp>
+#include "pbd/gstdio_compat.h"
#include <glibmm/miscutils.h>
#include "pbd/epa.h"
@@ -927,15 +926,10 @@ ARDOUR::get_jack_server_user_config_file_path ()
bool
ARDOUR::write_jack_config_file (const std::string& config_file_path, const string& command_line)
{
- ofstream jackdrc (config_file_path.c_str());
-
- if (!jackdrc) {
+ if (!g_file_set_contents (config_file_path.c_str(), command_line.c_str(), -1, NULL)) {
error << string_compose (_("cannot open JACK rc file %1 to store parameters"), config_file_path) << endmsg;
return false;
}
-
- jackdrc << command_line << endl;
- jackdrc.close ();
return true;
}
diff --git a/libs/gtkmm2ext/cursors.cc b/libs/gtkmm2ext/cursors.cc
index 9948fc667f..f8862835f6 100644
--- a/libs/gtkmm2ext/cursors.cc
+++ b/libs/gtkmm2ext/cursors.cc
@@ -18,8 +18,8 @@
*/
#include <sstream>
-#include <fstream>
+#include "pbd/gstdio_compat.h"
#include "pbd/error.h"
#include "pbd/compose.h"
@@ -41,13 +41,13 @@ CursorInfo::CursorInfo (const std::string& n, int hotspot_x, int hotspot_y)
int
CursorInfo::load_cursor_info (const std::string& path)
{
- std::ifstream infofile (path.c_str());
-
- if (!infofile) {
- return -1;
- }
+ gchar *buf = NULL;
+ if (!g_file_get_contents (path.c_str(), &buf, NULL, NULL)) {
+ return -1;
+ }
+ std::stringstream infofile (buf);
+ g_free (buf);
- std::stringstream s;
std::string name;
int x;
int y;
diff --git a/libs/surfaces/osc/osc.cc b/libs/surfaces/osc/osc.cc
index fade3b20b7..9c775121da 100644
--- a/libs/surfaces/osc/osc.cc
+++ b/libs/surfaces/osc/osc.cc
@@ -17,8 +17,6 @@
*
*/
-#include <iostream>
-#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <cerrno>
@@ -208,15 +206,8 @@ OSC::start ()
std::string url_file;
if (find_file (ardour_config_search_path(), "osc_url", url_file)) {
-
_osc_url_file = url_file;
- ofstream urlfile;
- urlfile.open(_osc_url_file.c_str(), ios::trunc);
-
- if (urlfile) {
- urlfile << get_server_url () << endl;
- urlfile.close();
- } else {
+ if (g_file_set_contents (_osc_url_file.c_str(), get_server_url().c_str(), -1, NULL)) {
cerr << "Couldn't write '" << _osc_url_file << "'" <<endl;
}
}