summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2020-04-10 23:48:32 +0200
committerMichael Lutz <michi@icosahedron.de>2020-04-12 18:44:43 +0200
commitb17ea3de361a14c9adaabbd576c15cce0cfe5809 (patch)
tree32fc78b504af7f021af9959b12c082627efaba6d
parent9dd8b3d430cc4d5f385b97e03e02fbc9865d069c (diff)
downloadopenttd-b17ea3de361a14c9adaabbd576c15cce0cfe5809.tar.xz
Remove: [OSX] Support for the pre-10.5 audio/music APIs.
-rw-r--r--src/music/cocoa_m.cpp53
-rw-r--r--src/sound/cocoa_s.cpp77
2 files changed, 25 insertions, 105 deletions
diff --git a/src/music/cocoa_m.cpp b/src/music/cocoa_m.cpp
index f9b8969fd..9fec5ba15 100644
--- a/src/music/cocoa_m.cpp
+++ b/src/music/cocoa_m.cpp
@@ -58,34 +58,10 @@ static void DoSetVolume()
AUGraphGetIndNode(graph, i, &node);
AudioUnit unit;
- OSType comp_type = 0;
-
-#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
- }
+ AudioComponentDescription desc;
+ AUGraphNodeInfo(graph, node, &desc, &unit);
- 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 */
diff --git a/src/sound/cocoa_s.cpp b/src/sound/cocoa_s.cpp
index 10fae12a6..cb1bc59e8 100644
--- a/src/sound/cocoa_s.cpp
+++ b/src/sound/cocoa_s.cpp
@@ -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;
-
- 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
+ /* 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";
+ }
+
+ /* 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;
}
}