X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fcoreaudiosource.cc;h=48040952db05520198a126250f18826ea4daf26d;hb=5ada17eba0195d90f0685776251b384efdf5168e;hp=010905d120cc371beaa8437b0e6613a8674bed8c;hpb=5399425f534e2d96d07cf29f427bfa0f39d904b7;p=ardour.git diff --git a/libs/ardour/coreaudiosource.cc b/libs/ardour/coreaudiosource.cc index 010905d120..48040952db 100644 --- a/libs/ardour/coreaudiosource.cc +++ b/libs/ardour/coreaudiosource.cc @@ -25,12 +25,16 @@ #include "ardour/coreaudiosource.h" #include "ardour/utils.h" -#include -#include +#ifdef COREAUDIO105 +#include "CAAudioFile.h" +#else +#include "CAExtAudioFile.h" +#endif +#include "CAStreamBasicDescription.h" #include -#include "i18n.h" +#include "pbd/i18n.h" #include @@ -104,10 +108,16 @@ CoreAudioSource::~CoreAudioSource () { } +void +CoreAudioSource::close () +{ + af.Close (); +} + int -CoreAudioSource::safe_read (Sample* dst, framepos_t start, framecnt_t cnt, AudioBufferList& abl) const +CoreAudioSource::safe_read (Sample* dst, samplepos_t start, samplecnt_t cnt, AudioBufferList& abl) const { - framecnt_t nread = 0; + samplecnt_t nread = 0; while (nread < cnt) { @@ -150,10 +160,10 @@ CoreAudioSource::safe_read (Sample* dst, framepos_t start, framecnt_t cnt, Audio } -framecnt_t -CoreAudioSource::read_unlocked (Sample *dst, framepos_t start, framecnt_t cnt) const +samplecnt_t +CoreAudioSource::read_unlocked (Sample *dst, samplepos_t start, samplecnt_t cnt) const { - framecnt_t file_cnt; + samplecnt_t file_cnt; AudioBufferList abl; abl.mNumberBuffers = 1; @@ -179,7 +189,7 @@ CoreAudioSource::read_unlocked (Sample *dst, framepos_t start, framecnt_t cnt) c } if (file_cnt != cnt) { - frameoffset_t delta = cnt - file_cnt; + sampleoffset_t delta = cnt - file_cnt; memset (dst+file_cnt, 0, sizeof (Sample) * delta); } @@ -203,7 +213,7 @@ CoreAudioSource::read_unlocked (Sample *dst, framepos_t start, framecnt_t cnt) c /* stride through the interleaved data */ - for (framecnt_t n = 0; n < file_cnt; ++n) { + for (samplecnt_t n = 0; n < file_cnt; ++n) { dst[n] = *ptr; ptr += n_channels; } @@ -227,7 +237,7 @@ CoreAudioSource::sample_rate() const } int -CoreAudioSource::update_header (framepos_t, struct tm&, time_t) +CoreAudioSource::update_header (samplepos_t, struct tm&, time_t) { return 0; } @@ -235,12 +245,15 @@ CoreAudioSource::update_header (framepos_t, struct tm&, time_t) int CoreAudioSource::get_soundfile_info (string path, SoundFileInfo& _info, string&) { +#ifdef COREAUDIO105 FSRef ref; +#endif ExtAudioFileRef af = 0; UInt32 size; CFStringRef name; int ret = -1; +#ifdef COREAUDIO105 if (FSPathMakeRef ((UInt8*)path.c_str(), &ref, 0) != noErr) { goto out; } @@ -248,6 +261,15 @@ CoreAudioSource::get_soundfile_info (string path, SoundFileInfo& _info, string&) if (ExtAudioFileOpen(&ref, &af) != noErr) { goto out; } +#else + CFURLRef url = CFURLCreateFromFileSystemRepresentation (kCFAllocatorDefault, (const UInt8*)path.c_str (), strlen (path.c_str ()), false); + OSStatus res = ExtAudioFileOpenURL(url, &af); + if (url) CFRelease (url); + + if (res != noErr) { + goto out; + } +#endif AudioStreamBasicDescription absd; memset(&absd, 0, sizeof(absd)); @@ -305,66 +327,66 @@ CoreAudioSource::get_soundfile_info (string path, SoundFileInfo& _info, string&) } switch (absd.mFormatID) { - case kAudioFormatLinearPCM: - _info.format_name += "PCM"; - break; - - case kAudioFormatAC3: - _info.format_name += "AC3"; - break; - - case kAudioFormat60958AC3: - _info.format_name += "60958 AC3"; - break; - - case kAudioFormatMPEGLayer1: - _info.format_name += "MPEG-1"; - break; - - case kAudioFormatMPEGLayer2: - _info.format_name += "MPEG-2"; - break; - - case kAudioFormatMPEGLayer3: - _info.format_name += "MPEG-3"; - break; - - case kAudioFormatAppleIMA4: - _info.format_name += "IMA-4"; - break; - - case kAudioFormatMPEG4AAC: - _info.format_name += "AAC"; - break; - - case kAudioFormatMPEG4CELP: - _info.format_name += "CELP"; - break; - - case kAudioFormatMPEG4HVXC: - _info.format_name += "HVXC"; - break; - - case kAudioFormatMPEG4TwinVQ: - _info.format_name += "TwinVQ"; - break; - - /* these really shouldn't show up, but we should do something - somewhere else to make sure that doesn't happen. until - that is guaranteed, print something anyway. - */ - - case kAudioFormatTimeCode: - _info.format_name += "timecode"; - break; - - case kAudioFormatMIDIStream: - _info.format_name += "MIDI"; - break; - - case kAudioFormatParameterValueStream: - _info.format_name += "parameter values"; - break; + case kAudioFormatLinearPCM: + _info.format_name += "PCM"; + break; + + case kAudioFormatAC3: + _info.format_name += "AC3"; + break; + + case kAudioFormat60958AC3: + _info.format_name += "60958 AC3"; + break; + + case kAudioFormatMPEGLayer1: + _info.format_name += "MPEG-1"; + break; + + case kAudioFormatMPEGLayer2: + _info.format_name += "MPEG-2"; + break; + + case kAudioFormatMPEGLayer3: + _info.format_name += "MPEG-3"; + break; + + case kAudioFormatAppleIMA4: + _info.format_name += "IMA-4"; + break; + + case kAudioFormatMPEG4AAC: + _info.format_name += "AAC"; + break; + + case kAudioFormatMPEG4CELP: + _info.format_name += "CELP"; + break; + + case kAudioFormatMPEG4HVXC: + _info.format_name += "HVXC"; + break; + + case kAudioFormatMPEG4TwinVQ: + _info.format_name += "TwinVQ"; + break; + + /* these really shouldn't show up, but we should do something + somewhere else to make sure that doesn't happen. until + that is guaranteed, print something anyway. + */ + + case kAudioFormatTimeCode: + _info.format_name += "timecode"; + break; + + case kAudioFormatMIDIStream: + _info.format_name += "MIDI"; + break; + + case kAudioFormatParameterValueStream: + _info.format_name += "parameter values"; + break; } // XXX it would be nice to find a way to get this information if it exists @@ -372,7 +394,7 @@ CoreAudioSource::get_soundfile_info (string path, SoundFileInfo& _info, string&) _info.timecode = 0; ret = 0; - out: +out: ExtAudioFileDispose (af); return ret;