X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=libs%2Fardour%2Fsndfile_helpers.cc;h=b308a74c36cf6ff93f63a540042a2a605822eda7;hb=5952c48a848926edb02b5d630e36cc461c893964;hp=64a05e47340de589ab0c4cdc48bb34ed2c9e53ad;hpb=52089ed9fbce56ea578eb24949c1371739eb108d;p=ardour.git diff --git a/libs/ardour/sndfile_helpers.cc b/libs/ardour/sndfile_helpers.cc index 64a05e4734..b308a74c36 100644 --- a/libs/ardour/sndfile_helpers.cc +++ b/libs/ardour/sndfile_helpers.cc @@ -1,14 +1,11 @@ #include #include +#include + #include #include -#ifdef HAVE_COREAUDIO -#include -#include -#endif // HAVE_COREAUDIO - #include "i18n.h" using std::map; @@ -113,7 +110,7 @@ sndfile_file_ending_from_string (string str) static vector file_endings; if (file_endings.empty()) { - file_endings = internationalize((const char **) sndfile_file_endings_strings); + file_endings = PBD::internationalize((const char **) sndfile_file_endings_strings); } for (int n = 0; sndfile_header_formats_strings[n]; ++n) { @@ -197,101 +194,3 @@ sndfile_minor_format(int format) } } -#ifdef HAVE_COREAUDIO -std::string -CFStringRefToStdString(CFStringRef stringRef) -{ - CFIndex size = - CFStringGetMaximumSizeForEncoding(CFStringGetLength(stringRef) , - kCFStringEncodingASCII); - char *buf = new char[size]; - - std::string result; - - if(CFStringGetCString(stringRef, buf, size, kCFStringEncodingASCII)) { - result = buf; - } - delete [] buf; - return result; -} -#endif // HAVE_COREAUDIO - -bool -get_soundfile_info (string path, SoundFileInfo& _info) -{ -#ifdef HAVE_COREAUDIO - OSStatus err = noErr; - FSRef ref; - ExtAudioFileRef af = 0; - size_t size; - CFStringRef name; - - err = FSPathMakeRef ((UInt8*)path.c_str(), &ref, 0); - if (err != noErr) { - ExtAudioFileDispose (af); - goto libsndfile; - } - - err = ExtAudioFileOpen(&ref, &af); - if (err != noErr) { - ExtAudioFileDispose (af); - goto libsndfile; - } - - AudioStreamBasicDescription absd; - memset(&absd, 0, sizeof(absd)); - size = sizeof(AudioStreamBasicDescription); - err = ExtAudioFileGetProperty(af, - kExtAudioFileProperty_FileDataFormat, &size, &absd); - if (err != noErr) { - ExtAudioFileDispose (af); - goto libsndfile; - } - - _info.samplerate = absd.mSampleRate; - _info.channels = absd.mChannelsPerFrame; - - size = sizeof(_info.length); - err = ExtAudioFileGetProperty(af, kExtAudioFileProperty_FileLengthFrames, &size, &_info.length); - if (err != noErr) { - ExtAudioFileDispose (af); - goto libsndfile; - } - - size = sizeof(CFStringRef); - err = AudioFormatGetProperty( - kAudioFormatProperty_FormatName, sizeof(absd), &absd, &size, &name); - if (err != noErr) { - ExtAudioFileDispose (af); - goto libsndfile; - } - - _info.format_name = CFStringRefToStdString(name); - - ExtAudioFileDispose (af); - return true; - -libsndfile: -#endif // HAVE_COREAUDIO - - SNDFILE *sf; - SF_INFO sf_info; - - sf_info.format = 0; // libsndfile says to clear this before sf_open(). - - if ((sf = sf_open ((char*) path.c_str(), SFM_READ, &sf_info)) < 0) { - return false; - } - - sf_close (sf); - - _info.samplerate = sf_info.samplerate; - _info.channels = sf_info.channels; - _info.length = sf_info.frames; - _info.format_name = string_compose("Format: %1, %2", - sndfile_major_format(sf_info.format), - sndfile_minor_format(sf_info.format)); - - return true; -} -