diff --git a/libs/ardour/ardour/coreaudio_source.h b/libs/ardour/ardour/coreaudio_source.h index 54ccd1080d..394c8af795 100644 --- a/libs/ardour/ardour/coreaudio_source.h +++ b/libs/ardour/ardour/coreaudio_source.h @@ -23,7 +23,7 @@ #include -#include +#include namespace ARDOUR { @@ -45,8 +45,8 @@ class CoreAudioSource : public Source { private: static string peak_dir; - ExtAudioFileRef* af_ref; - uint16_t n_channels; + AudioFileID af; + AudioStreamBasicDescription _info; uint16_t channel; mutable float *tmpbuf; diff --git a/libs/ardour/coreaudio_source.cc b/libs/ardour/coreaudio_source.cc index cf0080c188..9f061e8103 100644 --- a/libs/ardour/coreaudio_source.cc +++ b/libs/ardour/coreaudio_source.cc @@ -79,14 +79,18 @@ CoreAudioSource::init (const string& idstr, bool build_peak) if (err) { throw failed_constructor(); } - err = ExtAudioFileOpen (ref, af_ref); + err = AudioFileOpen (ref, 0, fsRdPerm, &af); if (err) { throw failed_constructor(); } + /* XXX get value for n_channels */ + UInt32 size = sizeof(AudioStreamBasicDescription); + memset (_info, 0, size); + 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); + AudioFileClose(af); throw failed_constructor(); } @@ -103,7 +107,7 @@ CoreAudioSource::init (const string& idstr, bool build_peak) if (build_peak) { if (initialize_peakfile (false, file)) { - ExtAudioFileDispose(*af_ref); + AudioFileClose(af); throw failed_constructor (); } } @@ -143,20 +147,16 @@ CoreAudioSource::read (Sample *dst, jack_nframes_t start, jack_nframes_t cnt) co } AudioBufferList abl; - AudioBuffer ab; - abl.mNumberBuffers = 1; - abl.mBuffers[0] = ab; - ab.mNumberChannels = n_channels; - ab.mDataByteSize = cnt; - ab.mData = dst; - + abl.mBuffers[0].mNumberChannels = n_channels; if (n_channels == 1) { - uint32_t ioNumber = cnt; - err = ExtAudioFileRead(*af_ref, (UInt32*)&ioNumber, &abl); + abl.mBuffers[0].mDataByteSize = cnt * sizeof(float); + abl.mBuffers[0].mData = dst; + nread = cnt; + err = ExtAudioFileRead(*af_ref, (UInt32*)&nread, &abl); _read_data_count = cnt * sizeof(float); - return ioNumber; + return nread; } real_cnt = cnt * n_channels;