this repo has no description
at fixPythonPipStalling 155 lines 6.5 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 CAAudioFileConverter.h 40 41=============================================================================*/ 42 43#ifndef __CAAudioFileConverter_h__ 44#define __CAAudioFileConverter_h__ 45 46/* 47 Compile options: 48 CAAUDIOFILE_PROFILE 49*/ 50 51#if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 52 #include <AudioToolbox/AudioToolbox.h> 53#else 54 #include <AudioToolbox.h> 55#endif 56#include "CAStreamBasicDescription.h" 57#include "CABufferList.h" 58#include "CAHostTimeBase.h" 59#include "CAAudioChannelLayout.h" 60#include "CAAudioFile.h" 61 62class CAAudioFileConverter { 63public: 64 // options for ConversionParameters.flags 65 enum { 66 kOpt_OverwriteOutputFile = 1, 67 kOpt_Verbose = 2, 68 kOpt_CAFTag = 4, // tags encoded CAF files with info about the source file 69 // or restores based on it when decoding 70 kOpt_NoSanitizeOutputFormat = 8 // used internally 71 }; 72 73 struct ConversionParameters { 74 ConversionParameters(); 75 76 UInt32 flags; 77 78 struct { 79 const char * filePath; // POSIX path, UTF-8 80 AudioFileID audioFileID; // or set this to non-zero 81 AudioChannelLayoutTag channelLayoutTag; // 0 to use the one in the file, or default 82 } input; 83 84 struct { 85 const char * filePath; // POSIX path; if null, file is written to same 86 // directory as input file, name generated from 87 // its name with the appropriate filename extension 88 // (fails if file already exists) 89 AudioFileTypeID fileType; 90 CAStreamBasicDescription dataFormat; 91 int channels; // -1 for same number of channels as input 92 SInt32 bitRate; // -1 for default 93 SInt32 codecQuality; // 0-127, -1 for default 94 SInt32 srcQuality; // 0-127, -1 for default 95 SInt32 strategy; // 0-2, -1 for default 96 SInt32 primeMethod; // 0-2, -1 for default 97 AudioChannelLayoutTag channelLayoutTag; // 0 for default 98 } output; 99 100 //UInt32 bufferSize; // [UNIMPLEMENTED] 101 }; 102 103 CAAudioFileConverter(); 104 105 virtual ~CAAudioFileConverter(); 106 107 void ConvertFile(const ConversionParameters &params); 108 virtual bool Progress(SInt64 packetsConverted, SInt64 packetsTotal) { return false; } 109 virtual void GenerateOutputFileName(const char *inputFilePath, 110 const CAStreamBasicDescription &inputFormat, 111 const CAStreamBasicDescription &outputFormat, 112 OSType outputFileType, char *outName); 113 114 const char * GetOutputFileName() { return mOutName; } 115 const CAAudioFile & InputFile() { return mSrcFile; } 116 const CAAudioFile & OutputFile() { return mDestFile; } 117 118 // customization 119 virtual void PrepareConversion() { } 120 virtual void OpenInputFile(); 121 virtual void OpenOutputFile(const CAStreamBasicDescription &srcFormat, const CAStreamBasicDescription &destFormat, FSRef &destFSRef, CAAudioChannelLayout &destFileLayout); 122 virtual void ComputeReadSize(const CAStreamBasicDescription &srcFormat, const CAStreamBasicDescription &destFormat, UInt32 &bytesToRead, UInt32 &framesToRead) { } 123 virtual void BeginConversion() { } 124 virtual void EndConversion() { } 125 virtual bool ShouldTerminateConversion() { return false; } 126 127 bool TaggedEncodingToCAF() const { 128 return (mParams.flags & kOpt_CAFTag) && mDestFormat.mFormatID != kAudioFormatLinearPCM && mParams.output.fileType == kAudioFileCAFType; 129 } 130 bool TaggedDecodingFromCAF() const { 131 return (mParams.flags & kOpt_CAFTag) && mSrcFormat.mFormatID != kAudioFormatLinearPCM; 132 // don't know for sure that the source file is CAF... 133 } 134 135 void WriteCAFInfo(); 136 void ReadCAFInfo(); 137 138protected: 139 void PrintFormats(const CAAudioChannelLayout *origSrcFileLayout); 140 141 ConversionParameters mParams; 142 CAAudioFile mSrcFile; 143 CAAudioFile mDestFile; 144 CAStreamBasicDescription mSrcFormat; // valid after OpenInputFile 145 CAStreamBasicDescription mDestFormat; // valid after OpenOutputFile 146 147private: 148 CABufferList * mReadBuffer; 149 CABufferList * mReadPtrs; 150 151protected: 152 char mOutName[PATH_MAX]; 153}; 154 155#endif // __CAAudioFileConverter_h__