StoringTimer (int);
void ref ();
void check (int);
+#ifndef NDEBUG
void dump (std::string const &);
+#endif
private:
cycles_t _current_ref;
int
AudioAnalyser::analyse (const string& path, Readable* src, uint32_t channel)
{
- ofstream ofile;
+ stringstream outss;
Plugin::FeatureSet features;
int ret = -1;
bool done = false;
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;
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;
}
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;
*/
-#include <fstream>
#include <cstdio>
#include <errno.h>
+#include <pbd/gstdio_compat.h>
#include <glibmm/miscutils.h>
#include "pbd/error.h"
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)")
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? */
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;
}
_points = 0;
}
-
+#ifndef NDEBUG
void
StoringTimer::dump (string const & file)
{
f << _point[i] << " " << _ref[i] << " " << _value[i] << "\n";
}
}
+#endif
void
StoringTimer::ref ()
#include <cstring>
#include <cerrno>
-#include <fstream>
-#include <iostream>
#include <sstream>
#include <algorithm>
{
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;
#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>
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
#include <portaudio.h>
#endif
-#include <fstream>
-
#include <boost/scoped_ptr.hpp>
+#include "pbd/gstdio_compat.h"
#include <glibmm/miscutils.h>
#include "pbd/epa.h"
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;
}
*/
#include <sstream>
-#include <fstream>
+#include "pbd/gstdio_compat.h"
#include "pbd/error.h"
#include "pbd/compose.h"
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;
*
*/
-#include <iostream>
-#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <cerrno>
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;
}
}