1
0
Fork 0

Remove: [OSX] Support for the pre-10.5 audio/music APIs.

pull/8074/head
Michael Lutz 2020-04-10 23:48:32 +02:00
parent 9dd8b3d430
commit b17ea3de36
2 changed files with 23 additions and 103 deletions

View File

@ -58,34 +58,10 @@ static void DoSetVolume()
AUGraphGetIndNode(graph, i, &node);
AudioUnit unit;
OSType comp_type = 0;
AudioComponentDescription desc;
AUGraphNodeInfo(graph, node, &desc, &unit);
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
if (MacOSVersionIsAtLeast(10, 5, 0)) {
/* The 10.6 SDK has changed the function prototype of
* AUGraphNodeInfo. This is a binary compatible change,
* but we need to get the type declaration right or
* risk compilation errors. The header AudioComponent.h
* was introduced in 10.6 so use it to decide which
* type definition to use. */
#if defined(__AUDIOCOMPONENT_H__) || defined(HAVE_OSX_107_SDK)
AudioComponentDescription desc;
#else
ComponentDescription desc;
#endif
AUGraphNodeInfo(graph, node, &desc, &unit);
comp_type = desc.componentType;
} else
#endif
{
#if (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5)
ComponentDescription desc;
AUGraphGetNodeInfo(graph, node, &desc, nullptr, nullptr, &unit);
comp_type = desc.componentType;
#endif
}
if (comp_type == kAudioUnitType_Output) {
if (desc.componentType == kAudioUnitType_Output) {
output_unit = unit;
break;
}
@ -161,26 +137,9 @@ void MusicDriver_Cocoa::PlaySong(const MusicSongInfo &song)
const char *os_file = OTTD2FS(filename.c_str());
CFAutoRelease<CFURLRef> url(CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, (const UInt8*)os_file, strlen(os_file), false));
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
if (MacOSVersionIsAtLeast(10, 5, 0)) {
if (MusicSequenceFileLoad(_sequence, url.get(), kMusicSequenceFile_AnyType, 0) != noErr) {
DEBUG(driver, 0, "cocoa_m: Failed to load MIDI file");
return;
}
} else
#endif
{
#if (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5)
FSRef ref_file;
if (!CFURLGetFSRef(url.get(), &ref_file)) {
DEBUG(driver, 0, "cocoa_m: Failed to make FSRef");
return;
}
if (MusicSequenceLoadSMFWithFlags(_sequence, &ref_file, 0) != noErr) {
DEBUG(driver, 0, "cocoa_m: Failed to load MIDI file old style");
return;
}
#endif
if (MusicSequenceFileLoad(_sequence, url.get(), kMusicSequenceFile_AnyType, 0) != noErr) {
DEBUG(driver, 0, "cocoa_m: Failed to load MIDI file");
return;
}
/* Construct audio graph */

View File

@ -68,49 +68,22 @@ const char *SoundDriver_Cocoa::Start(const char * const *parm)
MxInitialize((uint)requestedDesc.mSampleRate);
#if defined(__AUDIOCOMPONENT_H__) || defined(HAVE_OSX_107_SDK)
if (MacOSVersionIsAtLeast(10, 6, 0)) {
/* Locate the default output audio unit */
AudioComponentDescription desc;
desc.componentType = kAudioUnitType_Output;
desc.componentSubType = kAudioUnitSubType_HALOutput;
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
desc.componentFlags = 0;
desc.componentFlagsMask = 0;
/* Locate the default output audio unit */
AudioComponentDescription desc;
desc.componentType = kAudioUnitType_Output;
desc.componentSubType = kAudioUnitSubType_HALOutput;
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
desc.componentFlags = 0;
desc.componentFlagsMask = 0;
AudioComponent comp = AudioComponentFindNext (nullptr, &desc);
if (comp == nullptr) {
return "cocoa_s: Failed to start CoreAudio: AudioComponentFindNext returned nullptr";
}
AudioComponent comp = AudioComponentFindNext (nullptr, &desc);
if (comp == nullptr) {
return "cocoa_s: Failed to start CoreAudio: AudioComponentFindNext returned nullptr";
}
/* Open & initialize the default output audio unit */
if (AudioComponentInstanceNew(comp, &_outputAudioUnit) != noErr) {
return "cocoa_s: Failed to start CoreAudio: AudioComponentInstanceNew";
}
} else
#endif
{
#if (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6)
/* Locate the default output audio unit */
ComponentDescription desc;
desc.componentType = kAudioUnitType_Output;
desc.componentSubType = kAudioUnitSubType_HALOutput;
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
desc.componentFlags = 0;
desc.componentFlagsMask = 0;
Component comp = FindNextComponent (nullptr, &desc);
if (comp == nullptr) {
return "cocoa_s: Failed to start CoreAudio: FindNextComponent returned nullptr";
}
/* Open & initialize the default output audio unit */
if (OpenAComponent(comp, &_outputAudioUnit) != noErr) {
return "cocoa_s: Failed to start CoreAudio: OpenAComponent";
}
#else
return "cocoa_s: Not supported on this OS X version";
#endif
/* Open & initialize the default output audio unit */
if (AudioComponentInstanceNew(comp, &_outputAudioUnit) != noErr) {
return "cocoa_s: Failed to start CoreAudio: AudioComponentInstanceNew";
}
if (AudioUnitInitialize(_outputAudioUnit) != noErr) {
@ -157,21 +130,9 @@ void SoundDriver_Cocoa::Stop()
return;
}
#if defined(__AUDIOCOMPONENT_H__) || defined(HAVE_OSX_107_SDK)
if (MacOSVersionIsAtLeast(10, 6, 0)) {
if (AudioComponentInstanceDispose(_outputAudioUnit) != noErr) {
DEBUG(driver, 0, "cocoa_s: Core_CloseAudio: AudioComponentInstanceDispose failed");
return;
}
} else
#endif
{
#if (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6)
if (CloseComponent(_outputAudioUnit) != noErr) {
DEBUG(driver, 0, "cocoa_s: Core_CloseAudio: CloseComponent failed");
return;
}
#endif
if (AudioComponentInstanceDispose(_outputAudioUnit) != noErr) {
DEBUG(driver, 0, "cocoa_s: Core_CloseAudio: AudioComponentInstanceDispose failed");
return;
}
}