mirror of https://github.com/OpenTTD/OpenTTD
Remove: [OSX] Support for the pre-10.5 audio/music APIs.
parent
9dd8b3d430
commit
b17ea3de36
|
@ -58,34 +58,10 @@ static void DoSetVolume()
|
||||||
AUGraphGetIndNode(graph, i, &node);
|
AUGraphGetIndNode(graph, i, &node);
|
||||||
|
|
||||||
AudioUnit unit;
|
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 (desc.componentType == kAudioUnitType_Output) {
|
||||||
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) {
|
|
||||||
output_unit = unit;
|
output_unit = unit;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -161,26 +137,9 @@ void MusicDriver_Cocoa::PlaySong(const MusicSongInfo &song)
|
||||||
const char *os_file = OTTD2FS(filename.c_str());
|
const char *os_file = OTTD2FS(filename.c_str());
|
||||||
CFAutoRelease<CFURLRef> url(CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, (const UInt8*)os_file, strlen(os_file), false));
|
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 (MusicSequenceFileLoad(_sequence, url.get(), kMusicSequenceFile_AnyType, 0) != noErr) {
|
||||||
if (MacOSVersionIsAtLeast(10, 5, 0)) {
|
DEBUG(driver, 0, "cocoa_m: Failed to load MIDI file");
|
||||||
if (MusicSequenceFileLoad(_sequence, url.get(), kMusicSequenceFile_AnyType, 0) != noErr) {
|
return;
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Construct audio graph */
|
/* Construct audio graph */
|
||||||
|
|
|
@ -68,49 +68,22 @@ const char *SoundDriver_Cocoa::Start(const char * const *parm)
|
||||||
|
|
||||||
MxInitialize((uint)requestedDesc.mSampleRate);
|
MxInitialize((uint)requestedDesc.mSampleRate);
|
||||||
|
|
||||||
#if defined(__AUDIOCOMPONENT_H__) || defined(HAVE_OSX_107_SDK)
|
/* Locate the default output audio unit */
|
||||||
if (MacOSVersionIsAtLeast(10, 6, 0)) {
|
AudioComponentDescription desc;
|
||||||
/* Locate the default output audio unit */
|
desc.componentType = kAudioUnitType_Output;
|
||||||
AudioComponentDescription desc;
|
desc.componentSubType = kAudioUnitSubType_HALOutput;
|
||||||
desc.componentType = kAudioUnitType_Output;
|
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
|
||||||
desc.componentSubType = kAudioUnitSubType_HALOutput;
|
desc.componentFlags = 0;
|
||||||
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
|
desc.componentFlagsMask = 0;
|
||||||
desc.componentFlags = 0;
|
|
||||||
desc.componentFlagsMask = 0;
|
|
||||||
|
|
||||||
AudioComponent comp = AudioComponentFindNext (nullptr, &desc);
|
AudioComponent comp = AudioComponentFindNext (nullptr, &desc);
|
||||||
if (comp == nullptr) {
|
if (comp == nullptr) {
|
||||||
return "cocoa_s: Failed to start CoreAudio: AudioComponentFindNext returned nullptr";
|
return "cocoa_s: Failed to start CoreAudio: AudioComponentFindNext returned nullptr";
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Open & initialize the default output audio unit */
|
/* Open & initialize the default output audio unit */
|
||||||
if (AudioComponentInstanceNew(comp, &_outputAudioUnit) != noErr) {
|
if (AudioComponentInstanceNew(comp, &_outputAudioUnit) != noErr) {
|
||||||
return "cocoa_s: Failed to start CoreAudio: AudioComponentInstanceNew";
|
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AudioUnitInitialize(_outputAudioUnit) != noErr) {
|
if (AudioUnitInitialize(_outputAudioUnit) != noErr) {
|
||||||
|
@ -157,21 +130,9 @@ void SoundDriver_Cocoa::Stop()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__AUDIOCOMPONENT_H__) || defined(HAVE_OSX_107_SDK)
|
if (AudioComponentInstanceDispose(_outputAudioUnit) != noErr) {
|
||||||
if (MacOSVersionIsAtLeast(10, 6, 0)) {
|
DEBUG(driver, 0, "cocoa_s: Core_CloseAudio: AudioComponentInstanceDispose failed");
|
||||||
if (AudioComponentInstanceDispose(_outputAudioUnit) != noErr) {
|
return;
|
||||||
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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue