arch_specific_objects = [ ]
vst_files = [ 'vst_plugin.cc', 'session_vst.cc' ]
+coreaudio_files = [ 'coreaudio_source.cc' ]
extra_sources = [ ]
if ardour['VST']:
if conf.CheckCHeader('/System/Library/Frameworks/CoreMIDI.framework/Headers/CoreMIDI.h'):
ardour.Append(LINKFLAGS="-framework CoreMIDI")
+if conf.CheckCHeader('/System/Library/Frameworks/AudioToolbox.framework/Headers/ExtendedAudioFile.h'):
+ ardour.Append(LINKFLAGS="-framework AudioToolbox")
+ #extra_sources += coreaudio_files
+
ardour = conf.Finish ()
ardour.Merge ([
Default(libardour)
if env['NLS']:
- i18n (ardour, ardour_files + vst_files, env)
+ i18n (ardour, ardour_files + vst_files + coreaudio_files, env)
env.Alias('tarball', env.Distribute (env['DISTTREE'],
[ 'SConscript', 'i18n.h', 'gettext.h', 'sse_functions.s' ] +
- ardour_files + vst_files +
+ ardour_files + vst_files + coreaudio_files +
glob.glob('po/*.po') + glob.glob('ardour/*.h')))
#ifndef __coreaudio_source_h__
#define __coreaudio_source_h__
-#include <AudioToolbox/AudioFile.h>
+#include <AudioToolbox/ExtendedAudioFile.h>
#include <ardour/source.h>
CoreAudioSource (const XMLNode&);
~CoreAudioSource ();
- jack_nframes_t length() const { return _info.frames; }
+ jack_nframes_t length() const { return _length; }
jack_nframes_t read (Sample *dst, jack_nframes_t start, jack_nframes_t cnt) const;
void mark_for_remove() {} // we never remove external sndfiles
string peak_path(string audio_path);
private:
static string peak_dir;
- AudioFileID sf;
+ ExtAudioFileRef* af_ref;
+ uint16_t n_channels;
+
uint16_t channel;
mutable float *tmpbuf;
mutable jack_nframes_t tmpbufsize;
tmpbuf = 0;
tmpbufsize = 0;
- sf = 0;
+ af_ref = 0;
_name = idstr;
if (err) {
throw failed_constructor();
}
- err = AudioFileOpen (ref, fsCurPerm, 0, sf);
+ err = ExtAudioFileOpen (ref, af_ref);
if (err) {
throw failed_constructor();
}
- if (channel >= _info.channels) {
- error << string_compose(_("CoreAudioSource: file only contains %1 channels; %2 is invalid as a channel number"), _info.channels, channel) << endmsg;
- sf_close (sf);
- sf = 0;
+ if (channel >= n_channels) {
+ error << string_compose(_("CoreAudioSource: file only contains %1 channels; %2 is invalid as a channel number"), n_channels, channel) << endmsg;
+ ExtAudioFileDispose(af_ref);
throw failed_constructor();
}
- _length = _info.frames;
+ int64_t ca_frames;
+ size_t prop_size = sizeof(ca_frames);
+
+ err = ExtAudioFileGetProperty(af_ref, kExtAudioFileProperty_FileLengthFrames,
+ sizeof(ca_frames), &ca_frames);
+ if (err) {
+ throw failed_constructor();
+ }
+ _length = ca_frames;
+
_path = file;
if (build_peak) {
if (initialize_peakfile (false, file)) {
- sf_close (sf);
- sf = 0;
+ ExtAudioFileDispose(af_ref);
throw failed_constructor ();
}
}
{
GoingAway (this); /* EMIT SIGNAL */
- if (sf) {
- sf_close (sf);
+ if (af_ref) {
+ ExtAudioFileDispose(af_ref);
}
if (tmpbuf) {
float *ptr;
uint32_t real_cnt;
- if (sf_seek (sf, (off_t) start, SEEK_SET) < 0) {
- char errbuf[256];
- sf_error_str (0, errbuf, sizeof (errbuf) - 1);
- error << string_compose(_("CoreAudioSource: could not seek to frame %1 within %2 (%3)"), start, _name.substr (1), errbuf) << endmsg;
+ OSStatus err = ExtAudioFileSeek(af_ref, start);
+ if (err) {
+ error << string_compose(_("CoreAudioSource: could not seek to frame %1 within %2"), start, _name.substr (1)) << endmsg;
return 0;
}
- if (_info.channels == 1) {
- jack_nframes_t ret = sf_read_float (sf, dst, cnt);
+ if (n_channels == 1) {
+ uint32_t ioNumber = cnt;
+ err = ExtAudioFileRead(af_ref, &ioNumber, dst);
_read_data_count = cnt * sizeof(float);
- return ret;
+ return ioNumber;
}
- real_cnt = cnt * _info.channels;
+ real_cnt = cnt * n_channels;
{
LockMonitor lm (_tmpbuf_lock, __LINE__, __FILE__);
tmpbuf = new float[tmpbufsize];
}
- nread = sf_read_float (sf, tmpbuf, real_cnt);
+ nread = real_cnt;
+ err = ExtAudioFileRead(af_ext, &nread, tmpbuf);
ptr = tmpbuf + channel;
- nread /= _info.channels;
+ nread /= n_channels;
/* stride through the interleaved data */
for (int32_t n = 0; n < nread; ++n) {
dst[n] = *ptr;
- ptr += _info.channels;
+ ptr += n_channels;
}
}