ExternalSource refactoring.
git-svn-id: svn://localhost/trunk/ardour2@373 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
0896e2e63f
commit
1e668dfaf2
|
@ -409,7 +409,7 @@ if conf.CheckCHeader('alsa/asoundlib.h'):
|
|||
subst_dict['%MIDITYPE%'] = "alsa/sequencer"
|
||||
elif conf.CheckCHeader('/System/Library/Frameworks/CoreMIDI.framework/Headers/CoreMIDI.h'):
|
||||
# this line is needed because scons can't handle -framework in ParseConfig() yet.
|
||||
libraries['sysmidi'] = LibraryInfo (LINKFLAGS= '-framework CoreMIDI -framework CoreFoundation -framework CoreAudio -framework CoreServices -framework AudioUnit -bind_at_load')
|
||||
libraries['sysmidi'] = LibraryInfo (LINKFLAGS= '-framework CoreMIDI -framework CoreFoundation -framework CoreAudio -framework CoreServices -framework AudioUnit -framework AudioToolbox -bind_at_load')
|
||||
env['SYSMIDI'] = 'CoreMIDI'
|
||||
subst_dict['%MIDITAG%'] = "ardour"
|
||||
subst_dict['%MIDITYPE%'] = "coremidi"
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
#include <ardour/tempo.h>
|
||||
#include <ardour/location.h>
|
||||
#include <ardour/region.h>
|
||||
#include <ardour/sndfile_helpers.h>
|
||||
#include <ardour/externalsource.h>
|
||||
|
||||
#include "audio_clock.h"
|
||||
#include "gtk-custom-ruler.h"
|
||||
|
@ -954,7 +954,7 @@ class Editor : public PublicEditor
|
|||
|
||||
void insert_sndfile (bool as_tracks);
|
||||
void embed_audio (); // inserts into region list
|
||||
int reject_because_rate_differs (const string & path, SoundFileInfo& finfo, const string & action, bool multiple_pending);
|
||||
int reject_because_rate_differs (const string & path, ARDOUR::SoundFileInfo& finfo, const string & action, bool multiple_pending);
|
||||
|
||||
void do_embed_sndfiles (vector<string> paths, bool split);
|
||||
void embed_sndfile (string path, bool split, bool multiple_files, bool& check_sr);
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#include <ardour/audioregion.h>
|
||||
#include <ardour/diskstream.h>
|
||||
#include <ardour/filesource.h>
|
||||
#include <ardour/sndfilesource.h>
|
||||
#include <ardour/externalsource.h>
|
||||
#include <ardour/utils.h>
|
||||
#include <ardour/location.h>
|
||||
#include <ardour/named_selection.h>
|
||||
|
@ -2179,7 +2179,7 @@ Editor::do_embed_sndfiles (vector<string> paths, bool split)
|
|||
void
|
||||
Editor::embed_sndfile (string path, bool split, bool multiple_files, bool& check_sample_rate)
|
||||
{
|
||||
SndFileSource *source = 0; /* keep g++ quiet */
|
||||
ExternalSource *source = 0; /* keep g++ quiet */
|
||||
AudioRegion::SourceList sources;
|
||||
string idspec;
|
||||
string linked_path;
|
||||
|
@ -2202,8 +2202,9 @@ Editor::embed_sndfile (string path, bool split, bool multiple_files, bool& check
|
|||
}
|
||||
|
||||
/* note that we temporarily truncated _id at the colon */
|
||||
if (!get_soundfile_info (path, finfo)) {
|
||||
error << string_compose(_("Editor: cannot open file \"%1\""), selection ) << endmsg;
|
||||
string error_msg;
|
||||
if (!ExternalSource::get_soundfile_info (path, finfo, error_msg)) {
|
||||
error << string_compose(_("Editor: cannot open file \"%1\", (%2)"), selection, error_msg ) << endmsg;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2234,7 +2235,7 @@ Editor::embed_sndfile (string path, bool split, bool multiple_files, bool& check
|
|||
idspec += string_compose(":%1", n);
|
||||
|
||||
try {
|
||||
source = new SndFileSource (idspec.c_str());
|
||||
source = ExternalSource::create (idspec.c_str());
|
||||
sources.push_back(source);
|
||||
}
|
||||
|
||||
|
@ -2312,14 +2313,14 @@ Editor::insert_paths_as_new_tracks (vector<string> paths, bool split)
|
|||
SoundFileInfo finfo;
|
||||
bool multiple_files;
|
||||
bool check_sample_rate = true;
|
||||
string error_msg;
|
||||
|
||||
multiple_files = paths.size() > 1;
|
||||
|
||||
for (vector<string>::iterator p = paths.begin(); p != paths.end(); ++p) {
|
||||
|
||||
if (!get_soundfile_info((*p), finfo)) {
|
||||
char errbuf[256];
|
||||
error << string_compose(_("Editor: cannot open file \"%1\""), (*p)) << endmsg;
|
||||
if (!ExternalSource::get_soundfile_info((*p), finfo, error_msg)) {
|
||||
error << string_compose(_("Editor: cannot open file \"%1\" (%2)"), (*p), error_msg) << endmsg;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -2379,16 +2380,16 @@ Editor::do_insert_sndfile (vector<string> paths, bool split, jack_nframes_t pos)
|
|||
void
|
||||
Editor::insert_sndfile_into (const string & path, bool multi, AudioTimeAxisView* tv, jack_nframes_t& pos, bool prompt)
|
||||
{
|
||||
SndFileSource *source = 0; /* keep g++ quiet */
|
||||
ExternalSource *source = 0; /* keep g++ quiet */
|
||||
AudioRegion::SourceList sources;
|
||||
string idspec;
|
||||
SoundFileInfo finfo;
|
||||
string error_msg;
|
||||
|
||||
/* note that we temporarily truncated _id at the colon */
|
||||
|
||||
if (!get_soundfile_info (path, finfo)) {
|
||||
char errbuf[256];
|
||||
error << string_compose(_("Editor: cannot open file \"%1\" (%2)"), path) << endmsg;
|
||||
if (!ExternalSource::get_soundfile_info (path, finfo, error_msg)) {
|
||||
error << string_compose(_("Editor: cannot open file \"%1\" (%2)"), path, error_msg) << endmsg;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2407,7 +2408,7 @@ Editor::insert_sndfile_into (const string & path, bool multi, AudioTimeAxisView*
|
|||
idspec += string_compose(":%1", n);
|
||||
|
||||
try {
|
||||
source = new SndFileSource (idspec.c_str());
|
||||
source = ExternalSource::create (idspec.c_str());
|
||||
sources.push_back(source);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
#include <ardour/playlist.h>
|
||||
#include <ardour/audioregion.h>
|
||||
#include <ardour/sndfilesource.h>
|
||||
#include <ardour/diskstream.h>
|
||||
|
||||
#include "streamview.h"
|
||||
|
|
|
@ -29,8 +29,7 @@
|
|||
|
||||
#include <ardour/audio_library.h>
|
||||
#include <ardour/audioregion.h>
|
||||
#include <ardour/sndfile_helpers.h>
|
||||
#include <ardour/sndfilesource.h>
|
||||
#include <ardour/externalsource.h>
|
||||
|
||||
#include "gui_thread.h"
|
||||
#include "prompter.h"
|
||||
|
@ -119,7 +118,8 @@ SoundFileBox::setup_labels (string filename)
|
|||
{
|
||||
path = filename;
|
||||
|
||||
if(!get_soundfile_info (filename, sf_info)) {
|
||||
string error_msg;
|
||||
if(!ExternalSource::get_soundfile_info (filename, sf_info, error_msg)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -184,11 +184,11 @@ SoundFileBox::play_btn_clicked ()
|
|||
|
||||
if (region_cache.find (path) == region_cache.end()) {
|
||||
AudioRegion::SourceList srclist;
|
||||
SndFileSource* sfs;
|
||||
ExternalSource* sfs;
|
||||
|
||||
for (int n = 0; n < sf_info.channels; ++n) {
|
||||
try {
|
||||
sfs = new SndFileSource(path+":"+string_compose("%1", n), false);
|
||||
sfs = ExternalSource::create (path+":"+string_compose("%1", n), false);
|
||||
srclist.push_back(sfs);
|
||||
|
||||
} catch (failed_constructor& err) {
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#include <gtkmm/treeview.h>
|
||||
|
||||
#include <ardour/session.h>
|
||||
#include <ardour/sndfile_helpers.h>
|
||||
#include <ardour/externalsource.h>
|
||||
|
||||
#include "ardour_dialog.h"
|
||||
|
||||
|
@ -67,7 +67,7 @@ class SoundFileBox : public Gtk::VBox
|
|||
|
||||
LabelModelColumns label_columns;
|
||||
|
||||
SoundFileInfo sf_info;
|
||||
ARDOUR::SoundFileInfo sf_info;
|
||||
|
||||
pid_t current_pid;
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
#include <ardour/playlist.h>
|
||||
#include <ardour/audioregion.h>
|
||||
#include <ardour/sndfilesource.h>
|
||||
#include <ardour/diskstream.h>
|
||||
|
||||
#include "taperegionview.h"
|
||||
|
|
|
@ -37,6 +37,7 @@ cycle_timer.cc
|
|||
default_click.cc
|
||||
destructive_filesource.cc
|
||||
diskstream.cc
|
||||
externalsource.cc
|
||||
filesource.cc
|
||||
gain.cc
|
||||
gdither.cc
|
||||
|
|
|
@ -20,36 +20,26 @@
|
|||
#ifndef __coreaudio_source_h__
|
||||
#define __coreaudio_source_h__
|
||||
|
||||
#include <ardour/source.h>
|
||||
#include <ardour/externalsource.h>
|
||||
#include <AudioToolbox/ExtendedAudioFile.h>
|
||||
|
||||
namespace ARDOUR {
|
||||
|
||||
class CoreAudioSource : public Source {
|
||||
class CoreAudioSource : public ExternalSource {
|
||||
public:
|
||||
CoreAudioSource (const string& path_plus_channel, bool build_peak = true);
|
||||
CoreAudioSource (const XMLNode&);
|
||||
~CoreAudioSource ();
|
||||
|
||||
jack_nframes_t length() const { return _length; }
|
||||
jack_nframes_t read (Sample *dst, jack_nframes_t start, jack_nframes_t cnt, char * workbuf) const;
|
||||
void mark_for_remove() {} // we never remove external sndfiles
|
||||
string peak_path(string audio_path);
|
||||
string old_peak_path(string audio_path);
|
||||
string path() const { return _path; }
|
||||
|
||||
static void set_peak_dir (string dir) { peak_dir = dir; }
|
||||
|
||||
private:
|
||||
static string peak_dir;
|
||||
|
||||
ExtAudioFileRef af;
|
||||
uint16_t channel;
|
||||
uint16_t n_channels;
|
||||
|
||||
mutable float *tmpbuf;
|
||||
mutable jack_nframes_t tmpbufsize;
|
||||
mutable PBD::Lock _tmpbuf_lock;
|
||||
string _path;
|
||||
|
||||
void init (const string &str, bool build_peak);
|
||||
jack_nframes_t read_unlocked (Sample *dst, jack_nframes_t start, jack_nframes_t cnt, char * workbuf) const;
|
||||
|
|
68
libs/ardour/ardour/externalsource.h
Normal file
68
libs/ardour/ardour/externalsource.h
Normal file
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
Copyright (C) 2006 Paul Davis
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __external_source_h__
|
||||
#define __external_source_h__
|
||||
|
||||
#include <ardour/source.h>
|
||||
|
||||
namespace ARDOUR {
|
||||
|
||||
struct SoundFileInfo {
|
||||
float samplerate;
|
||||
uint16_t channels;
|
||||
int64_t length;
|
||||
std::string format_name;
|
||||
};
|
||||
|
||||
class ExternalSource : public Source {
|
||||
public:
|
||||
virtual ~ExternalSource ();
|
||||
|
||||
string path() const { return _path; }
|
||||
|
||||
virtual jack_nframes_t read (Sample *dst, jack_nframes_t start, jack_nframes_t cnt, char * workbuf) const = 0;
|
||||
|
||||
void mark_for_remove() {} // we never remove external sndfiles
|
||||
string peak_path(string audio_path);
|
||||
string old_peak_path(string audio_path);
|
||||
|
||||
static void set_peak_dir (string dir) { peak_dir = dir; }
|
||||
|
||||
static ExternalSource* create (const string& path_plus_channel, bool build_peak = true);
|
||||
static ExternalSource* create (const XMLNode& node);
|
||||
static bool get_soundfile_info (string path, SoundFileInfo& _info, string& error);
|
||||
|
||||
protected:
|
||||
ExternalSource (const string& path_plus_channel, bool build_peak = true);
|
||||
ExternalSource (const XMLNode&);
|
||||
|
||||
static string peak_dir;
|
||||
|
||||
uint16_t channel;
|
||||
string _path;
|
||||
|
||||
virtual void init (const string &str, bool build_peak) = 0;
|
||||
virtual jack_nframes_t read_unlocked (Sample *dst, jack_nframes_t start, jack_nframes_t cnt, char * workbuf) const;
|
||||
};
|
||||
|
||||
}; /* namespace ARDOUR */
|
||||
|
||||
#endif /* __external_source_h__ */
|
||||
|
|
@ -36,13 +36,4 @@ int sndfile_data_width (int format);
|
|||
string sndfile_major_format(int);
|
||||
string sndfile_minor_format(int);
|
||||
|
||||
struct SoundFileInfo {
|
||||
float samplerate;
|
||||
uint16_t channels;
|
||||
int64_t length;
|
||||
std::string format_name;
|
||||
};
|
||||
|
||||
bool get_soundfile_info (string path, SoundFileInfo& _info);
|
||||
|
||||
#endif /* __sndfile_helpers_h__ */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 2000 Paul Davis
|
||||
Copyright (C) 2006 Paul Davis
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -18,46 +18,38 @@
|
|||
$Id$
|
||||
*/
|
||||
|
||||
#ifndef __playlist_snd_file_buffer_h__
|
||||
#define __playlist_snd_file_buffer_h__
|
||||
#ifndef __sndfile_source_h__
|
||||
#define __sndfile_source_h__
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
#include <ardour/source.h>
|
||||
#include <ardour/externalsource.h>
|
||||
|
||||
namespace ARDOUR {
|
||||
|
||||
class SndFileSource : public Source {
|
||||
class SndFileSource : public ExternalSource {
|
||||
public:
|
||||
SndFileSource (const string& path_plus_channel, bool build_peak = true);
|
||||
SndFileSource (const XMLNode&);
|
||||
~SndFileSource ();
|
||||
|
||||
jack_nframes_t length() const { return _info.frames; }
|
||||
jack_nframes_t read (Sample *dst, jack_nframes_t start, jack_nframes_t cnt, char * workbuf) const;
|
||||
void mark_for_remove() {} // we never remove external sndfiles
|
||||
string peak_path(string audio_path);
|
||||
string old_peak_path(string audio_path);
|
||||
string path() const { return _path; }
|
||||
jack_nframes_t length() const { return _info.frames; }
|
||||
|
||||
static void set_peak_dir (string dir) { peak_dir = dir; }
|
||||
jack_nframes_t read (Sample *dst, jack_nframes_t start, jack_nframes_t cnt, char * workbuf) const;
|
||||
|
||||
private:
|
||||
static string peak_dir;
|
||||
|
||||
SNDFILE *sf;
|
||||
SF_INFO _info;
|
||||
uint16_t channel;
|
||||
|
||||
mutable float *tmpbuf;
|
||||
mutable jack_nframes_t tmpbufsize;
|
||||
mutable PBD::Lock _tmpbuf_lock;
|
||||
string _path;
|
||||
|
||||
void init (const string &str, bool build_peak);
|
||||
jack_nframes_t read_unlocked (Sample *dst, jack_nframes_t start, jack_nframes_t cnt, char * workbuf) const;
|
||||
};
|
||||
|
||||
}; /* namespace EDL */
|
||||
}; /* namespace ARDOUR */
|
||||
|
||||
#endif /* __playlist_snd_file_buffer_h__ */
|
||||
#endif /* __sndfile_source_h__ */
|
||||
|
||||
|
|
|
@ -17,33 +17,21 @@
|
|||
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <pbd/mountpoint.h>
|
||||
#include <ardour/coreaudio_source.h>
|
||||
|
||||
#include "i18n.h"
|
||||
|
||||
using namespace ARDOUR;
|
||||
|
||||
string CoreAudioSource::peak_dir = "";
|
||||
|
||||
CoreAudioSource::CoreAudioSource (const XMLNode& node)
|
||||
: Source (node)
|
||||
: ExternalSource (node)
|
||||
{
|
||||
if (set_state (node)) {
|
||||
throw failed_constructor();
|
||||
}
|
||||
|
||||
init (_name, true);
|
||||
SourceCreated (this); /* EMIT SIGNAL */
|
||||
SourceCreated (this); /* EMIT SIGNAL */
|
||||
}
|
||||
|
||||
CoreAudioSource::CoreAudioSource (const string& idstr, bool build_peak)
|
||||
: Source(build_peak)
|
||||
: ExternalSource(idstr, build_peak)
|
||||
{
|
||||
init (idstr, build_peak);
|
||||
|
||||
|
@ -73,7 +61,6 @@ CoreAudioSource::init (const string& idstr, bool build_peak)
|
|||
file = idstr.substr (0, pos);
|
||||
}
|
||||
|
||||
|
||||
/* note that we temporarily truncated _id at the colon */
|
||||
FSRef ref;
|
||||
err = FSPathMakeRef ((UInt8*)file.c_str(), &ref, 0);
|
||||
|
@ -125,9 +112,8 @@ CoreAudioSource::init (const string& idstr, bool build_peak)
|
|||
}
|
||||
|
||||
CoreAudioSource::~CoreAudioSource ()
|
||||
|
||||
{
|
||||
GoingAway (this); /* EMIT SIGNAL */
|
||||
GoingAway (this); /* EMIT SIGNAL */
|
||||
|
||||
if (af) {
|
||||
ExtAudioFileDispose (af);
|
||||
|
@ -138,12 +124,6 @@ CoreAudioSource::~CoreAudioSource ()
|
|||
}
|
||||
}
|
||||
|
||||
jack_nframes_t
|
||||
CoreAudioSource::read_unlocked (Sample *dst, jack_nframes_t start, jack_nframes_t cnt, char * workbuf) const
|
||||
{
|
||||
return read (dst, start, cnt, workbuf);
|
||||
}
|
||||
|
||||
jack_nframes_t
|
||||
CoreAudioSource::read (Sample *dst, jack_nframes_t start, jack_nframes_t cnt, char * workbuf) const
|
||||
{
|
||||
|
@ -204,31 +184,3 @@ CoreAudioSource::read (Sample *dst, jack_nframes_t start, jack_nframes_t cnt, ch
|
|||
return real_cnt;
|
||||
}
|
||||
|
||||
string
|
||||
CoreAudioSource::peak_path (string audio_path)
|
||||
{
|
||||
/* XXX hardly bombproof! fix me */
|
||||
|
||||
struct stat stat_file;
|
||||
struct stat stat_mount;
|
||||
|
||||
string mp = mountpoint (audio_path);
|
||||
|
||||
stat (audio_path.c_str(), &stat_file);
|
||||
stat (mp.c_str(), &stat_mount);
|
||||
|
||||
char buf[32];
|
||||
snprintf (buf, sizeof (buf), "%u-%u-%d.peak", stat_mount.st_ino, stat_file.st_ino, channel);
|
||||
|
||||
string res = peak_dir;
|
||||
res += buf;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
string
|
||||
CoreAudioSource::old_peak_path (string audio_path)
|
||||
{
|
||||
return peak_path (audio_path);
|
||||
}
|
||||
|
||||
|
|
203
libs/ardour/externalsource.cc
Normal file
203
libs/ardour/externalsource.cc
Normal file
|
@ -0,0 +1,203 @@
|
|||
/*
|
||||
Copyright (C) 2006 Paul Davis
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
*/
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
#include <pbd/mountpoint.h>
|
||||
#include <ardour/externalsource.h>
|
||||
#include <ardour/sndfilesource.h>
|
||||
#include <ardour/sndfile_helpers.h>
|
||||
|
||||
// if these headers come before sigc++ is included
|
||||
// the parser throws ObjC++ errors. (nil is a keyword)
|
||||
#ifdef HAVE_COREAUDIO
|
||||
#include <ardour/coreaudio_source.h>
|
||||
#include <AudioToolbox/ExtendedAudioFile.h>
|
||||
#include <AudioToolbox/AudioFormat.h>
|
||||
#endif // HAVE_COREAUDIO
|
||||
|
||||
#include "i18n.h"
|
||||
|
||||
using namespace ARDOUR;
|
||||
|
||||
string ExternalSource::peak_dir = "";
|
||||
|
||||
ExternalSource::ExternalSource (const XMLNode& node)
|
||||
: Source (node)
|
||||
{
|
||||
}
|
||||
|
||||
ExternalSource::ExternalSource (const string& idstr, bool build_peak)
|
||||
: Source(build_peak)
|
||||
{
|
||||
}
|
||||
|
||||
ExternalSource::~ExternalSource ()
|
||||
{
|
||||
}
|
||||
|
||||
jack_nframes_t
|
||||
ExternalSource::read_unlocked (Sample *dst, jack_nframes_t start, jack_nframes_t cnt, char * workbuf) const
|
||||
{
|
||||
return read (dst, start, cnt, workbuf);
|
||||
}
|
||||
|
||||
string
|
||||
ExternalSource::peak_path (string audio_path)
|
||||
{
|
||||
/* XXX hardly bombproof! fix me */
|
||||
|
||||
struct stat stat_file;
|
||||
struct stat stat_mount;
|
||||
|
||||
string mp = mountpoint (audio_path);
|
||||
|
||||
stat (audio_path.c_str(), &stat_file);
|
||||
stat (mp.c_str(), &stat_mount);
|
||||
|
||||
char buf[32];
|
||||
snprintf (buf, sizeof (buf), "%ld-%ld-%d.peak", stat_mount.st_ino, stat_file.st_ino, channel);
|
||||
|
||||
string res = peak_dir;
|
||||
res += buf;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
string
|
||||
ExternalSource::old_peak_path (string audio_path)
|
||||
{
|
||||
return peak_path (audio_path);
|
||||
}
|
||||
|
||||
ExternalSource*
|
||||
ExternalSource::create (const XMLNode& node)
|
||||
{
|
||||
return new SndFileSource (node);
|
||||
}
|
||||
|
||||
ExternalSource*
|
||||
ExternalSource::create (const string& idstr, bool build_peak)
|
||||
{
|
||||
return new SndFileSource (idstr, build_peak);
|
||||
}
|
||||
|
||||
#ifdef HAVE_COREAUDIO
|
||||
std::string
|
||||
CFStringRefToStdString(CFStringRef stringRef)
|
||||
{
|
||||
CFIndex size =
|
||||
CFStringGetMaximumSizeForEncoding(CFStringGetLength(stringRef) ,
|
||||
kCFStringEncodingASCII);
|
||||
char *buf = new char[size];
|
||||
|
||||
std::string result;
|
||||
|
||||
if(CFStringGetCString(stringRef, buf, size, kCFStringEncodingASCII)) {
|
||||
result = buf;
|
||||
}
|
||||
delete [] buf;
|
||||
return result;
|
||||
}
|
||||
#endif // HAVE_COREAUDIO
|
||||
|
||||
bool
|
||||
ExternalSource::get_soundfile_info (string path, SoundFileInfo& _info, string& error_msg)
|
||||
{
|
||||
#ifdef HAVE_COREAUDIO
|
||||
OSStatus err = noErr;
|
||||
FSRef ref;
|
||||
ExtAudioFileRef af = 0;
|
||||
size_t size;
|
||||
CFStringRef name;
|
||||
|
||||
err = FSPathMakeRef ((UInt8*)path.c_str(), &ref, 0);
|
||||
if (err != noErr) {
|
||||
ExtAudioFileDispose (af);
|
||||
goto libsndfile;
|
||||
}
|
||||
|
||||
err = ExtAudioFileOpen(&ref, &af);
|
||||
if (err != noErr) {
|
||||
ExtAudioFileDispose (af);
|
||||
goto libsndfile;
|
||||
}
|
||||
|
||||
AudioStreamBasicDescription absd;
|
||||
memset(&absd, 0, sizeof(absd));
|
||||
size = sizeof(AudioStreamBasicDescription);
|
||||
err = ExtAudioFileGetProperty(af,
|
||||
kExtAudioFileProperty_FileDataFormat, &size, &absd);
|
||||
if (err != noErr) {
|
||||
ExtAudioFileDispose (af);
|
||||
goto libsndfile;
|
||||
}
|
||||
|
||||
_info.samplerate = absd.mSampleRate;
|
||||
_info.channels = absd.mChannelsPerFrame;
|
||||
|
||||
size = sizeof(_info.length);
|
||||
err = ExtAudioFileGetProperty(af, kExtAudioFileProperty_FileLengthFrames, &size, &_info.length);
|
||||
if (err != noErr) {
|
||||
ExtAudioFileDispose (af);
|
||||
goto libsndfile;
|
||||
}
|
||||
|
||||
size = sizeof(CFStringRef);
|
||||
err = AudioFormatGetProperty(
|
||||
kAudioFormatProperty_FormatName, sizeof(absd), &absd, &size, &name);
|
||||
if (err != noErr) {
|
||||
ExtAudioFileDispose (af);
|
||||
goto libsndfile;
|
||||
}
|
||||
|
||||
_info.format_name = CFStringRefToStdString(name);
|
||||
|
||||
ExtAudioFileDispose (af);
|
||||
return true;
|
||||
|
||||
libsndfile:
|
||||
#endif // HAVE_COREAUDIO
|
||||
|
||||
SNDFILE *sf;
|
||||
SF_INFO sf_info;
|
||||
|
||||
sf_info.format = 0; // libsndfile says to clear this before sf_open().
|
||||
|
||||
if ((sf = sf_open ((char*) path.c_str(), SFM_READ, &sf_info)) == 0) {
|
||||
char errbuf[256];
|
||||
error_msg = sf_error_str (0, errbuf, sizeof (errbuf) - 1);
|
||||
return false;
|
||||
}
|
||||
|
||||
sf_close (sf);
|
||||
|
||||
_info.samplerate = sf_info.samplerate;
|
||||
_info.channels = sf_info.channels;
|
||||
_info.length = sf_info.frames;
|
||||
_info.format_name = string_compose("Format: %1, %2",
|
||||
sndfile_major_format(sf_info.format),
|
||||
sndfile_minor_format(sf_info.format));
|
||||
|
||||
return true;
|
||||
}
|
|
@ -282,7 +282,7 @@ Session::first_stage_init (string fullpath, string snapshot_name)
|
|||
int
|
||||
Session::second_stage_init (bool new_session)
|
||||
{
|
||||
SndFileSource::set_peak_dir (peak_dir());
|
||||
ExternalSource::set_peak_dir (peak_dir());
|
||||
|
||||
if (!new_session) {
|
||||
if (load_state (_current_snapshot_name)) {
|
||||
|
@ -1802,7 +1802,6 @@ Session::XMLSourceFactory (const XMLNode& node)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
if (node.property (X_("destructive")) != 0) {
|
||||
src = new DestructiveFileSource (node, frame_rate());
|
||||
|
@ -1814,7 +1813,7 @@ Session::XMLSourceFactory (const XMLNode& node)
|
|||
catch (failed_constructor& err) {
|
||||
|
||||
try {
|
||||
src = new SndFileSource (node);
|
||||
src = ExternalSource::create (node);
|
||||
}
|
||||
|
||||
catch (failed_constructor& err) {
|
||||
|
@ -2946,11 +2945,11 @@ Session::cleanup_sources (Session::cleanup_report& rep)
|
|||
|
||||
for (SourceList::iterator i = sources.begin(); i != sources.end(); ++i) {
|
||||
FileSource* fs;
|
||||
SndFileSource* sfs;
|
||||
ExternalSource* sfs;
|
||||
|
||||
if ((fs = dynamic_cast<FileSource*> ((*i).second)) != 0) {
|
||||
all_sources.insert (fs->path());
|
||||
} else if ((sfs = dynamic_cast<SndFileSource*> ((*i).second)) != 0) {
|
||||
} else if ((sfs = dynamic_cast<ExternalSource*> ((*i).second)) != 0) {
|
||||
all_sources.insert (sfs->path());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,11 +4,6 @@
|
|||
#include <sndfile.h>
|
||||
#include <ardour/sndfile_helpers.h>
|
||||
|
||||
#ifdef HAVE_COREAUDIO
|
||||
#include <AudioToolbox/ExtendedAudioFile.h>
|
||||
#include <AudioToolbox/AudioFormat.h>
|
||||
#endif // HAVE_COREAUDIO
|
||||
|
||||
#include "i18n.h"
|
||||
|
||||
using std::map;
|
||||
|
@ -197,101 +192,3 @@ sndfile_minor_format(int format)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_COREAUDIO
|
||||
std::string
|
||||
CFStringRefToStdString(CFStringRef stringRef)
|
||||
{
|
||||
CFIndex size =
|
||||
CFStringGetMaximumSizeForEncoding(CFStringGetLength(stringRef) ,
|
||||
kCFStringEncodingASCII);
|
||||
char *buf = new char[size];
|
||||
|
||||
std::string result;
|
||||
|
||||
if(CFStringGetCString(stringRef, buf, size, kCFStringEncodingASCII)) {
|
||||
result = buf;
|
||||
}
|
||||
delete [] buf;
|
||||
return result;
|
||||
}
|
||||
#endif // HAVE_COREAUDIO
|
||||
|
||||
bool
|
||||
get_soundfile_info (string path, SoundFileInfo& _info)
|
||||
{
|
||||
#ifdef HAVE_COREAUDIO
|
||||
OSStatus err = noErr;
|
||||
FSRef ref;
|
||||
ExtAudioFileRef af = 0;
|
||||
size_t size;
|
||||
CFStringRef name;
|
||||
|
||||
err = FSPathMakeRef ((UInt8*)path.c_str(), &ref, 0);
|
||||
if (err != noErr) {
|
||||
ExtAudioFileDispose (af);
|
||||
goto libsndfile;
|
||||
}
|
||||
|
||||
err = ExtAudioFileOpen(&ref, &af);
|
||||
if (err != noErr) {
|
||||
ExtAudioFileDispose (af);
|
||||
goto libsndfile;
|
||||
}
|
||||
|
||||
AudioStreamBasicDescription absd;
|
||||
memset(&absd, 0, sizeof(absd));
|
||||
size = sizeof(AudioStreamBasicDescription);
|
||||
err = ExtAudioFileGetProperty(af,
|
||||
kExtAudioFileProperty_FileDataFormat, &size, &absd);
|
||||
if (err != noErr) {
|
||||
ExtAudioFileDispose (af);
|
||||
goto libsndfile;
|
||||
}
|
||||
|
||||
_info.samplerate = absd.mSampleRate;
|
||||
_info.channels = absd.mChannelsPerFrame;
|
||||
|
||||
size = sizeof(_info.length);
|
||||
err = ExtAudioFileGetProperty(af, kExtAudioFileProperty_FileLengthFrames, &size, &_info.length);
|
||||
if (err != noErr) {
|
||||
ExtAudioFileDispose (af);
|
||||
goto libsndfile;
|
||||
}
|
||||
|
||||
size = sizeof(CFStringRef);
|
||||
err = AudioFormatGetProperty(
|
||||
kAudioFormatProperty_FormatName, sizeof(absd), &absd, &size, &name);
|
||||
if (err != noErr) {
|
||||
ExtAudioFileDispose (af);
|
||||
goto libsndfile;
|
||||
}
|
||||
|
||||
_info.format_name = CFStringRefToStdString(name);
|
||||
|
||||
ExtAudioFileDispose (af);
|
||||
return true;
|
||||
|
||||
libsndfile:
|
||||
#endif // HAVE_COREAUDIO
|
||||
|
||||
SNDFILE *sf;
|
||||
SF_INFO sf_info;
|
||||
|
||||
sf_info.format = 0; // libsndfile says to clear this before sf_open().
|
||||
|
||||
if ((sf = sf_open ((char*) path.c_str(), SFM_READ, &sf_info)) == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
sf_close (sf);
|
||||
|
||||
_info.samplerate = sf_info.samplerate;
|
||||
_info.channels = sf_info.channels;
|
||||
_info.length = sf_info.frames;
|
||||
_info.format_name = string_compose("Format: %1, %2",
|
||||
sndfile_major_format(sf_info.format),
|
||||
sndfile_minor_format(sf_info.format));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 2000 Paul Davis
|
||||
Copyright (C) 2006 Paul Davis
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -18,33 +18,21 @@
|
|||
$Id$
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <pbd/mountpoint.h>
|
||||
#include <ardour/sndfilesource.h>
|
||||
|
||||
#include "i18n.h"
|
||||
|
||||
using namespace ARDOUR;
|
||||
|
||||
string SndFileSource::peak_dir = "";
|
||||
|
||||
SndFileSource::SndFileSource (const XMLNode& node)
|
||||
: Source (node)
|
||||
: ExternalSource (node)
|
||||
{
|
||||
if (set_state (node)) {
|
||||
throw failed_constructor();
|
||||
}
|
||||
|
||||
init (_name, true);
|
||||
SourceCreated (this); /* EMIT SIGNAL */
|
||||
SourceCreated (this); /* EMIT SIGNAL */
|
||||
}
|
||||
|
||||
SndFileSource::SndFileSource (const string& idstr, bool build_peak)
|
||||
: Source(build_peak)
|
||||
: ExternalSource(idstr, build_peak)
|
||||
{
|
||||
init (idstr, build_peak);
|
||||
|
||||
|
@ -110,7 +98,7 @@ SndFileSource::init (const string& idstr, bool build_peak)
|
|||
SndFileSource::~SndFileSource ()
|
||||
|
||||
{
|
||||
GoingAway (this); /* EMIT SIGNAL */
|
||||
GoingAway (this); /* EMIT SIGNAL */
|
||||
|
||||
if (sf) {
|
||||
sf_close (sf);
|
||||
|
@ -121,12 +109,6 @@ SndFileSource::~SndFileSource ()
|
|||
}
|
||||
}
|
||||
|
||||
jack_nframes_t
|
||||
SndFileSource::read_unlocked (Sample *dst, jack_nframes_t start, jack_nframes_t cnt, char * workbuf) const
|
||||
{
|
||||
return read (dst, start, cnt, workbuf);
|
||||
}
|
||||
|
||||
jack_nframes_t
|
||||
SndFileSource::read (Sample *dst, jack_nframes_t start, jack_nframes_t cnt, char * workbuf) const
|
||||
{
|
||||
|
@ -178,30 +160,3 @@ SndFileSource::read (Sample *dst, jack_nframes_t start, jack_nframes_t cnt, char
|
|||
return nread;
|
||||
}
|
||||
|
||||
string
|
||||
SndFileSource::peak_path (string audio_path)
|
||||
{
|
||||
/* XXX hardly bombproof! fix me */
|
||||
|
||||
struct stat stat_file;
|
||||
struct stat stat_mount;
|
||||
|
||||
string mp = mountpoint (audio_path);
|
||||
|
||||
stat (audio_path.c_str(), &stat_file);
|
||||
stat (mp.c_str(), &stat_mount);
|
||||
|
||||
char buf[32];
|
||||
snprintf (buf, sizeof (buf), "%ld-%ld-%d.peak", stat_mount.st_ino, stat_file.st_ino, channel);
|
||||
|
||||
string res = peak_dir;
|
||||
res += buf;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
string
|
||||
SndFileSource::old_peak_path (string audio_path)
|
||||
{
|
||||
return peak_path (audio_path);
|
||||
}
|
||||
|
|
|
@ -34,8 +34,6 @@
|
|||
#include <pbd/pthread_utils.h>
|
||||
|
||||
#include <ardour/source.h>
|
||||
#include <ardour/filesource.h>
|
||||
#include <ardour/sndfilesource.h>
|
||||
|
||||
#include "i18n.h"
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user