fix peakfile/sourcefactory botch

git-svn-id: svn://localhost/ardour2/trunk@2546 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2007-10-12 14:27:47 +00:00
parent a57a62b925
commit 50c68c6d0c
2 changed files with 61 additions and 60 deletions

View file

@ -46,7 +46,7 @@ class SourceFactory {
static boost::shared_ptr<Source> createReadable (DataType type, Session&, std::string path, int chn, AudioFileSource::Flag flags, static boost::shared_ptr<Source> createReadable (DataType type, Session&, std::string path, int chn, AudioFileSource::Flag flags,
bool announce = true, bool async = false); bool announce = true, bool async = false);
static boost::shared_ptr<Source> createWritable (DataType type, Session&, std::string name, bool destructive, nframes_t rate, static boost::shared_ptr<Source> createWritable (DataType type, Session&, std::string name, bool destructive, nframes_t rate,
bool announce = true, bool async = true); bool announce = true, bool async = false);
static Glib::Cond* PeaksToBuild; static Glib::Cond* PeaksToBuild;
static Glib::StaticMutex peak_building_lock; static Glib::StaticMutex peak_building_lock;

View file

@ -116,17 +116,27 @@ SourceFactory::createSilent (Session& s, const XMLNode& node, nframes_t nframes,
return ret; return ret;
} }
#ifdef USE_COREAUDIO_FOR_FILES
boost::shared_ptr<Source> boost::shared_ptr<Source>
SourceFactory::create (Session& s, const XMLNode& node, bool defer_peaks) SourceFactory::create (Session& s, const XMLNode& node, bool defer_peaks)
{ {
DataType type = DataType::AUDIO;
const XMLProperty* prop = node.property("type");
if (prop) {
type = DataType(prop->value());
}
if (type == DataType::AUDIO) {
#ifdef HAVE_COREAUDIO
try { try {
boost::shared_ptr<Source> ret (new CoreAudioSource (s, node)); boost::shared_ptr<Source> ret (new CoreAudioSource (s, node));
if (!defer_peaks) {
if (setup_peakfile (ret, false)) { if (setup_peakfile (ret, defer_peaks)) {
return boost::shared_ptr<Source>(); return boost::shared_ptr<Source>();
} }
}
SourceCreated (ret); SourceCreated (ret);
return ret; return ret;
} }
@ -137,38 +147,34 @@ SourceFactory::create (Session& s, const XMLNode& node, bool defer_peaks)
/* this is allowed to throw */ /* this is allowed to throw */
boost::shared_ptr<Source> ret (new SndFileSource (s, node)); boost::shared_ptr<Source> ret (new SndFileSource (s, node));
if (!defer_peaks) {
if (setup_peakfile (ret, false)) { if (setup_peakfile (ret, defer_peaks)) {
return boost::shared_ptr<Source>(); return boost::shared_ptr<Source>();
} }
}
SourceCreated (ret); SourceCreated (ret);
return ret; return ret;
} }
return boost::shared_ptr<Source>();
}
#else #else
boost::shared_ptr<Source>
SourceFactory::create (Session& s, const XMLNode& node, bool defer_peaks)
{
/* this is allowed to throw */ /* this is allowed to throw */
boost::shared_ptr<Source> ret (new SndFileSource (s, node)); boost::shared_ptr<Source> ret (new SndFileSource (s, node));
if (!defer_peaks) { if (setup_peakfile (ret, defer_peaks)) {
if (setup_peakfile (ret, false)) {
return boost::shared_ptr<Source>(); return boost::shared_ptr<Source>();
} }
}
SourceCreated (ret); SourceCreated (ret);
return ret; return ret;
#endif
} else if (type == DataType::MIDI) {
boost::shared_ptr<Source> ret (new SMFSource (s, node));
} }
#endif // USE_COREAUDIO_FOR_FILES return boost::shared_ptr<Source>();
}
boost::shared_ptr<Source> boost::shared_ptr<Source>
SourceFactory::createReadable (DataType type, Session& s, string path, int chn, AudioFileSource::Flag flags, bool announce, bool defer_peaks) SourceFactory::createReadable (DataType type, Session& s, string path, int chn, AudioFileSource::Flag flags, bool announce, bool defer_peaks)
@ -178,11 +184,11 @@ SourceFactory::createReadable (DataType type, Session& s, string path, int chn,
#ifdef HAVE_COREAUDIO #ifdef HAVE_COREAUDIO
try { try {
boost::shared_ptr<Source> ret (new CoreAudioSource (s, path, chn, flags)); boost::shared_ptr<Source> ret (new CoreAudioSource (s, path, chn, flags));
if (!defer_peaks) {
if (setup_peakfile (ret, false)) { if (setup_peakfile (ret, defer_peaks)) {
return boost::shared_ptr<Source>(); return boost::shared_ptr<Source>();
} }
}
if (announce) { if (announce) {
SourceCreated (ret); SourceCreated (ret);
} }
@ -191,11 +197,9 @@ SourceFactory::createReadable (DataType type, Session& s, string path, int chn,
catch (failed_constructor& err) { catch (failed_constructor& err) {
boost::shared_ptr<Source> ret (new SndFileSource (s, path, chn, flags)); boost::shared_ptr<Source> ret (new SndFileSource (s, path, chn, flags));
if (!defer_peaks) { if (setup_peakfile (ret, defer_peaks)) {
if (setup_peakfile (ret, false)) {
return boost::shared_ptr<Source>(); return boost::shared_ptr<Source>();
} }
}
if (announce) { if (announce) {
SourceCreated (ret); SourceCreated (ret);
} }
@ -204,11 +208,9 @@ SourceFactory::createReadable (DataType type, Session& s, string path, int chn,
#else #else
boost::shared_ptr<Source> ret (new SndFileSource (s, path, chn, flags)); boost::shared_ptr<Source> ret (new SndFileSource (s, path, chn, flags));
if (!defer_peaks) { if (setup_peakfile (ret, defer_peaks)) {
if (setup_peakfile (ret, false)) {
return boost::shared_ptr<Source>(); return boost::shared_ptr<Source>();
} }
}
if (announce) { if (announce) {
SourceCreated (ret); SourceCreated (ret);
@ -246,11 +248,10 @@ SourceFactory::createWritable (DataType type, Session& s, std::string path, bool
(destructive ? AudioFileSource::Flag (SndFileSource::default_writable_flags | AudioFileSource::Destructive) : (destructive ? AudioFileSource::Flag (SndFileSource::default_writable_flags | AudioFileSource::Destructive) :
SndFileSource::default_writable_flags))); SndFileSource::default_writable_flags)));
if (!defer_peaks) {
if (setup_peakfile (ret, false)) { if (setup_peakfile (ret, false)) {
return boost::shared_ptr<Source>(); return boost::shared_ptr<Source>();
} }
}
if (announce) { if (announce) {
SourceCreated (ret); SourceCreated (ret);
} }