this repo has no description
at fixPythonPipStalling 154 lines 6.1 kB view raw
1/* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 3 Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 ("Apple") in consideration of your agreement to the following terms, and your 5 use, installation, modification or redistribution of this Apple software 6 constitutes acceptance of these terms. If you do not agree with these terms, 7 please do not use, install, modify or redistribute this Apple software. 8 9 In consideration of your agreement to abide by the following terms, and subject 10 to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 copyrights in this original Apple software (the "Apple Software"), to use, 12 reproduce, modify and redistribute the Apple Software, with or without 13 modifications, in source and/or binary forms; provided that if you redistribute 14 the Apple Software in its entirety and without modifications, you must retain 15 this notice and the following text and disclaimers in all such redistributions of 16 the Apple Software. Neither the name, trademarks, service marks or logos of 17 Apple Computer, Inc. may be used to endorse or promote products derived from the 18 Apple Software without specific prior written permission from Apple. Except as 19 expressly stated in this notice, no other rights or licenses, express or implied, 20 are granted by Apple herein, including but not limited to any patent rights that 21 may be infringed by your derivative works or by other works in which the Apple 22 Software may be incorporated. 23 24 The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 COMBINATION WITH YOUR PRODUCTS. 29 30 IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37*/ 38/*============================================================================= 39 audioformats.cpp 40 41=============================================================================*/ 42 43#include "CAAudioFileFormats.h" 44#include <stdlib.h> 45#include "AFToolsCommon.h" 46 47#if TARGET_OS_WIN32 48 #include <QTML.h> 49#endif 50 51// This program interrogates the AudioFile and AudioFormat API's for information 52// useful in constructing test scripts. It might also be useful as an example 53// of how to use these API's. 54 55void PrintFileFormats() 56{ 57 CAAudioFileFormats *fileFormats = CAAudioFileFormats::Instance(); 58 59 for (int i = 0; i < fileFormats->mNumFileFormats; ++i) { 60 CAAudioFileFormats::FileFormatInfo *ffi = &fileFormats->mFileFormats[i]; 61 char buf[20], extbuf[32]; 62 printf("('%s', '%s'", OSTypeToStr(buf, ffi->mFileTypeID), ffi->GetExtension(0, extbuf, sizeof(extbuf))); 63 64 for (int j = 0; j < ffi->mNumDataFormats; ++j) { 65 CAAudioFileFormats::DataFormatInfo *dfi = &ffi->mDataFormats[j]; 66 if (dfi->mFormatID == kAudioFormatLinearPCM) { 67 for (int k = 0; k < dfi->mNumVariants; ++k) { 68 AudioStreamBasicDescription *asbd = &dfi->mVariants[k]; 69 if (asbd->mFormatFlags & ~(kAudioFormatFlagIsPacked | kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsBigEndian | kAudioFormatFlagIsFloat)) 70 printf("(%08lx/%ld) ", asbd->mFormatFlags, asbd->mBitsPerChannel); 71 else { 72 printf(", '%s", 73 (asbd->mFormatFlags & kAudioFormatFlagIsBigEndian) ? "BE" : "LE"); 74 if (asbd->mFormatFlags & kAudioFormatFlagIsFloat) 75 printf("F"); 76 else 77 printf("%sI", 78 (asbd->mFormatFlags & kAudioFormatFlagIsSignedInteger) ? "" : "U"); 79 printf("%ld'", asbd->mBitsPerChannel); 80 } 81 } 82 } else { 83 printf(", '%s'", OSTypeToStr(buf, dfi->mFormatID)); 84 } 85 } 86 printf("),\n"); 87 } 88} 89 90struct LayoutTag { 91 UInt32 constant; 92 const char *name; 93}; 94 95#define TAG(x) { x, #x }, 96 97static LayoutTag gLayoutTags[] = { 98 TAG(kAudioChannelLayoutTag_Stereo) 99 TAG(kAudioChannelLayoutTag_AAC_Quadraphonic) 100 TAG(kAudioChannelLayoutTag_AAC_4_0) 101 TAG(kAudioChannelLayoutTag_AAC_5_0) 102 TAG(kAudioChannelLayoutTag_AAC_5_1) 103 TAG(kAudioChannelLayoutTag_AAC_6_0) 104 TAG(kAudioChannelLayoutTag_AAC_6_1) 105 TAG(kAudioChannelLayoutTag_AAC_7_0) 106 TAG(kAudioChannelLayoutTag_AAC_7_1) 107 TAG(kAudioChannelLayoutTag_AAC_Octagonal) 108 TAG(kAudioChannelLayoutTag_MPEG_5_0_A) 109 TAG(kAudioChannelLayoutTag_MPEG_5_0_B) 110 TAG(kAudioChannelLayoutTag_MPEG_5_1_A) 111 TAG(kAudioChannelLayoutTag_MPEG_5_1_B) 112 { 0, NULL } // sentinel 113}; 114 115static const char *prefix = "kAudioChannelLayoutTag_"; 116 117void PrintCompatibleChannelLayouts() 118{ 119 int plen = strlen(prefix); 120 for (LayoutTag *tag1 = gLayoutTags; tag1->name != NULL; ++tag1) { 121 AudioChannelLayout layout1 = { tag1->constant, 0, 0 }; 122 printf("\t'%s' : (", tag1->name + plen); 123 int printed = 0; 124 for (LayoutTag *tag2 = gLayoutTags; tag2->name != NULL; ++tag2) { 125 AudioChannelLayout layout2 = { tag2->constant, 0, 0 }; 126 AudioChannelLayout *layouts[] = { &layout1, &layout2 }; 127 128 UInt32 propertySize; 129 OSStatus err = AudioFormatGetPropertyInfo(kAudioFormatProperty_ChannelMap, sizeof(layouts), layouts, &propertySize); 130 if (err == noErr) { 131 SInt32 *map = (SInt32 *)malloc(propertySize); 132 err = AudioFormatGetProperty(kAudioFormatProperty_ChannelMap, sizeof(layouts), layouts, &propertySize, map); 133 if (err == noErr) { 134 if (printed++) printf(", "); 135 printf("'%s'", tag2->name + plen); 136 } 137 } 138 } 139 printf("),\n"); 140 } 141} 142 143int main(int argc, const char *argv[]) 144{ 145 #if TARGET_OS_WIN32 146 InitializeQTML(0L); 147 #endif 148 149 PrintFileFormats(); 150 printf("#######################\n"); 151 PrintCompatibleChannelLayouts(); 152 153 return 0; 154}