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
This commit is contained in:
parent
b9c8814959
commit
97bd6db2b7
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 ()
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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());
|
||||
gchar *buf = NULL;
|
||||
if (!g_file_get_contents (path.c_str(), &buf, NULL, NULL)) {
|
||||
return -1;
|
||||
}
|
||||
std::stringstream infofile (buf);
|
||||
g_free (buf);
|
||||
|
||||
if (!infofile) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::stringstream s;
|
||||
std::string name;
|
||||
int x;
|
||||
int y;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user