mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-08 07:45:00 +01:00
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
9 changed files with 42 additions and 80 deletions
|
|
@ -70,7 +70,9 @@ public:
|
||||||
StoringTimer (int);
|
StoringTimer (int);
|
||||||
void ref ();
|
void ref ();
|
||||||
void check (int);
|
void check (int);
|
||||||
|
#ifndef NDEBUG
|
||||||
void dump (std::string const &);
|
void dump (std::string const &);
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
cycles_t _current_ref;
|
cycles_t _current_ref;
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ AudioAnalyser::reset ()
|
||||||
int
|
int
|
||||||
AudioAnalyser::analyse (const string& path, Readable* src, uint32_t channel)
|
AudioAnalyser::analyse (const string& path, Readable* src, uint32_t channel)
|
||||||
{
|
{
|
||||||
ofstream ofile;
|
stringstream outss;
|
||||||
Plugin::FeatureSet features;
|
Plugin::FeatureSet features;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
bool done = false;
|
bool done = false;
|
||||||
|
|
@ -110,20 +110,6 @@ AudioAnalyser::analyse (const string& path, Readable* src, uint32_t channel)
|
||||||
framecnt_t len = src->readable_length();
|
framecnt_t len = src->readable_length();
|
||||||
framepos_t pos = 0;
|
framepos_t pos = 0;
|
||||||
float* bufs[1] = { 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];
|
data = new Sample[bufsize];
|
||||||
bufs[0] = data;
|
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));
|
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;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -163,21 +149,15 @@ AudioAnalyser::analyse (const string& path, Readable* src, uint32_t channel)
|
||||||
|
|
||||||
features = plugin->getRemainingFeatures ();
|
features = plugin->getRemainingFeatures ();
|
||||||
|
|
||||||
if (use_features (features, (path.empty() ? &ofile : 0))) {
|
if (use_features (features, (path.empty() ? 0 : &outss))) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
/* works even if it has not been opened */
|
if (!ret) {
|
||||||
ofile.close ();
|
g_file_set_contents (path.c_str(), outss.str().c_str(), -1, NULL);
|
||||||
|
|
||||||
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());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete [] data;
|
delete [] data;
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,10 @@
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <pbd/gstdio_compat.h>
|
||||||
#include <glibmm/miscutils.h>
|
#include <glibmm/miscutils.h>
|
||||||
|
|
||||||
#include "pbd/error.h"
|
#include "pbd/error.h"
|
||||||
|
|
@ -98,7 +98,8 @@ Automatable::load_automation (const string& path)
|
||||||
fullpath = _a_session.automation_dir();
|
fullpath = _a_session.automation_dir();
|
||||||
fullpath += path;
|
fullpath += path;
|
||||||
}
|
}
|
||||||
ifstream in (fullpath.c_str());
|
|
||||||
|
FILE * in = g_fopen (fullpath.c_str (), "rb");
|
||||||
|
|
||||||
if (!in) {
|
if (!in) {
|
||||||
warning << string_compose(_("cannot open %2 to load automation data (%3)")
|
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;
|
set<Evoral::Parameter> tosave;
|
||||||
controls().clear ();
|
controls().clear ();
|
||||||
|
|
||||||
while (in) {
|
while (!feof(in)) {
|
||||||
double when;
|
double when;
|
||||||
double value;
|
double value;
|
||||||
uint32_t port;
|
uint32_t port;
|
||||||
|
|
||||||
in >> port; if (!in) break;
|
if (3 != fscanf (in, "%d %lf %lf", &port, &when, &value)) {
|
||||||
in >> when; if (!in) goto bad;
|
if (feof(in)) {
|
||||||
in >> value; if (!in) goto bad;
|
break;
|
||||||
|
}
|
||||||
|
goto bad;
|
||||||
|
}
|
||||||
|
|
||||||
Evoral::Parameter param(PluginAutomation, 0, port);
|
Evoral::Parameter param(PluginAutomation, 0, port);
|
||||||
/* FIXME: this is legacy and only used for plugin inserts? I think? */
|
/* 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);
|
c->list()->add (when, value);
|
||||||
tosave.insert (param);
|
tosave.insert (param);
|
||||||
}
|
}
|
||||||
|
::fclose (in);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
bad:
|
bad:
|
||||||
error << string_compose(_("cannot load automation data from %2"), fullpath) << endmsg;
|
error << string_compose(_("cannot load automation data from %2"), fullpath) << endmsg;
|
||||||
controls().clear ();
|
controls().clear ();
|
||||||
|
::fclose (in);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ StoringTimer::StoringTimer (int N)
|
||||||
_points = 0;
|
_points = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
void
|
void
|
||||||
StoringTimer::dump (string const & file)
|
StoringTimer::dump (string const & file)
|
||||||
{
|
{
|
||||||
|
|
@ -98,6 +98,7 @@ StoringTimer::dump (string const & file)
|
||||||
f << _point[i] << " " << _ref[i] << " " << _value[i] << "\n";
|
f << _point[i] << " " << _ref[i] << " " << _value[i] << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
StoringTimer::ref ()
|
StoringTimer::ref ()
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,6 @@
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <fstream>
|
|
||||||
#include <iostream>
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
|
@ -163,12 +161,6 @@ ARDOUR::write_recent_sessions (RecentSessions& rs)
|
||||||
|
|
||||||
{
|
{
|
||||||
stringstream recent;
|
stringstream recent;
|
||||||
//ofstream recent (fout);
|
|
||||||
|
|
||||||
// if (!recent) {
|
|
||||||
// fclose (fout);
|
|
||||||
// return -1;
|
|
||||||
// }
|
|
||||||
|
|
||||||
for (RecentSessions::iterator i = rs.begin(); i != rs.end(); ++i) {
|
for (RecentSessions::iterator i = rs.begin(); i != rs.end(); ++i) {
|
||||||
recent << (*i).first << '\n' << (*i).second << endl;
|
recent << (*i).first << '\n' << (*i).second << endl;
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,8 @@
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
|
#include <pbd/gstdio_compat.h>
|
||||||
#include <glibmm/threads.h>
|
#include <glibmm/threads.h>
|
||||||
#include <glibmm/miscutils.h>
|
#include <glibmm/miscutils.h>
|
||||||
#include <glibmm/fileutils.h>
|
#include <glibmm/fileutils.h>
|
||||||
|
|
@ -187,27 +187,23 @@ Source::set_been_analysed (bool yn)
|
||||||
int
|
int
|
||||||
Source::load_transients (const string& path)
|
Source::load_transients (const string& path)
|
||||||
{
|
{
|
||||||
ifstream file (path.c_str());
|
FILE *tf;
|
||||||
|
if (! (tf = g_fopen (path.c_str (), "rb"))) {
|
||||||
if (!file) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
transients.clear ();
|
transients.clear ();
|
||||||
|
while (!feof (tf) && !ferror(tf)) {
|
||||||
stringstream strstr;
|
|
||||||
double val;
|
double val;
|
||||||
|
if (1 != fscanf (tf, "%lf", &val)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
while (file.good()) {
|
|
||||||
file >> val;
|
|
||||||
|
|
||||||
if (!file.fail()) {
|
|
||||||
framepos_t frame = (framepos_t) floor (val * _session.frame_rate());
|
framepos_t frame = (framepos_t) floor (val * _session.frame_rate());
|
||||||
transients.push_back (frame);
|
transients.push_back (frame);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
::fclose (tf);
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
|
|
|
||||||
|
|
@ -38,10 +38,9 @@
|
||||||
#include <portaudio.h>
|
#include <portaudio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
#include <boost/scoped_ptr.hpp>
|
#include <boost/scoped_ptr.hpp>
|
||||||
|
|
||||||
|
#include "pbd/gstdio_compat.h"
|
||||||
#include <glibmm/miscutils.h>
|
#include <glibmm/miscutils.h>
|
||||||
|
|
||||||
#include "pbd/epa.h"
|
#include "pbd/epa.h"
|
||||||
|
|
@ -927,15 +926,10 @@ ARDOUR::get_jack_server_user_config_file_path ()
|
||||||
bool
|
bool
|
||||||
ARDOUR::write_jack_config_file (const std::string& config_file_path, const string& command_line)
|
ARDOUR::write_jack_config_file (const std::string& config_file_path, const string& command_line)
|
||||||
{
|
{
|
||||||
ofstream jackdrc (config_file_path.c_str());
|
if (!g_file_set_contents (config_file_path.c_str(), command_line.c_str(), -1, NULL)) {
|
||||||
|
|
||||||
if (!jackdrc) {
|
|
||||||
error << string_compose (_("cannot open JACK rc file %1 to store parameters"), config_file_path) << endmsg;
|
error << string_compose (_("cannot open JACK rc file %1 to store parameters"), config_file_path) << endmsg;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
jackdrc << command_line << endl;
|
|
||||||
jackdrc.close ();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
|
#include "pbd/gstdio_compat.h"
|
||||||
#include "pbd/error.h"
|
#include "pbd/error.h"
|
||||||
#include "pbd/compose.h"
|
#include "pbd/compose.h"
|
||||||
|
|
||||||
|
|
@ -41,13 +41,13 @@ CursorInfo::CursorInfo (const std::string& n, int hotspot_x, int hotspot_y)
|
||||||
int
|
int
|
||||||
CursorInfo::load_cursor_info (const std::string& path)
|
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)) {
|
||||||
if (!infofile) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
std::stringstream infofile (buf);
|
||||||
|
g_free (buf);
|
||||||
|
|
||||||
std::stringstream s;
|
|
||||||
std::string name;
|
std::string name;
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <fstream>
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
|
|
@ -208,15 +206,8 @@ OSC::start ()
|
||||||
std::string url_file;
|
std::string url_file;
|
||||||
|
|
||||||
if (find_file (ardour_config_search_path(), "osc_url", url_file)) {
|
if (find_file (ardour_config_search_path(), "osc_url", url_file)) {
|
||||||
|
|
||||||
_osc_url_file = url_file;
|
_osc_url_file = url_file;
|
||||||
ofstream urlfile;
|
if (g_file_set_contents (_osc_url_file.c_str(), get_server_url().c_str(), -1, NULL)) {
|
||||||
urlfile.open(_osc_url_file.c_str(), ios::trunc);
|
|
||||||
|
|
||||||
if (urlfile) {
|
|
||||||
urlfile << get_server_url () << endl;
|
|
||||||
urlfile.close();
|
|
||||||
} else {
|
|
||||||
cerr << "Couldn't write '" << _osc_url_file << "'" <<endl;
|
cerr << "Couldn't write '" << _osc_url_file << "'" <<endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue