Last active
December 28, 2015 23:19
-
-
Save KAMEDAkyosuke/7577678 to your computer and use it in GitHub Desktop.
AAC のハードウェアエンコーダーをサポートしているかどうかのチェック。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL)isAACHardwareEncoderAvailable | |
{ | |
OSStatus status; | |
UInt32 size;; | |
UInt32 encoderSpecifier = kAudioFormatMPEG4AAC; | |
status = AudioFormatGetPropertyInfo(kAudioFormatProperty_Encoders, | |
sizeof(encoderSpecifier), | |
&encoderSpecifier, | |
&size); | |
check_osstatus(status, @"AudioFormatGetPropertyInfo fail"); | |
if(status != noErr){ | |
return NO; | |
} | |
UInt32 numEncodres = size / sizeof(AudioClassDescription); | |
AudioClassDescription encoderDescriptions[numEncodres]; | |
status = AudioFormatGetProperty(kAudioFormatProperty_Encoders, | |
sizeof(encoderSpecifier), | |
&encoderSpecifier, | |
&size, | |
encoderDescriptions); | |
check_osstatus(status, @"AudioFormatGetProperty fail"); | |
if(status != noErr){ | |
return NO; | |
} | |
for(int i=0; i<numEncodres; ++i){ | |
AudioClassDescription desc = encoderDescriptions[i]; | |
if(desc.mSubType == kAudioFormatMPEG4AAC && | |
desc.mManufacturer == kAppleHardwareAudioCodecManufacturer){ | |
return YES; | |
} | |
} | |
return NO; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment