summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2008-02-27 13:56:14 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2008-02-27 13:56:14 +0000
commit3188ad3ab03fb15b430cc6dc2341a66c90a9c393 (patch)
tree1f1d49f73976b4bb39c298d9e585c2b3c8cb2d49 /libs
parenta969d639864f7c8d3f19aa4bd8f498b4391fb1d8 (diff)
fix up BWF creation; make CoreAudioSource work; add CAImportable; refactor SourceFactory to try sndfile first, CoreAudio second
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@3126 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/SConscript2
-rw-r--r--libs/ardour/ardour/audiofilesource.h2
-rw-r--r--libs/ardour/ardour/caimportable.h48
-rw-r--r--libs/ardour/ardour/coreaudiosource.h6
-rw-r--r--libs/ardour/ardour/sndfilesource.h2
-rw-r--r--libs/ardour/audiofilesource.cc35
-rw-r--r--libs/ardour/caimportable.cc118
-rw-r--r--libs/ardour/coreaudiosource.cc170
-rw-r--r--libs/ardour/playlist.cc1
-rw-r--r--libs/ardour/resampled_source.cc2
-rw-r--r--libs/ardour/session.cc13
-rw-r--r--libs/ardour/sndfilesource.cc52
-rw-r--r--libs/ardour/source_factory.cc80
13 files changed, 353 insertions, 178 deletions
diff --git a/libs/ardour/SConscript b/libs/ardour/SConscript
index a2e4c13db0..dce3432065 100644
--- a/libs/ardour/SConscript
+++ b/libs/ardour/SConscript
@@ -111,7 +111,7 @@ osc_files = [ 'osc.cc' ]
vst_files = [ 'vst_plugin.cc', 'session_vst.cc' ]
lv2_files = [ 'lv2_plugin.cc' ]
audiounit_files = [ 'audio_unit.cc' ]
-coreaudio_files = [ 'coreaudiosource.cc' ]
+coreaudio_files = [ 'coreaudiosource.cc', 'caimportable.cc' ]
extra_sources = [ ]
timefx_sources = [ ]
diff --git a/libs/ardour/ardour/audiofilesource.h b/libs/ardour/ardour/audiofilesource.h
index c339c1cfc6..eb156075b9 100644
--- a/libs/ardour/ardour/audiofilesource.h
+++ b/libs/ardour/ardour/audiofilesource.h
@@ -168,6 +168,8 @@ class AudioFileSource : public AudioSource {
bool removable() const;
bool writable() const { return _flags & Writable; }
+ static Sample* get_interleave_buffer (nframes_t size);
+
private:
Glib::ustring old_peak_path (Glib::ustring audio_path);
Glib::ustring broken_peak_path (Glib::ustring audio_path);
diff --git a/libs/ardour/ardour/caimportable.h b/libs/ardour/ardour/caimportable.h
new file mode 100644
index 0000000000..dc7f5769ae
--- /dev/null
+++ b/libs/ardour/ardour/caimportable.h
@@ -0,0 +1,48 @@
+/*
+ Copyright (C) 2007 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 __ardour_ca_importable_source_h__
+#define __ardour_ca_importable_source_h__
+
+#include <pbd/failed_constructor.h>
+#include <ardour/types.h>
+#include <ardour/importable_source.h>
+
+#include <appleutility/CAAudioFile.h>
+
+namespace ARDOUR {
+
+class CAImportableSource : public ImportableSource {
+ public:
+ CAImportableSource (const std::string& path);
+ virtual ~CAImportableSource();
+
+ nframes_t read (Sample* buffer, nframes_t nframes);
+ uint32_t channels() const;
+ nframes_t length() const;
+ nframes_t samplerate() const;
+ void seek (nframes_t pos);
+
+ protected:
+ mutable CAAudioFile af;
+};
+
+}
+
+#endif /* __ardour_ca_importable_source_h__ */
diff --git a/libs/ardour/ardour/coreaudiosource.h b/libs/ardour/ardour/coreaudiosource.h
index ad21188531..d7282b35bd 100644
--- a/libs/ardour/ardour/coreaudiosource.h
+++ b/libs/ardour/ardour/coreaudiosource.h
@@ -21,7 +21,6 @@
#define __coreaudio_source_h__
#include <appleutility/CAAudioFile.h>
-
#include <ardour/audiofilesource.h>
namespace ARDOUR {
@@ -48,11 +47,8 @@ class CoreAudioSource : public AudioFileSource {
mutable CAAudioFile af;
uint16_t n_channels;
- mutable float *tmpbuf;
- mutable nframes_t tmpbufsize;
- mutable Glib::Mutex _tmpbuf_lock;
-
void init ();
+ int safe_read (Sample*, nframes_t start, nframes_t cnt, AudioBufferList&) const;
};
}; /* namespace ARDOUR */
diff --git a/libs/ardour/ardour/sndfilesource.h b/libs/ardour/ardour/sndfilesource.h
index 54964608ee..dc83fc6ec1 100644
--- a/libs/ardour/ardour/sndfilesource.h
+++ b/libs/ardour/ardour/sndfilesource.h
@@ -102,8 +102,6 @@ class SndFileSource : public AudioFileSource {
void handle_header_position_change ();
static int64_t get_timecode_info (SNDFILE* sf, SF_BROADCAST_INFO* binfo, bool& exists);
-
- static Sample* get_interleave_buffer (nframes_t size);
};
} // namespace ARDOUR
diff --git a/libs/ardour/audiofilesource.cc b/libs/ardour/audiofilesource.cc
index a4a75727a9..0ef9fb2dbc 100644
--- a/libs/ardour/audiofilesource.cc
+++ b/libs/ardour/audiofilesource.cc
@@ -39,6 +39,7 @@
#include <glibmm/miscutils.h>
#include <glibmm/fileutils.h>
+#include <glibmm/thread.h>
#include <ardour/audiofilesource.h>
#include <ardour/sndfile_helpers.h>
@@ -69,6 +70,21 @@ uint64_t AudioFileSource::header_position_offset = 0;
/* XXX maybe this too */
char AudioFileSource::bwf_serial_number[13] = "000000000000";
+struct SizedSampleBuffer {
+ nframes_t size;
+ Sample* buf;
+
+ SizedSampleBuffer (nframes_t sz) : size (sz) {
+ buf = new Sample[size];
+ }
+
+ ~SizedSampleBuffer() {
+ delete [] buf;
+ }
+};
+
+Glib::StaticPrivate<SizedSampleBuffer> thread_interleave_buffer = GLIBMM_STATIC_PRIVATE_INIT;
+
AudioFileSource::AudioFileSource (Session& s, ustring path, Flag flags)
: AudioSource (s, path), _flags (flags),
_channel (0)
@@ -716,3 +732,22 @@ AudioFileSource::mark_immutable ()
_flags = Flag (_flags & ~(Writable|Removable|RemovableIfEmpty|RemoveAtDestroy|CanRename));
}
}
+
+
+Sample*
+AudioFileSource::get_interleave_buffer (nframes_t size)
+{
+ SizedSampleBuffer* ssb;
+
+ if ((ssb = thread_interleave_buffer.get()) == 0) {
+ ssb = new SizedSampleBuffer (size);
+ thread_interleave_buffer.set (ssb);
+ }
+
+ if (ssb->size < size) {
+ ssb = new SizedSampleBuffer (size);
+ thread_interleave_buffer.set (ssb);
+ }
+
+ return ssb->buf;
+}
diff --git a/libs/ardour/caimportable.cc b/libs/ardour/caimportable.cc
new file mode 100644
index 0000000000..229bfa8809
--- /dev/null
+++ b/libs/ardour/caimportable.cc
@@ -0,0 +1,118 @@
+#include <ardour/caimportable.h>
+#include <sndfile.h>
+#include <pbd/error.h>
+
+#include "i18n.h"
+
+using namespace ARDOUR;
+using namespace std;
+using namespace PBD;
+
+CAImportableSource::CAImportableSource (const string& path)
+{
+ try {
+ af.Open (path.c_str());
+
+ CAStreamBasicDescription file_format (af.GetFileDataFormat());
+ CAStreamBasicDescription client_format (file_format);
+
+ /* set canonial form (PCM, native float packed, 32 bit, with the correct number of channels
+ and interleaved (since we plan to deinterleave ourselves)
+ */
+
+ client_format.SetCanonical(client_format.NumberChannels(), true);
+ af.SetClientFormat (client_format);
+
+ } catch (CAXException& cax) {
+ error << string_compose ("CAImportable: %1", cax.mOperation) << endmsg;
+ throw failed_constructor ();
+ }
+
+}
+
+CAImportableSource::~CAImportableSource ()
+{
+}
+
+nframes_t
+CAImportableSource::read (Sample* buffer, nframes_t nframes)
+{
+ nframes_t nread = 0;
+ AudioBufferList abl;
+ nframes_t per_channel;
+ bool at_end = false;
+
+ abl.mNumberBuffers = 1;
+ abl.mBuffers[0].mNumberChannels = channels();
+
+ per_channel = nframes / abl.mBuffers[0].mNumberChannels;
+
+ while (nread < per_channel) {
+
+ UInt32 new_cnt = per_channel - nread;
+
+ abl.mBuffers[0].mDataByteSize = new_cnt * abl.mBuffers[0].mNumberChannels * sizeof(Sample);
+ abl.mBuffers[0].mData = buffer + nread;
+
+ try {
+ af.Read (new_cnt, &abl);
+ } catch (CAXException& cax) {
+ error << string_compose("CAImportable: %1", cax.mOperation);
+ return -1;
+ }
+
+ if (new_cnt == 0) {
+ /* EOF */
+ at_end = true;
+ break;
+ }
+
+ nread += new_cnt;
+ }
+
+ if (!at_end && nread < per_channel) {
+ return 0;
+ } else {
+ return nread * abl.mBuffers[0].mNumberChannels;
+ }
+}
+
+uint
+CAImportableSource::channels () const
+{
+ return af.GetFileDataFormat().NumberChannels();
+}
+
+nframes_t
+CAImportableSource::length () const
+{
+ return af.GetNumberFrames();
+}
+
+nframes_t
+CAImportableSource::samplerate() const
+{
+ CAStreamBasicDescription client_asbd;
+
+ try {
+ client_asbd = af.GetClientDataFormat ();
+ } catch (CAXException& cax) {
+ error << string_compose ("CAImportable: %1", cax.mOperation) << endmsg;
+ return 0.0;
+ }
+
+ return client_asbd.mSampleRate;
+}
+
+void
+CAImportableSource::seek (nframes_t pos)
+{
+ try {
+ af.Seek (pos);
+ } catch (CAXException& cax) {
+ error << string_compose ("CAImportable: %1 to %2", cax.mOperation, pos) << endmsg;
+ }
+}
+
+
+
diff --git a/libs/ardour/coreaudiosource.cc b/libs/ardour/coreaudiosource.cc
index 703225e502..011bcce337 100644
--- a/libs/ardour/coreaudiosource.cc
+++ b/libs/ardour/coreaudiosource.cc
@@ -1,5 +1,6 @@
/*
- Copyright (C) 2006 Paul Davis
+ Copyright (C) 2006 Paul Davis
+ Written by Taybin Rutkin
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
@@ -17,6 +18,8 @@
*/
+#include <algorithm>
+
#include <pbd/error.h>
#include <ardour/coreaudiosource.h>
#include <ardour/utils.h>
@@ -28,6 +31,7 @@
#include <AudioToolbox/AudioFormat.h>
+using namespace std;
using namespace ARDOUR;
using namespace PBD;
@@ -48,18 +52,12 @@ CoreAudioSource::CoreAudioSource (Session& s, const string& path, int chn, Flag
void
CoreAudioSource::init ()
{
- tmpbuf = 0;
- tmpbufsize = 0;
-
- cerr << "CoreAudioSource::init() " << name() << endl;
-
/* note that we temporarily truncated _id at the colon */
try {
af.Open(_path.c_str());
- CAStreamBasicDescription file_asbd (af.GetFileDataFormat());
- n_channels = file_asbd.NumberChannels();
- cerr << "number of channels: " << n_channels << endl;
+ CAStreamBasicDescription file_format (af.GetFileDataFormat());
+ n_channels = file_format.NumberChannels();
if (_channel >= n_channels) {
error << string_compose("CoreAudioSource: file only contains %1 channels; %2 is invalid as a channel number (%3)", n_channels, _channel, name()) << endmsg;
@@ -68,9 +66,15 @@ CoreAudioSource::init ()
_length = af.GetNumberFrames();
- CAStreamBasicDescription client_asbd(file_asbd);
- client_asbd.SetCanonical(client_asbd.NumberChannels(), false);
- af.SetClientFormat (client_asbd);
+ CAStreamBasicDescription client_format (file_format);
+
+ /* set canonial form (PCM, native float packed, 32 bit, with the correct number of channels
+ and interleaved (since we plan to deinterleave ourselves)
+ */
+
+ client_format.SetCanonical(client_format.NumberChannels(), true);
+ af.SetClientFormat (client_format);
+
} catch (CAXException& cax) {
error << string_compose ("CoreAudioSource: %1 (%2)", cax.mOperation, name()) << endmsg;
throw failed_constructor ();
@@ -79,81 +83,117 @@ CoreAudioSource::init ()
CoreAudioSource::~CoreAudioSource ()
{
- cerr << "CoreAudioSource::~CoreAudioSource() " << name() << endl;
GoingAway (); /* EMIT SIGNAL */
-
- if (tmpbuf) {
- delete [] tmpbuf;
- }
-
- cerr << "deletion done" << endl;
}
-nframes_t
-CoreAudioSource::read_unlocked (Sample *dst, nframes_t start, nframes_t cnt) const
+int
+CoreAudioSource::safe_read (Sample* dst, nframes_t start, nframes_t cnt, AudioBufferList& abl) const
{
- try {
- af.Seek (start);
- } catch (CAXException& cax) {
- error << string_compose("CoreAudioSource: %1 to %2 (%3)", cax.mOperation, start, _name.substr (1)) << endmsg;
- return 0;
- }
+ nframes_t nread = 0;
- AudioBufferList abl;
- abl.mNumberBuffers = 1;
- abl.mBuffers[0].mNumberChannels = n_channels;
-
- UInt32 new_cnt = cnt;
- if (n_channels == 1) {
- abl.mBuffers[0].mDataByteSize = cnt * sizeof(Sample);
- abl.mBuffers[0].mData = dst;
+ while (nread < cnt) {
+
+ try {
+ af.Seek (start+nread);
+ } catch (CAXException& cax) {
+ error << string_compose("CoreAudioSource: %1 to %2 (%3)", cax.mOperation, start+nread, _name.substr (1)) << endmsg;
+ return -1;
+ }
+
+ UInt32 new_cnt = cnt - nread;
+
+ abl.mBuffers[0].mDataByteSize = new_cnt * n_channels * sizeof(Sample);
+ abl.mBuffers[0].mData = dst + nread;
+
try {
af.Read (new_cnt, &abl);
} catch (CAXException& cax) {
error << string_compose("CoreAudioSource: %1 (%2)", cax.mOperation, _name);
+ return -1;
}
- _read_data_count = new_cnt * sizeof(float);
- return new_cnt;
- }
-
- UInt32 real_cnt = cnt * n_channels;
- {
- Glib::Mutex::Lock lm (_tmpbuf_lock);
-
- if (tmpbufsize < real_cnt) {
-
- if (tmpbuf) {
- delete [] tmpbuf;
+ if (new_cnt == 0) {
+ /* EOF */
+ if (start+cnt == _length) {
+ /* we really did hit the end */
+ nread = cnt;
}
- tmpbufsize = real_cnt;
- tmpbuf = new float[tmpbufsize];
+ break;
}
- abl.mBuffers[0].mDataByteSize = tmpbufsize * sizeof(Sample);
- abl.mBuffers[0].mData = tmpbuf;
+ nread += new_cnt;
+ }
+
+ if (nread < cnt) {
+ return -1;
+ } else {
+ return 0;
+ }
+}
+
+
+nframes_t
+CoreAudioSource::read_unlocked (Sample *dst, nframes_t start, nframes_t cnt) const
+{
+ nframes_t file_cnt;
+ AudioBufferList abl;
+
+ abl.mNumberBuffers = 1;
+ abl.mBuffers[0].mNumberChannels = n_channels;
+
+ if (start > _length) {
- cerr << "channel: " << _channel << endl;
+ /* read starts beyond end of data, just memset to zero */
- try {
- af.Read (real_cnt, &abl);
- } catch (CAXException& cax) {
- error << string_compose("CoreAudioSource: %1 (%2)", cax.mOperation, _name);
- }
- float *ptr = tmpbuf + _channel;
- real_cnt /= n_channels;
+ file_cnt = 0;
+
+ } else if (start + cnt > _length) {
- /* stride through the interleaved data */
+ /* read ends beyond end of data, read some, memset the rest */
+
+ file_cnt = _length - start;
+
+ } else {
- for (uint32_t n = 0; n < real_cnt; ++n) {
- dst[n] = *ptr;
- ptr += n_channels;
+ /* read is entirely within data */
+
+ file_cnt = cnt;
+ }
+
+ if (file_cnt != cnt) {
+ nframes_t delta = cnt - file_cnt;
+ memset (dst+file_cnt, 0, sizeof (Sample) * delta);
+ }
+
+ if (file_cnt) {
+
+ if (n_channels == 1) {
+ if (safe_read (dst, start, file_cnt, abl) == 0) {
+ _read_data_count = cnt * sizeof (Sample);
+ return cnt;
+ }
+ return 0;
}
}
+ Sample* interleave_buf = get_interleave_buffer (file_cnt * n_channels);
+
+ if (safe_read (interleave_buf, start, file_cnt, abl) != 0) {
+ return 0;
+ }
+
_read_data_count = cnt * sizeof(float);
-
- return real_cnt;
+
+ Sample *ptr = interleave_buf + _channel;
+
+ /* stride through the interleaved data */
+
+ for (uint32_t n = 0; n < file_cnt; ++n) {
+ dst[n] = *ptr;
+ ptr += n_channels;
+ }
+
+ return cnt;
}
float
diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc
index 3bee54babb..b54963cf3c 100644
--- a/libs/ardour/playlist.cc
+++ b/libs/ardour/playlist.cc
@@ -334,7 +334,6 @@ Playlist::release_notifications ()
}
}
-
void
Playlist::notify_modified ()
{
diff --git a/libs/ardour/resampled_source.cc b/libs/ardour/resampled_source.cc
index cdfdee2604..7db917635c 100644
--- a/libs/ardour/resampled_source.cc
+++ b/libs/ardour/resampled_source.cc
@@ -26,7 +26,7 @@
using namespace ARDOUR;
using namespace PBD;
-const uint32_t ResampledImportableSource::blocksize = 4096U;
+const uint32_t ResampledImportableSource::blocksize = 16384U;
ResampledImportableSource::ResampledImportableSource (boost::shared_ptr<ImportableSource> src, nframes_t rate, SrcQuality srcq)
: source (src)
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index ac7789e5db..35eb10ccf0 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -482,7 +482,7 @@ Session::destroy ()
// auditioner.reset ();
-#undef TRACK_DESTRUCTION
+#define TRACK_DESTRUCTION
#ifdef TRACK_DESTRUCTION
cerr << "delete named selections\n";
#endif /* TRACK_DESTRUCTION */
@@ -577,14 +577,19 @@ Session::destroy ()
tmp = i;
++tmp;
+
+ cerr << "Drop refs to " << i->second->name() << endl;
i->second->drop_references ();
+ cerr << "move on\n";
+
i = tmp;
}
-
+
+ cerr << "clear audio sources\n";
audio_sources.clear ();
-
+
#ifdef TRACK_DESTRUCTION
cerr << "delete mix groups\n";
#endif /* TRACK_DESTRUCTION */
@@ -2892,6 +2897,8 @@ Session::remove_source (boost::weak_ptr<Source> src)
return;
}
+ cerr << "remove source for " << source->name() << endl;
+
{
Glib::Mutex::Lock lm (audio_source_lock);
diff --git a/libs/ardour/sndfilesource.cc b/libs/ardour/sndfilesource.cc
index ffd9c8c752..b6f3accd4e 100644
--- a/libs/ardour/sndfilesource.cc
+++ b/libs/ardour/sndfilesource.cc
@@ -25,7 +25,6 @@
#include <sys/stat.h>
#include <glibmm/miscutils.h>
-#include <glibmm/thread.h>
#include <pbd/stacktrace.h>
#include <ardour/sndfilesource.h>
@@ -46,21 +45,6 @@ const AudioFileSource::Flag SndFileSource::default_writable_flags = AudioFileSou
AudioFileSource::Removable|
AudioFileSource::RemovableIfEmpty|
AudioFileSource::CanRename);
-struct SizedSampleBuffer {
- nframes_t size;
- Sample* buf;
-
- SizedSampleBuffer (nframes_t sz) : size (sz) {
- buf = new Sample[size];
- }
-
- ~SizedSampleBuffer() {
- delete [] buf;
- }
-};
-
-Glib::StaticPrivate<SizedSampleBuffer> thread_interleave_buffer = GLIBMM_STATIC_PRIVATE_INIT;
-
SndFileSource::SndFileSource (Session& s, const XMLNode& node)
: AudioFileSource (s, node)
{
@@ -96,7 +80,7 @@ SndFileSource::SndFileSource (Session& s, ustring path, SampleFormat sfmt, Heade
*/
file_is_new = true;
-
+
switch (hf) {
case CAF:
fmt = SF_FORMAT_CAF;
@@ -190,9 +174,8 @@ SndFileSource::SndFileSource (Session& s, ustring path, SampleFormat sfmt, Heade
_flags = Flag (_flags & ~Broadcast);
delete _broadcast_info;
_broadcast_info = 0;
- }
-
- }
+ }
+ }
}
void
@@ -256,7 +239,7 @@ SndFileSource::open ()
set_timeline_position (get_timecode_info (sf, _broadcast_info, timecode_info_exists));
- if (!timecode_info_exists) {
+ if (_length != 0 && !timecode_info_exists) {
delete _broadcast_info;
_broadcast_info = 0;
_flags = Flag (_flags & ~Broadcast);
@@ -328,6 +311,11 @@ SndFileSource::read_unlocked (Sample *dst, nframes_t start, nframes_t cnt) const
file_cnt = cnt;
}
+ if (file_cnt != cnt) {
+ nframes_t delta = cnt - file_cnt;
+ memset (dst+file_cnt, 0, sizeof (Sample) * delta);
+ }
+
if (file_cnt) {
if (sf_seek (sf, (sf_count_t) start, SEEK_SET|SFM_READ) != (sf_count_t) start) {
@@ -344,11 +332,6 @@ SndFileSource::read_unlocked (Sample *dst, nframes_t start, nframes_t cnt) const
}
}
- if (file_cnt != cnt) {
- nframes_t delta = cnt - file_cnt;
- memset (dst+file_cnt, 0, sizeof (Sample) * delta);
- }
-
real_cnt = cnt * _info.channels;
Sample* interleave_buf = get_interleave_buffer (real_cnt);
@@ -908,20 +891,3 @@ SndFileSource::one_of_several_channels () const
return _info.channels > 1;
}
-Sample*
-SndFileSource::get_interleave_buffer (nframes_t size)
-{
- SizedSampleBuffer* ssb;
-
- if ((ssb = thread_interleave_buffer.get()) == 0) {
- ssb = new SizedSampleBuffer (size);
- thread_interleave_buffer.set (ssb);
- }
-
- if (ssb->size < size) {
- ssb = new SizedSampleBuffer (size);
- thread_interleave_buffer.set (ssb);
- }
-
- return ssb->buf;
-}
diff --git a/libs/ardour/source_factory.cc b/libs/ardour/source_factory.cc
index deb7e8b8e2..7942bfa5e0 100644
--- a/libs/ardour/source_factory.cc
+++ b/libs/ardour/source_factory.cc
@@ -30,12 +30,15 @@
#include <ardour/silentfilesource.h>
#include <ardour/configuration.h>
-#undef USE_COREAUDIO_FOR_FILES
+#ifdef HAVE_COREAUDIO
+#define USE_COREAUDIO_FOR_FILES
+#endif
#ifdef USE_COREAUDIO_FOR_FILES
#include <ardour/coreaudiosource.h>
#endif
+
#include "i18n.h"
using namespace ARDOUR;
@@ -73,6 +76,7 @@ peak_thread_work ()
if (!as) {
continue;
}
+
as->setup_peakfile ();
}
}
@@ -121,12 +125,12 @@ SourceFactory::createSilent (Session& s, const XMLNode& node, nframes_t nframes,
return ret;
}
-#ifdef USE_COREAUDIO_FOR_FILES
boost::shared_ptr<Source>
SourceFactory::create (Session& s, const XMLNode& node, bool defer_peaks)
{
try {
- boost::shared_ptr<Source> ret (new CoreAudioSource (s, node));
+
+ boost::shared_ptr<Source> ret (new SndFileSource (s, node));
if (setup_peakfile (ret, defer_peaks)) {
return boost::shared_ptr<Source>();
}
@@ -138,47 +142,34 @@ SourceFactory::create (Session& s, const XMLNode& node, bool defer_peaks)
catch (failed_constructor& err) {
+#ifdef USE_COREAUDIO_FOR_FILES
+
/* this is allowed to throw */
- boost::shared_ptr<Source> ret (new SndFileSource (s, node));
+ boost::shared_ptr<Source> ret (new CoreAudioSource (s, node));
if (setup_peakfile (ret, defer_peaks)) {
return boost::shared_ptr<Source>();
}
ret->check_for_analysis_data_on_disk ();
SourceCreated (ret);
return ret;
- }
-
- return boost::shared_ptr<Source>();
-}
-
#else
+ throw; // rethrow
+#endif
-boost::shared_ptr<Source>
-SourceFactory::create (Session& s, const XMLNode& node, bool defer_peaks)
-{
- /* this is allowed to throw */
-
- boost::shared_ptr<Source> ret (new SndFileSource (s, node));
-
- if (setup_peakfile (ret, defer_peaks)) {
- return boost::shared_ptr<Source>();
}
- ret->check_for_analysis_data_on_disk ();
- SourceCreated (ret);
- return ret;
-}
-#endif // USE_COREAUDIO_FOR_FILES
+ return boost::shared_ptr<Source>(); // keep stupid gcc happy
+}
-#ifdef USE_COREAUDIO_FOR_FILES
boost::shared_ptr<Source>
SourceFactory::createReadable (Session& s, string path, int chn, AudioFileSource::Flag flags, bool announce, bool defer_peaks)
{
if (!(flags & Destructive)) {
try {
- boost::shared_ptr<Source> ret (new CoreAudioSource (s, path, chn, flags));
+
+ boost::shared_ptr<Source> ret (new SndFileSource (s, path, chn, flags));
if (setup_peakfile (ret, defer_peaks)) {
return boost::shared_ptr<Source>();
}
@@ -193,7 +184,9 @@ SourceFactory::createReadable (Session& s, string path, int chn, AudioFileSource
/* this is allowed to throw */
- boost::shared_ptr<Source> ret (new SndFileSource (s, path, chn, flags));
+#ifdef USE_COREAUDIO_FOR_FILES
+
+ boost::shared_ptr<Source> ret (new CoreAudioSource (s, path, chn, flags));
if (setup_peakfile (ret, defer_peaks)) {
return boost::shared_ptr<Source>();
}
@@ -202,46 +195,19 @@ SourceFactory::createReadable (Session& s, string path, int chn, AudioFileSource
SourceCreated (ret);
}
return ret;
+
+#else
+ throw; // rethrow
+#endif
}
} else {
- boost::shared_ptr<Source> ret (new SndFileSource (s, path, chn, flags));
- if (setup_peakfile (ret, defer_peaks)) {
- return boost::shared_ptr<Source>();
- }
- ret->check_for_analysis_data_on_disk ();
- if (announce) {
- SourceCreated (ret);
- }
- return ret;
}
return boost::shared_ptr<Source>();
}
-#else
-
-boost::shared_ptr<Source>
-SourceFactory::createReadable (Session& s, string path, int chn, AudioFileSource::Flag flags, bool announce, bool defer_peaks)
-{
- boost::shared_ptr<Source> ret (new SndFileSource (s, path, chn, flags));
-
- if (setup_peakfile (ret, defer_peaks)) {
- return boost::shared_ptr<Source>();
- }
-
- ret->check_for_analysis_data_on_disk ();
-
- if (announce) {
- SourceCreated (ret);
- }
-
- return ret;
-}
-
-#endif // USE_COREAUDIO_FOR_FILES
-
boost::shared_ptr<Source>
SourceFactory::createWritable (Session& s, std::string path, bool destructive, nframes_t rate, bool announce, bool defer_peaks)
{