NO-OP: cleanup and lang-format
This commit is contained in:
parent
370adfa322
commit
183f00bbed
|
@ -20,58 +20,43 @@
|
|||
#ifndef __ardour_source_factory_h__
|
||||
#define __ardour_source_factory_h__
|
||||
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include <glibmm/threads.h>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
|
||||
#include "ardour/source.h"
|
||||
|
||||
class XMLNode;
|
||||
|
||||
namespace ARDOUR {
|
||||
|
||||
namespace ARDOUR
|
||||
{
|
||||
class Session;
|
||||
class AudioSource;
|
||||
class Playlist;
|
||||
|
||||
class LIBARDOUR_API SourceFactory {
|
||||
public:
|
||||
class LIBARDOUR_API SourceFactory
|
||||
{
|
||||
public:
|
||||
static void init ();
|
||||
|
||||
static PBD::Signal1<void,boost::shared_ptr<Source> > SourceCreated;
|
||||
static PBD::Signal1<void, boost::shared_ptr<Source>> SourceCreated;
|
||||
|
||||
static boost::shared_ptr<Source> create (Session&, const XMLNode& node, bool async = false);
|
||||
static boost::shared_ptr<Source> createSilent (Session&, const XMLNode& node,
|
||||
samplecnt_t nframes, float sample_rate);
|
||||
static boost::shared_ptr<Source> createSilent (Session&, const XMLNode& node, samplecnt_t, float sample_rate);
|
||||
static boost::shared_ptr<Source> createExternal (DataType, Session&, const std::string& path, int chn, Source::Flag, bool announce = true, bool async = false);
|
||||
static boost::shared_ptr<Source> createWritable (DataType, Session&, const std::string& path, samplecnt_t rate, bool announce = true, bool async = false);
|
||||
static boost::shared_ptr<Source> createForRecovery (DataType, Session&, const std::string& path, int chn);
|
||||
static boost::shared_ptr<Source> createFromPlaylist (DataType, Session&, boost::shared_ptr<Playlist> p, const PBD::ID& orig, const std::string& name, uint32_t chn, timepos_t start, timepos_t const& len, bool copy, bool defer_peaks);
|
||||
|
||||
static boost::shared_ptr<Source> createExternal
|
||||
(DataType type, Session&,
|
||||
const std::string& path,
|
||||
int chn, Source::Flag flags, bool announce = true, bool async = false);
|
||||
static Glib::Threads::Cond PeaksToBuild;
|
||||
static Glib::Threads::Mutex peak_building_lock;
|
||||
|
||||
static boost::shared_ptr<Source> createWritable
|
||||
(DataType type, Session&,
|
||||
const std::string& path,
|
||||
samplecnt_t rate, bool announce = true, bool async = false);
|
||||
|
||||
|
||||
static boost::shared_ptr<Source> createForRecovery
|
||||
(DataType type, Session&, const std::string& path, int chn);
|
||||
|
||||
static boost::shared_ptr<Source> createFromPlaylist
|
||||
(DataType type, Session& s, boost::shared_ptr<Playlist> p, const PBD::ID& orig, const std::string& name,
|
||||
uint32_t chn, timepos_t start, timepos_t const & len, bool copy, bool defer_peaks);
|
||||
|
||||
static Glib::Threads::Cond PeaksToBuild;
|
||||
static Glib::Threads::Mutex peak_building_lock;
|
||||
static std::list< boost::weak_ptr<AudioSource> > files_with_peaks;
|
||||
static std::list<boost::weak_ptr<AudioSource>> files_with_peaks;
|
||||
|
||||
static int peak_work_queue_length ();
|
||||
static int setup_peakfile (boost::shared_ptr<Source>, bool async);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace ARDOUR
|
||||
|
||||
#endif /* __ardour_source_factory_h__ */
|
||||
|
|
|
@ -24,22 +24,22 @@
|
|||
#include "libardour-config.h"
|
||||
#endif
|
||||
|
||||
#include "pbd/error.h"
|
||||
#include "pbd/convert.h"
|
||||
#include "pbd/error.h"
|
||||
#include "pbd/pthread_utils.h"
|
||||
|
||||
#include "ardour/audioplaylist.h"
|
||||
#include "ardour/audio_playlist_source.h"
|
||||
#include "ardour/audioplaylist.h"
|
||||
#include "ardour/boost_debug.h"
|
||||
#include "ardour/ffmpegfilesource.h"
|
||||
#include "ardour/midi_playlist.h"
|
||||
#include "ardour/mp3filesource.h"
|
||||
#include "ardour/source.h"
|
||||
#include "ardour/source_factory.h"
|
||||
#include "ardour/sndfilesource.h"
|
||||
#include "ardour/session.h"
|
||||
#include "ardour/silentfilesource.h"
|
||||
#include "ardour/smf_source.h"
|
||||
#include "ardour/session.h"
|
||||
#include "ardour/sndfilesource.h"
|
||||
#include "ardour/source.h"
|
||||
#include "ardour/source_factory.h"
|
||||
|
||||
#ifdef HAVE_COREAUDIO
|
||||
#include "ardour/coreaudiosource.h"
|
||||
|
@ -51,10 +51,10 @@ using namespace ARDOUR;
|
|||
using namespace std;
|
||||
using namespace PBD;
|
||||
|
||||
PBD::Signal1<void,boost::shared_ptr<Source> > SourceFactory::SourceCreated;
|
||||
Glib::Threads::Cond SourceFactory::PeaksToBuild;
|
||||
Glib::Threads::Mutex SourceFactory::peak_building_lock;
|
||||
std::list<boost::weak_ptr<AudioSource> > SourceFactory::files_with_peaks;
|
||||
PBD::Signal1<void, boost::shared_ptr<Source>> SourceFactory::SourceCreated;
|
||||
Glib::Threads::Cond SourceFactory::PeaksToBuild;
|
||||
Glib::Threads::Mutex SourceFactory::peak_building_lock;
|
||||
std::list<boost::weak_ptr<AudioSource>> SourceFactory::files_with_peaks;
|
||||
|
||||
static int active_threads = 0;
|
||||
|
||||
|
@ -65,19 +65,18 @@ peak_thread_work ()
|
|||
pthread_set_name ("PeakFileBuilder");
|
||||
|
||||
while (true) {
|
||||
|
||||
SourceFactory::peak_building_lock.lock ();
|
||||
|
||||
wait:
|
||||
if (SourceFactory::files_with_peaks.empty()) {
|
||||
wait:
|
||||
if (SourceFactory::files_with_peaks.empty ()) {
|
||||
SourceFactory::PeaksToBuild.wait (SourceFactory::peak_building_lock);
|
||||
}
|
||||
|
||||
if (SourceFactory::files_with_peaks.empty()) {
|
||||
if (SourceFactory::files_with_peaks.empty ()) {
|
||||
goto wait;
|
||||
}
|
||||
|
||||
boost::shared_ptr<AudioSource> as (SourceFactory::files_with_peaks.front().lock());
|
||||
boost::shared_ptr<AudioSource> as (SourceFactory::files_with_peaks.front ().lock ());
|
||||
SourceFactory::files_with_peaks.pop_front ();
|
||||
++active_threads;
|
||||
SourceFactory::peak_building_lock.unlock ();
|
||||
|
@ -115,18 +114,15 @@ SourceFactory::setup_peakfile (boost::shared_ptr<Source> s, bool async)
|
|||
boost::shared_ptr<AudioSource> as (boost::dynamic_pointer_cast<AudioSource> (s));
|
||||
|
||||
if (as) {
|
||||
|
||||
// immediately set 'peakfile-path' for empty and NoPeakFile sources
|
||||
if (async && !as->empty() && !(as->flags() & Source::NoPeakFile)) {
|
||||
|
||||
if (async && !as->empty () && !(as->flags () & Source::NoPeakFile)) {
|
||||
Glib::Threads::Mutex::Lock lm (peak_building_lock);
|
||||
files_with_peaks.push_back (boost::weak_ptr<AudioSource> (as));
|
||||
PeaksToBuild.broadcast ();
|
||||
|
||||
} else {
|
||||
|
||||
if (as->setup_peakfile ()) {
|
||||
error << string_compose("SourceFactory: could not set up peakfile for %1", as->name()) << endmsg;
|
||||
error << string_compose ("SourceFactory: could not set up peakfile for %1", as->name ()) << endmsg;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -138,7 +134,7 @@ SourceFactory::setup_peakfile (boost::shared_ptr<Source> s, bool async)
|
|||
boost::shared_ptr<Source>
|
||||
SourceFactory::createSilent (Session& s, const XMLNode& node, samplecnt_t nframes, float sr)
|
||||
{
|
||||
Source* src = new SilentFileSource (s, node, nframes, sr);
|
||||
Source* src = new SilentFileSource (s, node, nframes, sr);
|
||||
boost::shared_ptr<Source> ret (src);
|
||||
BOOST_MARK_SOURCE (ret);
|
||||
// no analysis data - the file is non-existent
|
||||
|
@ -149,19 +145,17 @@ SourceFactory::createSilent (Session& s, const XMLNode& node, samplecnt_t nframe
|
|||
boost::shared_ptr<Source>
|
||||
SourceFactory::create (Session& s, const XMLNode& node, bool defer_peaks)
|
||||
{
|
||||
DataType type = DataType::AUDIO;
|
||||
XMLProperty const * prop = node.property("type");
|
||||
DataType type = DataType::AUDIO;
|
||||
XMLProperty const* prop = node.property ("type");
|
||||
|
||||
if (prop) {
|
||||
type = DataType (prop->value());
|
||||
type = DataType (prop->value ());
|
||||
}
|
||||
|
||||
if (type == DataType::AUDIO) {
|
||||
|
||||
/* it could be nested */
|
||||
|
||||
if (node.property ("playlist") != 0) {
|
||||
|
||||
try {
|
||||
boost::shared_ptr<AudioPlaylistSource> ap (new AudioPlaylistSource (s, node));
|
||||
|
||||
|
@ -179,9 +173,8 @@ SourceFactory::create (Session& s, const XMLNode& node, bool defer_peaks)
|
|||
}
|
||||
|
||||
} else {
|
||||
|
||||
try {
|
||||
Source* src = new SndFileSource (s, node);
|
||||
Source* src = new SndFileSource (s, node);
|
||||
boost::shared_ptr<Source> ret (src);
|
||||
BOOST_MARK_SOURCE (ret);
|
||||
if (setup_peakfile (ret, defer_peaks)) {
|
||||
|
@ -190,11 +183,12 @@ SourceFactory::create (Session& s, const XMLNode& node, bool defer_peaks)
|
|||
ret->check_for_analysis_data_on_disk ();
|
||||
SourceCreated (ret);
|
||||
return ret;
|
||||
} catch (failed_constructor& err) { }
|
||||
} catch (failed_constructor& err) {
|
||||
}
|
||||
|
||||
#ifdef HAVE_COREAUDIO
|
||||
try {
|
||||
Source* src = new CoreAudioSource (s, node);
|
||||
Source* src = new CoreAudioSource (s, node);
|
||||
boost::shared_ptr<Source> ret (src);
|
||||
BOOST_MARK_SOURCE (ret);
|
||||
|
||||
|
@ -205,7 +199,8 @@ SourceFactory::create (Session& s, const XMLNode& node, bool defer_peaks)
|
|||
ret->check_for_analysis_data_on_disk ();
|
||||
SourceCreated (ret);
|
||||
return ret;
|
||||
} catch (...) { }
|
||||
} catch (...) {
|
||||
}
|
||||
#endif
|
||||
/* this is allowed to throw */
|
||||
throw failed_constructor ();
|
||||
|
@ -214,7 +209,7 @@ SourceFactory::create (Session& s, const XMLNode& node, bool defer_peaks)
|
|||
} else if (type == DataType::MIDI) {
|
||||
try {
|
||||
boost::shared_ptr<SMFSource> src (new SMFSource (s, node));
|
||||
Source::Lock lock(src->mutex());
|
||||
Source::Lock lock (src->mutex ());
|
||||
src->load_model (lock, true);
|
||||
BOOST_MARK_SOURCE (src);
|
||||
src->check_for_analysis_data_on_disk ();
|
||||
|
@ -229,12 +224,11 @@ SourceFactory::create (Session& s, const XMLNode& node, bool defer_peaks)
|
|||
|
||||
boost::shared_ptr<Source>
|
||||
SourceFactory::createExternal (DataType type, Session& s, const string& path,
|
||||
int chn, Source::Flag flags, bool announce, bool defer_peaks)
|
||||
int chn, Source::Flag flags, bool announce, bool defer_peaks)
|
||||
{
|
||||
if (type == DataType::AUDIO) {
|
||||
|
||||
try {
|
||||
Source* src = new SndFileSource (s, path, chn, flags);
|
||||
Source* src = new SndFileSource (s, path, chn, flags);
|
||||
boost::shared_ptr<Source> ret (src);
|
||||
BOOST_MARK_SOURCE (ret);
|
||||
if (setup_peakfile (ret, defer_peaks)) {
|
||||
|
@ -245,11 +239,12 @@ SourceFactory::createExternal (DataType type, Session& s, const string& path,
|
|||
SourceCreated (ret);
|
||||
}
|
||||
return ret;
|
||||
} catch (failed_constructor& err) { }
|
||||
} catch (failed_constructor& err) {
|
||||
}
|
||||
|
||||
#ifdef HAVE_COREAUDIO
|
||||
try {
|
||||
Source* src = new CoreAudioSource (s, path, chn, flags);
|
||||
Source* src = new CoreAudioSource (s, path, chn, flags);
|
||||
boost::shared_ptr<Source> ret (src);
|
||||
BOOST_MARK_SOURCE (ret);
|
||||
if (setup_peakfile (ret, defer_peaks)) {
|
||||
|
@ -260,33 +255,35 @@ SourceFactory::createExternal (DataType type, Session& s, const string& path,
|
|||
SourceCreated (ret);
|
||||
}
|
||||
return ret;
|
||||
} catch (...) { }
|
||||
} catch (...) {
|
||||
}
|
||||
#endif
|
||||
|
||||
/* only create mp3s for audition: no announce, no peaks */
|
||||
if (!announce && (!AudioFileSource::get_build_peakfiles () || defer_peaks)) {
|
||||
try {
|
||||
Source* src = new Mp3FileSource (s, path, chn, flags);
|
||||
Source* src = new Mp3FileSource (s, path, chn, flags);
|
||||
boost::shared_ptr<Source> ret (src);
|
||||
BOOST_MARK_SOURCE (ret);
|
||||
return ret;
|
||||
|
||||
} catch (failed_constructor& err) { }
|
||||
} catch (failed_constructor& err) {
|
||||
}
|
||||
|
||||
try {
|
||||
Source* src = new FFMPEGFileSource (s, path, chn, flags);
|
||||
Source* src = new FFMPEGFileSource (s, path, chn, flags);
|
||||
boost::shared_ptr<Source> ret (src);
|
||||
BOOST_MARK_SOURCE (ret);
|
||||
return ret;
|
||||
|
||||
} catch (failed_constructor& err) { }
|
||||
} catch (failed_constructor& err) {
|
||||
}
|
||||
}
|
||||
|
||||
} else if (type == DataType::MIDI) {
|
||||
|
||||
try {
|
||||
boost::shared_ptr<SMFSource> src (new SMFSource (s, path));
|
||||
Source::Lock lock(src->mutex());
|
||||
Source::Lock lock (src->mutex ());
|
||||
src->load_model (lock, true);
|
||||
BOOST_MARK_SOURCE (src);
|
||||
|
||||
|
@ -297,7 +294,6 @@ SourceFactory::createExternal (DataType type, Session& s, const string& path,
|
|||
return src;
|
||||
} catch (...) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
throw failed_constructor ();
|
||||
|
@ -305,16 +301,16 @@ SourceFactory::createExternal (DataType type, Session& s, const string& path,
|
|||
|
||||
boost::shared_ptr<Source>
|
||||
SourceFactory::createWritable (DataType type, Session& s, const std::string& path,
|
||||
samplecnt_t rate, bool announce, bool defer_peaks)
|
||||
samplecnt_t rate, bool announce, bool defer_peaks)
|
||||
{
|
||||
/* this might throw failed_constructor(), which is OK */
|
||||
|
||||
if (type == DataType::AUDIO) {
|
||||
Source* src = new SndFileSource (s, path, string(),
|
||||
s.config.get_native_file_data_format(),
|
||||
s.config.get_native_file_header_format(),
|
||||
rate,
|
||||
SndFileSource::default_writable_flags);
|
||||
Source* src = new SndFileSource (s, path, string (),
|
||||
s.config.get_native_file_data_format (),
|
||||
s.config.get_native_file_header_format (),
|
||||
rate,
|
||||
SndFileSource::default_writable_flags);
|
||||
boost::shared_ptr<Source> ret (src);
|
||||
BOOST_MARK_SOURCE (ret);
|
||||
|
||||
|
@ -330,13 +326,13 @@ SourceFactory::createWritable (DataType type, Session& s, const std::string& pat
|
|||
return ret;
|
||||
|
||||
} else if (type == DataType::MIDI) {
|
||||
// XXX writable flags should belong to MidiSource too
|
||||
// XXX writable flags should belong to MidiSource too
|
||||
try {
|
||||
boost::shared_ptr<SMFSource> src (new SMFSource (s, path, SndFileSource::default_writable_flags));
|
||||
|
||||
assert (src->writable ());
|
||||
|
||||
Source::Lock lock(src->mutex());
|
||||
Source::Lock lock (src->mutex ());
|
||||
src->load_model (lock, true);
|
||||
BOOST_MARK_SOURCE (src);
|
||||
|
||||
|
@ -388,21 +384,19 @@ SourceFactory::createForRecovery (DataType type, Session& s, const std::string&
|
|||
|
||||
boost::shared_ptr<Source>
|
||||
SourceFactory::createFromPlaylist (DataType type, Session& s, boost::shared_ptr<Playlist> p, const PBD::ID& orig, const std::string& name,
|
||||
uint32_t chn, timepos_t start, timepos_t const & len, bool copy, bool defer_peaks)
|
||||
uint32_t chn, timepos_t start, timepos_t const& len, bool copy, bool defer_peaks)
|
||||
{
|
||||
if (type == DataType::AUDIO) {
|
||||
try {
|
||||
|
||||
boost::shared_ptr<AudioPlaylist> ap = boost::dynamic_pointer_cast<AudioPlaylist>(p);
|
||||
boost::shared_ptr<AudioPlaylist> ap = boost::dynamic_pointer_cast<AudioPlaylist> (p);
|
||||
|
||||
if (ap) {
|
||||
|
||||
if (copy) {
|
||||
ap.reset (new AudioPlaylist (ap, start, len, name, true));
|
||||
start = timecnt_t::zero (Temporal::AudioTime);
|
||||
}
|
||||
|
||||
Source* src = new AudioPlaylistSource (s, orig, name, ap, chn, start, len, Source::Flag (0));
|
||||
Source* src = new AudioPlaylistSource (s, orig, name, ap, chn, start, len, Source::Flag (0));
|
||||
boost::shared_ptr<Source> ret (src);
|
||||
|
||||
if (setup_peakfile (ret, defer_peaks)) {
|
||||
|
@ -420,7 +414,6 @@ SourceFactory::createFromPlaylist (DataType type, Session& s, boost::shared_ptr<
|
|||
}
|
||||
|
||||
} else if (type == DataType::MIDI) {
|
||||
|
||||
/* fail - not implemented, and probably too difficult to do */
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user