├── SimplePlayer-iOS ├── en.lproj │ └── InfoPlist.strings ├── SimplePlayer-iOS-Prefix.pch ├── SimplePlayer-iOS-Info.plist ├── iPad │ ├── SimplePlayer_iOSAppDelegate_iPad.m │ └── SimplePlayer_iOSAppDelegate_iPad.h ├── iPhone │ ├── SimplePlayer_iOSAppDelegate_iPhone.m │ ├── SimplePlayer_iOSAppDelegate_iPhone.h │ └── SimplePlayer_iOSAppDelegate_iPhone.mm ├── main.m ├── SimplePlayer_iOSAppDelegate.m └── SimplePlayer_iOSAppDelegate.h ├── Configs ├── Release.xcconfig ├── Debug.xcconfig └── Base.xcconfig ├── ThirdParty └── PublicUtility │ ├── CAMath.h │ ├── CAAtomic.h │ ├── CAAutoDisposer.h │ ├── CADebugMacros.h │ ├── CADebugPrintf.h │ ├── CADebugMacros.cpp │ └── CADebugPrintf.cpp ├── SFBAudioEngine.xcodeproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── indragie.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── indragie.xcuserdatad │ └── xcschemes │ ├── xcschememanagement.plist │ ├── SFBAudioEngine.xcscheme │ ├── SFBAudioEngine.framework.xcscheme │ ├── SimplePlayer.xcscheme │ └── SimplePlayer-iOS.xcscheme ├── SimplePlayer ├── main.m ├── SimplePlayerAppDelegate.h ├── SimplePlayer-Info.plist ├── PlayerWindowController.h └── SimplePlayerAppDelegate.mm ├── .gitignore ├── Info.plist ├── COPYING ├── CreateStringForOSType.h ├── Metadata ├── Base64Utilities.h ├── SetID3v1TagFromMetadata.cpp ├── TagLibStringUtilities.h ├── AddTagToDictionary.h ├── SetTagFromMetadata.h ├── SetAPETagFromMetadata.h ├── SetID3v2TagFromMetadata.h ├── SetXiphCommentFromMetadata.h ├── AddAudioPropertiesToDictionary.h ├── AddAPETagToDictionary.h ├── AddID3v2TagToDictionary.h ├── AddXiphCommentToDictionary.h ├── CFDictionaryUtilities.h ├── AddID3v1TagToDictionary.cpp ├── AddID3v1TagToDictionary.h ├── SetID3v1TagFromMetadata.h ├── AddAudioPropertiesToDictionary.cpp ├── SetTagFromMetadata.cpp ├── AddTagToDictionary.cpp ├── MODMetadata.h ├── TrueAudioMetadata.h ├── MP4Metadata.h ├── OggSpeexMetadata.h ├── MP3Metadata.h ├── AIFFMetadata.h ├── WAVEMetadata.h ├── MonkeysAudioMetadata.h ├── WavPackMetadata.h ├── OggFLACMetadata.h ├── MusepackMetadata.h ├── FLACMetadata.h ├── OggVorbisMetadata.h ├── TagLibStringUtilities.cpp └── CFDictionaryUtilities.cpp ├── CreateDisplayNameForURL.h ├── DeallocateABL.h ├── CreateStringForOSType.cpp ├── ChannelLayoutsAreEqual.h ├── AllocateABL.h ├── DeallocateABL.cpp ├── Logger+NSOverloads.mm ├── CreateChannelLayout.h ├── Semaphore.h ├── CFErrorUtilities.h ├── README.md ├── Converter ├── AudioConverter.cpp ├── AudioDitherer.h ├── AudioConverter.h └── AudioDitherer.cpp ├── ChannelLayoutsAreEqual.cpp ├── Guard.h ├── Input ├── FileInputSource.h ├── InMemoryFileInputSource.h ├── MemoryMappedFileInputSource.h ├── HTTPInputSource.h └── InputSource.cpp ├── AllocateABL.cpp ├── CreateDisplayNameForURL.cpp ├── Player ├── DecoderStateData.h └── DecoderStateData.cpp ├── Mutex.h ├── Decoders ├── CoreAudioDecoder.h ├── MonkeysAudioDecoder.h └── MODDecoder.h └── Semaphore.cpp /SimplePlayer-iOS/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Base.xcconfig" 2 | 3 | DEBUG_INFORMATION_FORMAT = dwarf-with-dsym 4 | -------------------------------------------------------------------------------- /ThirdParty/PublicUtility/CAMath.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonoramac/SFBAudioEngine/HEAD/ThirdParty/PublicUtility/CAMath.h -------------------------------------------------------------------------------- /ThirdParty/PublicUtility/CAAtomic.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonoramac/SFBAudioEngine/HEAD/ThirdParty/PublicUtility/CAAtomic.h -------------------------------------------------------------------------------- /ThirdParty/PublicUtility/CAAutoDisposer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonoramac/SFBAudioEngine/HEAD/ThirdParty/PublicUtility/CAAutoDisposer.h -------------------------------------------------------------------------------- /ThirdParty/PublicUtility/CADebugMacros.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonoramac/SFBAudioEngine/HEAD/ThirdParty/PublicUtility/CADebugMacros.h -------------------------------------------------------------------------------- /ThirdParty/PublicUtility/CADebugPrintf.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonoramac/SFBAudioEngine/HEAD/ThirdParty/PublicUtility/CADebugPrintf.h -------------------------------------------------------------------------------- /ThirdParty/PublicUtility/CADebugMacros.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonoramac/SFBAudioEngine/HEAD/ThirdParty/PublicUtility/CADebugMacros.cpp -------------------------------------------------------------------------------- /ThirdParty/PublicUtility/CADebugPrintf.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonoramac/SFBAudioEngine/HEAD/ThirdParty/PublicUtility/CADebugPrintf.cpp -------------------------------------------------------------------------------- /SFBAudioEngine.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SFBAudioEngine.xcodeproj/project.xcworkspace/xcuserdata/indragie.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonoramac/SFBAudioEngine/HEAD/SFBAudioEngine.xcodeproj/project.xcworkspace/xcuserdata/indragie.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Base.xcconfig" 2 | 3 | ONLY_ACTIVE_ARCH = YES 4 | 5 | COPY_PHASE_STRIP = NO 6 | 7 | GCC_ENABLE_FIX_AND_CONTINUE = YES 8 | GCC_OPTIMIZATION_LEVEL = 0 9 | GCC_PREPROCESSOR_DEFINITIONS = DEBUG=1 10 | 11 | GCC_WARN_UNINITIALIZED_AUTOS = NO 12 | -------------------------------------------------------------------------------- /SimplePlayer/main.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 Stephen F. Booth 3 | * All Rights Reserved 4 | */ 5 | 6 | #import 7 | 8 | int main(int argc, char *argv[]) 9 | { 10 | return NSApplicationMain(argc, (const char **) argv); 11 | } 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | build/* 3 | *.pbxuser 4 | !default.pbxuser 5 | *.mode1v3 6 | !default.mode1v3 7 | *.mode2v3 8 | !default.mode2v3 9 | *.perspectivev3 10 | !default.perspectivev3 11 | *.xcworkspace 12 | !default.xcworkspace 13 | xcuserdata 14 | profile 15 | *.moved-aside 16 | -------------------------------------------------------------------------------- /SimplePlayer-iOS/SimplePlayer-iOS-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'SimplePlayer-iOS' target in the 'SimplePlayer-iOS' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_3_0 8 | #warning "This project uses features only available in iPhone SDK 3.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | -------------------------------------------------------------------------------- /Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | org.sbooth.AudioEngine 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | FMWK 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | sfb! 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /SimplePlayer/SimplePlayerAppDelegate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 Stephen F. Booth 3 | * All Rights Reserved 4 | */ 5 | 6 | #import 7 | 8 | @class PlayerWindowController; 9 | 10 | @interface SimplePlayerAppDelegate : NSObject 11 | { 12 | @private 13 | PlayerWindowController *_playerWindowController; 14 | NSWindow *_openURLPanel; 15 | NSTextField *_openURLPanelTextField; 16 | } 17 | 18 | @property (assign) IBOutlet PlayerWindowController * playerWindowController; 19 | @property (assign) IBOutlet NSWindow * openURLPanel; 20 | @property (assign) IBOutlet NSTextField * openURLPanelTextField; 21 | 22 | - (IBAction) openFile:(id)sender; 23 | - (IBAction) openURL:(id)sender; 24 | 25 | - (IBAction) openURLPanelOpenAction:(id)sender; 26 | - (IBAction) openURLPanelCancelAction:(id)sender; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /SimplePlayer/SimplePlayer-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | org.sbooth.AudioEngine.SimplePlayer 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | APPL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | LSMinimumSystemVersion 22 | ${MACOSX_DEPLOYMENT_TARGET} 23 | NSMainNibFile 24 | MainMenu 25 | NSPrincipalClass 26 | NSApplication 27 | 28 | 29 | -------------------------------------------------------------------------------- /SimplePlayer/PlayerWindowController.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 Stephen F. Booth 3 | * All Rights Reserved 4 | */ 5 | 6 | #import 7 | 8 | @interface PlayerWindowController : NSWindowController 9 | { 10 | @private 11 | void *_player; // An instance of AudioPlayer 12 | NSTimer *_uiTimer; // User interface update timer 13 | 14 | NSSlider *_slider; // UI elements 15 | NSTextField *_elapsed; 16 | NSTextField *_remaining; 17 | NSButton *_playButton; 18 | NSButton *_forwardButton; 19 | NSButton *_backwardButton; 20 | } 21 | 22 | // IB properties 23 | @property (assign) IBOutlet NSSlider * slider; 24 | @property (assign) IBOutlet NSTextField * elapsed; 25 | @property (assign) IBOutlet NSTextField * remaining; 26 | @property (assign) IBOutlet NSButton * playButton; 27 | @property (assign) IBOutlet NSButton * forwardButton; 28 | @property (assign) IBOutlet NSButton * backwardButton; 29 | 30 | // Action methods 31 | - (IBAction) playPause:(id)sender; 32 | 33 | - (IBAction) seekForward:(id)sender; 34 | - (IBAction) seekBackward:(id)sender; 35 | 36 | - (IBAction) seek:(id)sender; 37 | 38 | // Attempt to play the specified file- returns YES if successful 39 | - (BOOL) playURL:(NSURL *)url; 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /Configs/Base.xcconfig: -------------------------------------------------------------------------------- 1 | ARCHS = i386 x86_64 2 | MACOSX_DEPLOYMENT_TARGET = 10.6 3 | 4 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0 5 | GCC_C_LANGUAGE_STANDARD = gnu99 6 | CLANG_CXX_LANGUAGE_STANDARD = gnu++11 7 | 8 | ALWAYS_SEARCH_USER_PATHS = NO 9 | 10 | GCC_ENABLE_PASCAL_STRINGS = NO 11 | 12 | GCC_WARN_CHECK_SWITCH_STATEMENTS = YES 13 | GCC_WARN_SHADOW = YES 14 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES 15 | GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES 16 | GCC_WARN_ABOUT_RETURN_TYPE = YES 17 | GCC_WARN_MISSING_PARENTHESES = YES 18 | GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES 19 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES 20 | GCC_WARN_ABOUT_MISSING_NEWLINE = YES 21 | GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES 22 | GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES 23 | GCC_WARN_SIGN_COMPARE = YES 24 | GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES 25 | GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES 26 | GCC_WARN_UNDECLARED_SELECTOR = YES 27 | GCC_WARN_UNINITIALIZED_AUTOS = YES 28 | GCC_WARN_UNKNOWN_PRAGMAS = YES 29 | GCC_WARN_UNUSED_FUNCTION = YES 30 | GCC_WARN_UNUSED_LABEL = YES 31 | GCC_WARN_UNUSED_PARAMETER = YES 32 | GCC_WARN_UNUSED_VALUE = YES 33 | GCC_WARN_UNUSED_VARIABLE = YES 34 | 35 | // TODO: Enable this warning 36 | //CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES 37 | -------------------------------------------------------------------------------- /SFBAudioEngine.xcodeproj/xcuserdata/indragie.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | SFBAudioEngine.framework.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | SFBAudioEngine.xcscheme 13 | 14 | orderHint 15 | 2 16 | 17 | SimplePlayer-iOS.xcscheme 18 | 19 | orderHint 20 | 3 21 | 22 | SimplePlayer.xcscheme 23 | 24 | orderHint 25 | 1 26 | 27 | 28 | SuppressBuildableAutocreation 29 | 30 | 3252E83A10CC9E4500F1AA23 31 | 32 | primary 33 | 34 | 35 | 32AEB26F1409AC30001F9A60 36 | 37 | primary 38 | 39 | 40 | 32AEB3031409BE48001F9A60 41 | 42 | primary 43 | 44 | 45 | 32C212D41091116D00BA2493 46 | 47 | primary 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Stephen F. Booth 2 | All Rights Reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | - Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | - Neither the name of Stephen F. Booth nor the names of its 14 | contributors may be used to endorse or promote products derived 15 | from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /SimplePlayer-iOS/SimplePlayer-iOS-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFile 12 | 13 | CFBundleIdentifier 14 | org.sbooth.${PRODUCT_NAME:rfc1034identifier} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | 1.0 23 | CFBundleSignature 24 | ???? 25 | CFBundleVersion 26 | 1.0 27 | LSRequiresIPhoneOS 28 | 29 | NSMainNibFile 30 | MainWindow_iPhone 31 | NSMainNibFile~ipad 32 | MainWindow_iPad 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /CreateStringForOSType.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | 35 | CFStringRef CreateStringForOSType(OSType osType); 36 | -------------------------------------------------------------------------------- /SimplePlayer-iOS/iPad/SimplePlayer_iOSAppDelegate_iPad.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #import "SimplePlayer_iOSAppDelegate_iPad.h" 32 | 33 | @implementation SimplePlayer_iOSAppDelegate_iPad 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /SimplePlayer-iOS/iPhone/SimplePlayer_iOSAppDelegate_iPhone.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #import "SimplePlayer_iOSAppDelegate_iPhone.h" 32 | 33 | @implementation SimplePlayer_iOSAppDelegate_iPhone 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /Metadata/Base64Utilities.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | 35 | namespace TagLib { 36 | ByteVector EncodeBase64(const ByteVector& input); 37 | ByteVector DecodeBase64(const ByteVector& input); 38 | } 39 | -------------------------------------------------------------------------------- /SimplePlayer-iOS/iPad/SimplePlayer_iOSAppDelegate_iPad.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #import 32 | #import "SimplePlayer_iOSAppDelegate.h" 33 | 34 | @interface SimplePlayer_iOSAppDelegate_iPad : SimplePlayer_iOSAppDelegate 35 | {} 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /SimplePlayer-iOS/iPhone/SimplePlayer_iOSAppDelegate_iPhone.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #import 32 | #import "SimplePlayer_iOSAppDelegate.h" 33 | 34 | @interface SimplePlayer_iOSAppDelegate_iPhone : SimplePlayer_iOSAppDelegate 35 | {} 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /SimplePlayer-iOS/iPhone/SimplePlayer_iOSAppDelegate_iPhone.mm: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #import "SimplePlayer_iOSAppDelegate_iPhone.h" 32 | 33 | @implementation SimplePlayer_iOSAppDelegate_iPhone 34 | 35 | - (void) dealloc 36 | { 37 | [super dealloc]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /SimplePlayer-iOS/main.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #import 32 | 33 | int main(int argc, char *argv[]) 34 | { 35 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 36 | int retVal = UIApplicationMain(argc, argv, nil, nil); 37 | [pool release]; 38 | return retVal; 39 | } 40 | -------------------------------------------------------------------------------- /CreateDisplayNameForURL.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | 35 | // ======================================== 36 | // Get the localized display name for a URL 37 | // ======================================== 38 | CFStringRef CreateDisplayNameForURL(CFURLRef url); 39 | -------------------------------------------------------------------------------- /DeallocateABL.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | 35 | // ======================================== 36 | // Utility function for deallocating an AudioBufferList struct 37 | // ======================================== 38 | AudioBufferList * DeallocateABL(AudioBufferList *bufferList); 39 | -------------------------------------------------------------------------------- /CreateStringForOSType.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #include "CreateStringForOSType.h" 32 | 33 | CFStringRef CreateStringForOSType(OSType osType) 34 | { 35 | unsigned char formatID [4]; 36 | *(UInt32 *)formatID = OSSwapHostToBigInt32(osType); 37 | 38 | return CFStringCreateWithFormat(kCFAllocatorDefault, nullptr, CFSTR("%.4s"), formatID); 39 | } 40 | -------------------------------------------------------------------------------- /ChannelLayoutsAreEqual.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | 35 | // ======================================== 36 | // Utility function for determining if two AudioChannelLayouts are equal 37 | // ======================================== 38 | bool ChannelLayoutsAreEqual(const AudioChannelLayout *lhs, const AudioChannelLayout *rhs); 39 | -------------------------------------------------------------------------------- /Metadata/SetID3v1TagFromMetadata.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #include "AudioMetadata.h" 32 | #include "SetID3v1TagFromMetadata.h" 33 | #include "SetTagFromMetadata.h" 34 | 35 | bool 36 | SetID3v1TagFromMetadata(const AudioMetadata& metadata, TagLib::ID3v1::Tag *tag) 37 | { 38 | // TagLib::ID3v1::Tag has no additonal functionality over TagLib::Tag 39 | return SetTagFromMetadata(metadata, tag); 40 | } 41 | -------------------------------------------------------------------------------- /Metadata/TagLibStringUtilities.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | #include 35 | 36 | namespace TagLib { 37 | String StringFromCFString(CFStringRef s); 38 | 39 | // Does nothing if value is TagLib::String::null 40 | void AddStringToCFDictionary(CFMutableDictionaryRef d, CFStringRef key, String value); 41 | } 42 | -------------------------------------------------------------------------------- /Metadata/AddTagToDictionary.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | #include 35 | 36 | // ======================================== 37 | // Add the metadata specified in the TagLib::Tag instance to dictionary 38 | // ======================================== 39 | bool AddTagToDictionary(CFMutableDictionaryRef dictionary, const TagLib::Tag *tag); 40 | -------------------------------------------------------------------------------- /Metadata/SetTagFromMetadata.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | #include 35 | 36 | class AudioMetadata; 37 | 38 | // ======================================== 39 | // Fill in a Tag from the specified AudioMetadata 40 | // ======================================== 41 | bool SetTagFromMetadata(const AudioMetadata& metadata, TagLib::Tag *tag); 42 | -------------------------------------------------------------------------------- /Metadata/SetAPETagFromMetadata.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | #include 35 | 36 | class AudioMetadata; 37 | 38 | // ======================================== 39 | // Fill in an APE tag from the specified AudioMetadata 40 | // ======================================== 41 | bool SetAPETagFromMetadata(const AudioMetadata& metadata, TagLib::APE::Tag *tag, bool setAlbumArt = true); 42 | -------------------------------------------------------------------------------- /Metadata/SetID3v2TagFromMetadata.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | #include 35 | 36 | class AudioMetadata; 37 | 38 | // ======================================== 39 | // Fill in an ID3v2 tag from the specified AudioMetadata 40 | // ======================================== 41 | bool SetID3v2TagFromMetadata(const AudioMetadata& metadata, TagLib::ID3v2::Tag *tag, bool setAlbumArt = true); 42 | -------------------------------------------------------------------------------- /Metadata/SetXiphCommentFromMetadata.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | #include 35 | 36 | class AudioMetadata; 37 | 38 | // ======================================== 39 | // Fill in a Xiph comment from the specified AudioMetadata 40 | // ======================================== 41 | bool SetXiphCommentFromMetadata(const AudioMetadata& metadata, TagLib::Ogg::XiphComment *tag, bool setAlbumArt = true); 42 | -------------------------------------------------------------------------------- /AllocateABL.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | 35 | // ======================================== 36 | // Utility function for allocating an AudioBufferList struct 37 | // ======================================== 38 | AudioBufferList * AllocateABL(const AudioStreamBasicDescription& format, UInt32 capacityFrames); 39 | AudioBufferList * AllocateABL(UInt32 channelsPerFrame, UInt32 bytesPerFrame, bool interleaved, UInt32 capacityFrames); 40 | -------------------------------------------------------------------------------- /Metadata/AddAudioPropertiesToDictionary.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | #include 35 | 36 | class AudioMetadata; 37 | 38 | // ======================================== 39 | // Add the properties specified in the AudioProperties instance to dictionary 40 | // ======================================== 41 | bool AddAudioPropertiesToDictionary(CFMutableDictionaryRef dictionary, const TagLib::AudioProperties *properties); 42 | -------------------------------------------------------------------------------- /Metadata/AddAPETagToDictionary.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | class AttachedPicture; 38 | 39 | // ======================================== 40 | // Add the metadata specified in the APE::Tag instance to dictionary 41 | // ======================================== 42 | bool AddAPETagToDictionary(CFMutableDictionaryRef dictionary, std::vector& attachedPictures, const TagLib::APE::Tag *tag); 43 | -------------------------------------------------------------------------------- /DeallocateABL.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #include 32 | #include 33 | 34 | #include "DeallocateABL.h" 35 | 36 | AudioBufferList * 37 | DeallocateABL(AudioBufferList *bufferList) 38 | { 39 | assert(nullptr != bufferList); 40 | 41 | for(UInt32 bufferIndex = 0; bufferIndex < bufferList->mNumberBuffers; ++bufferIndex) 42 | free(bufferList->mBuffers[bufferIndex].mData), bufferList->mBuffers[bufferIndex].mData = nullptr; 43 | 44 | free(bufferList), bufferList = nullptr; 45 | 46 | return nullptr; 47 | } 48 | -------------------------------------------------------------------------------- /Metadata/AddID3v2TagToDictionary.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | class AttachedPicture; 38 | 39 | // ======================================== 40 | // Add the metadata specified in the ID3v2::Tag instance to dictionary 41 | // ======================================== 42 | bool AddID3v2TagToDictionary(CFMutableDictionaryRef dictionary, std::vector& attachedPictures, const TagLib::ID3v2::Tag *tag); 43 | -------------------------------------------------------------------------------- /Metadata/AddXiphCommentToDictionary.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | class AttachedPicture; 38 | 39 | // ======================================== 40 | // Add the metadata specified in the Ogg::XiphComment instance to dictionary 41 | // ======================================== 42 | bool AddXiphCommentToDictionary(CFMutableDictionaryRef dictionary, std::vector& attachedPictures, const TagLib::Ogg::XiphComment *tag); 43 | -------------------------------------------------------------------------------- /Logger+NSOverloads.mm: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #include "Logger.h" 32 | 33 | std::ostream& operator<<(std::ostream& out, NSString *s) 34 | { 35 | out << (CFStringRef)s; 36 | return out; 37 | } 38 | 39 | std::ostream& operator<<(std::ostream& out, NSNumber *n) 40 | { 41 | out << (CFNumberRef)n; 42 | return out; 43 | } 44 | 45 | std::ostream& operator<<(std::ostream& out, NSURL *u) 46 | { 47 | out << (CFURLRef)u; 48 | return out; 49 | } 50 | 51 | std::ostream& operator<<(std::ostream& out, NSError *e) 52 | { 53 | out << (CFErrorRef)e; 54 | return out; 55 | } 56 | 57 | -------------------------------------------------------------------------------- /Metadata/CFDictionaryUtilities.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | 35 | void AddIntToDictionary(CFMutableDictionaryRef d, CFStringRef key, int value); 36 | void AddIntToDictionaryAsString(CFMutableDictionaryRef d, CFStringRef key, int value); 37 | 38 | void AddLongLongToDictionary(CFMutableDictionaryRef d, CFStringRef key, long long value); 39 | 40 | void AddFloatToDictionary(CFMutableDictionaryRef d, CFStringRef key, float value); 41 | void AddDoubleToDictionary(CFMutableDictionaryRef d, CFStringRef key, double value); 42 | -------------------------------------------------------------------------------- /Metadata/AddID3v1TagToDictionary.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #include "AddID3v1TagToDictionary.h" 32 | #include "AddTagToDictionary.h" 33 | 34 | bool 35 | AddID3v1TagToDictionary(CFMutableDictionaryRef dictionary, const TagLib::ID3v1::Tag *tag) 36 | { 37 | // ID3v1 tags are only supposed to contain characters in ISO 8859-1 format, but that isn't always the case 38 | // AddTagToDictionary assumes UTF-8, so everything should work properly 39 | // Currently TagLib::ID3v1::Tag doesn't implement any more functionality than TagLib::Tag 40 | return AddTagToDictionary(dictionary, tag); 41 | } 42 | -------------------------------------------------------------------------------- /CreateChannelLayout.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | 35 | size_t GetChannelLayoutSize(const AudioChannelLayout *layout); 36 | 37 | AudioChannelLayout * CreateChannelLayout(UInt32 numberChannelDescriptions = 0); 38 | AudioChannelLayout * CreateChannelLayoutWithTag(AudioChannelLayoutTag layoutTag); 39 | AudioChannelLayout * CreateChannelLayoutWithBitmap(UInt32 channelBitmap); 40 | 41 | AudioChannelLayout * CopyChannelLayout(const AudioChannelLayout *rhs); 42 | 43 | AudioChannelLayout * CreateDefaultAudioChannelLayout(UInt32 channelsPerFrame); 44 | -------------------------------------------------------------------------------- /Semaphore.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | 35 | // ======================================== 36 | // A wrapper around a mach semaphore 37 | // ======================================== 38 | class Semaphore 39 | { 40 | public: 41 | Semaphore(); 42 | ~Semaphore(); 43 | 44 | Semaphore(const Semaphore& rhs) = delete; 45 | Semaphore& operator=(const Semaphore& rhs) = delete; 46 | 47 | bool Signal(); 48 | bool SignalAll(); 49 | 50 | bool Wait(); 51 | bool TimedWait(mach_timespec_t duration); 52 | 53 | private: 54 | semaphore_t mSemaphore; 55 | }; 56 | -------------------------------------------------------------------------------- /CFErrorUtilities.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | 35 | // ======================================== 36 | // Utility functions simplifying the boilerplate creation of CFErrors 37 | // ======================================== 38 | CFErrorRef CreateError(CFStringRef domain, CFIndex code, CFStringRef description, CFStringRef failureReason, CFStringRef recoverySuggestion); 39 | CFErrorRef CreateErrorForURL(CFStringRef domain, CFIndex code, CFStringRef descriptionFormatStringForURL, CFURLRef url, CFStringRef failureReason, CFStringRef recoverySuggestion); 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SFBAudioEngine is a set of C++ classes enabling applications to easily play audio in the following formats: 2 | 3 | * WAVE 4 | * AIFF 5 | * Apple Lossless 6 | * AAC 7 | * FLAC 8 | * MP3 9 | * Musepack 10 | * WavePack 11 | * Ogg Vorbis 12 | * Monkey's Audio 13 | * Ogg Speex 14 | * True Audio 15 | * All other formats supported natively by Core Audio 16 | 17 | In addition to playback, SFBAudioEngine supports reading and writing of metadata for most supported formats. 18 | 19 | SFBAudioEngine uses C++11 language features (such as delegated constructors and range-based for), but not C++11 STL features (such as std::shared_ptr). This means that clang must be used to compile SFBAudioEngine and any application using it, but either GNU's libstdc++ or clang's libc++ may be used provided that SFBAudioEngine's dependencies are compiled using the same library. 20 | 21 | A command line audio player using SFBAudioEngine is as simple as: 22 | 23 | #include 24 | 25 | #include "SFBAudioEngine/AudioDecoder.h" 26 | #include "SFBAudioEngine/AudioPlayer.h" 27 | 28 | #include 29 | 30 | int main(int argc, char *argv []) 31 | { 32 | if(1 == argc) { 33 | printf("Usage: %s file [file ...]\n", argv[0]); 34 | return EXIT_FAILURE; 35 | } 36 | 37 | AudioPlayer player; 38 | 39 | while(0 < --argc) { 40 | const char *path = *++argv; 41 | CFURLRef fileURL = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, 42 | reinterpret_cast(path), 43 | strlen(path), 44 | FALSE); 45 | 46 | AudioDecoder *decoder = AudioDecoder::CreateDecoderForURL(fileURL); 47 | 48 | CFRelease(fileURL), fileURL = NULL; 49 | 50 | if(NULL == decoder) { 51 | puts("Couldn't create decoder"); 52 | continue; 53 | } 54 | 55 | if(!player.Enqueue(decoder)) { 56 | puts("Couldn't enqueue decoder"); 57 | delete decoder, decoder = NULL; 58 | } 59 | } 60 | 61 | player.Play(); 62 | 63 | // Display progress every 2 seconds 64 | while(player.IsPlaying()) { 65 | CFRunLoopRunInMode(kCFRunLoopDefaultMode, 2, true); 66 | printf("%.2f / %.2f [%.2f]\n", player.GetCurrentTime(), player.GetTotalTime(), player.GetRemainingTime()); 67 | } 68 | 69 | player.Stop(); 70 | 71 | return EXIT_SUCCESS; 72 | } 73 | 74 | -------------------------------------------------------------------------------- /SFBAudioEngine.xcodeproj/xcuserdata/indragie.xcuserdatad/xcschemes/SFBAudioEngine.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 42 | 43 | 44 | 45 | 51 | 52 | 54 | 55 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /Metadata/AddID3v1TagToDictionary.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | 35 | // Ignore warnings about TagLib::ID3v1::StringHandler virtual functions but non-virtual dtor 36 | 37 | #pragma clang diagnostic push 38 | #pragma clang diagnostic ignored "-Wnon-virtual-dtor" 39 | 40 | #include 41 | 42 | #pragma clang diagnostic pop 43 | 44 | // ======================================== 45 | // Add the metadata specified in the ID3v1::Tag instance to dictionary 46 | // ======================================== 47 | bool AddID3v1TagToDictionary(CFMutableDictionaryRef dictionary, const TagLib::ID3v1::Tag *tag); 48 | -------------------------------------------------------------------------------- /SFBAudioEngine.xcodeproj/xcuserdata/indragie.xcuserdatad/xcschemes/SFBAudioEngine.framework.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 42 | 43 | 44 | 45 | 51 | 52 | 54 | 55 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /Metadata/SetID3v1TagFromMetadata.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | 35 | // Ignore warnings about TagLib::ID3v1::StringHandler virtual functions but non-virtual dtor 36 | 37 | #pragma clang diagnostic push 38 | #pragma clang diagnostic ignored "-Wnon-virtual-dtor" 39 | 40 | #include 41 | 42 | #pragma clang diagnostic pop 43 | 44 | class AudioMetadata; 45 | 46 | // ======================================== 47 | // Fill in an ID3v1 tag from the specified AudioMetadata 48 | // ======================================== 49 | bool SetID3v1TagFromMetadata(const AudioMetadata& metadata, TagLib::ID3v1::Tag *tag); 50 | -------------------------------------------------------------------------------- /Converter/AudioConverter.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #include "AudioConverter.h" 32 | 33 | AudioConverter::AudioConverter() 34 | { 35 | memset(&mSourceFormat, 0, sizeof(AudioStreamBasicDescription)); 36 | memset(&mDestinationFormat, 0, sizeof(AudioStreamBasicDescription)); 37 | } 38 | 39 | AudioConverter::AudioConverter(const AudioConverter& converter) 40 | : mSourceFormat(converter.GetSourceFormat()), mDestinationFormat(converter.GetDestinationFormat()) 41 | {} 42 | 43 | AudioConverter::AudioConverter(const AudioStreamBasicDescription& sourceFormat, const AudioStreamBasicDescription& destinationFormat) 44 | : mSourceFormat(sourceFormat), mDestinationFormat(destinationFormat) 45 | {} 46 | 47 | AudioConverter::~AudioConverter() 48 | {} 49 | -------------------------------------------------------------------------------- /Converter/AudioDitherer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010, 2011 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | // ======================================== 34 | // A simple implementation of rectangular and triangular dithers 35 | // ======================================== 36 | class AudioDitherer 37 | { 38 | public: 39 | enum DitherType { 40 | eNoDither, 41 | eRectangularDither, 42 | eTriangularDither 43 | }; 44 | 45 | AudioDitherer(DitherType type = eTriangularDither); 46 | ~AudioDitherer(); 47 | 48 | inline DitherType GetDitherType() const { return mDitherType; } 49 | void SetDitherType(DitherType ditherType); 50 | 51 | void Reset(); 52 | 53 | void Dither(double *buffer, unsigned long frameCount); 54 | 55 | private: 56 | DitherType mDitherType; 57 | double mTriangleState; 58 | }; 59 | -------------------------------------------------------------------------------- /SimplePlayer-iOS/SimplePlayer_iOSAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // SimplePlayer_iOSAppDelegate.m 3 | // SimplePlayer-iOS 4 | // 5 | // Created by Stephen Booth on 8/27/11. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "SimplePlayer_iOSAppDelegate.h" 10 | 11 | @implementation SimplePlayer_iOSAppDelegate 12 | 13 | @synthesize window = _window; 14 | 15 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 16 | { 17 | // Override point for customization after application launch. 18 | [self.window makeKeyAndVisible]; 19 | return YES; 20 | } 21 | 22 | - (void)applicationWillResignActive:(UIApplication *)application 23 | { 24 | /* 25 | Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 26 | Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 27 | */ 28 | } 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application 31 | { 32 | /* 33 | Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 34 | If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 35 | */ 36 | } 37 | 38 | - (void)applicationWillEnterForeground:(UIApplication *)application 39 | { 40 | /* 41 | Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 42 | */ 43 | } 44 | 45 | - (void)applicationDidBecomeActive:(UIApplication *)application 46 | { 47 | /* 48 | Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 49 | */ 50 | } 51 | 52 | - (void)applicationWillTerminate:(UIApplication *)application 53 | { 54 | /* 55 | Called when the application is about to terminate. 56 | Save data if appropriate. 57 | See also applicationDidEnterBackground:. 58 | */ 59 | } 60 | 61 | - (void)dealloc 62 | { 63 | [_window release]; 64 | [super dealloc]; 65 | } 66 | 67 | @end 68 | -------------------------------------------------------------------------------- /Metadata/AddAudioPropertiesToDictionary.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #include "AddAudioPropertiesToDictionary.h" 32 | #include "AudioMetadata.h" 33 | #include "CFDictionaryUtilities.h" 34 | 35 | bool 36 | AddAudioPropertiesToDictionary(CFMutableDictionaryRef dictionary, const TagLib::AudioProperties *properties) 37 | { 38 | if(nullptr == dictionary || nullptr == properties) 39 | return false; 40 | 41 | if(properties->length()) 42 | AddIntToDictionary(dictionary, kPropertiesDurationKey, properties->length()); 43 | 44 | if(properties->channels()) 45 | AddIntToDictionary(dictionary, kPropertiesChannelsPerFrameKey, properties->channels()); 46 | 47 | if(properties->sampleRate()) 48 | AddIntToDictionary(dictionary, kPropertiesSampleRateKey, properties->sampleRate()); 49 | 50 | if(properties->bitrate()) 51 | AddIntToDictionary(dictionary, kPropertiesBitrateKey, properties->bitrate()); 52 | 53 | return true; 54 | } 55 | -------------------------------------------------------------------------------- /Metadata/SetTagFromMetadata.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #include "AudioMetadata.h" 32 | #include "SetTagFromMetadata.h" 33 | #include "TagLibStringUtilities.h" 34 | 35 | bool 36 | SetTagFromMetadata(const AudioMetadata& metadata, TagLib::Tag *tag) 37 | { 38 | if(nullptr == tag) 39 | return false; 40 | 41 | tag->setTitle(TagLib::StringFromCFString(metadata.GetTitle())); 42 | tag->setArtist(TagLib::StringFromCFString(metadata.GetArtist())); 43 | tag->setAlbum(TagLib::StringFromCFString(metadata.GetAlbumTitle())); 44 | tag->setComment(TagLib::StringFromCFString(metadata.GetComment())); 45 | tag->setGenre(TagLib::StringFromCFString(metadata.GetGenre())); 46 | tag->setYear(metadata.GetReleaseDate() ? CFStringGetIntValue(metadata.GetReleaseDate()) : 0); 47 | 48 | int track = 0; 49 | if(metadata.GetTrackNumber()) 50 | // Ignore return value 51 | CFNumberGetValue(metadata.GetTrackNumber(), kCFNumberIntType, &track); 52 | tag->setTrack(track); 53 | 54 | return true; 55 | } 56 | -------------------------------------------------------------------------------- /Metadata/AddTagToDictionary.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #include "AddTagToDictionary.h" 32 | #include "AudioMetadata.h" 33 | #include "TagLibStringUtilities.h" 34 | #include "CFDictionaryUtilities.h" 35 | 36 | bool 37 | AddTagToDictionary(CFMutableDictionaryRef dictionary, const TagLib::Tag *tag) 38 | { 39 | if(nullptr == dictionary || nullptr == tag) 40 | return false; 41 | 42 | TagLib::AddStringToCFDictionary(dictionary, kMetadataTitleKey, tag->title()); 43 | TagLib::AddStringToCFDictionary(dictionary, kMetadataAlbumTitleKey, tag->album()); 44 | TagLib::AddStringToCFDictionary(dictionary, kMetadataArtistKey, tag->artist()); 45 | TagLib::AddStringToCFDictionary(dictionary, kMetadataGenreKey, tag->genre()); 46 | 47 | if(tag->year()) 48 | AddIntToDictionaryAsString(dictionary, kMetadataReleaseDateKey, tag->year()); 49 | 50 | if(tag->track()) 51 | AddIntToDictionary(dictionary, kMetadataTrackNumberKey, tag->track()); 52 | 53 | TagLib::AddStringToCFDictionary(dictionary, kMetadataCommentKey, tag->comment()); 54 | 55 | return true; 56 | } 57 | -------------------------------------------------------------------------------- /ChannelLayoutsAreEqual.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #include "ChannelLayoutsAreEqual.h" 32 | 33 | bool 34 | ChannelLayoutsAreEqual(const AudioChannelLayout *lhs, const AudioChannelLayout *rhs) 35 | { 36 | if(lhs == rhs) 37 | return true; 38 | 39 | if(nullptr == lhs || nullptr == rhs) 40 | return false; 41 | 42 | // First check if the tags are equal 43 | if(lhs->mChannelLayoutTag != rhs->mChannelLayoutTag) 44 | return false; 45 | 46 | // If the tags are equal, check for special values 47 | if(kAudioChannelLayoutTag_UseChannelBitmap == lhs->mChannelLayoutTag) 48 | return (lhs->mChannelBitmap == rhs->mChannelBitmap); 49 | 50 | if(kAudioChannelLayoutTag_UseChannelDescriptions == lhs->mChannelLayoutTag) { 51 | if(lhs->mNumberChannelDescriptions != rhs->mNumberChannelDescriptions) 52 | return false; 53 | 54 | size_t bytesToCompare = lhs->mNumberChannelDescriptions * sizeof(AudioChannelDescription); 55 | return (0 == memcmp(&lhs->mChannelDescriptions, &rhs->mChannelDescriptions, bytesToCompare)); 56 | } 57 | 58 | return true; 59 | } 60 | -------------------------------------------------------------------------------- /Metadata/MODMetadata.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | #import "AudioMetadata.h" 35 | 36 | // ======================================== 37 | // An AudioMetadata subclass supporting MOD files 38 | // ======================================== 39 | class MODMetadata : public AudioMetadata 40 | { 41 | 42 | public: 43 | 44 | // ======================================== 45 | // The data types handled by this class 46 | static CFArrayRef CreateSupportedFileExtensions(); 47 | static CFArrayRef CreateSupportedMIMETypes(); 48 | 49 | static bool HandlesFilesWithExtension(CFStringRef extension); 50 | static bool HandlesMIMEType(CFStringRef mimeType); 51 | 52 | // ======================================== 53 | // Creation 54 | MODMetadata(CFURLRef url); 55 | 56 | // ======================================== 57 | // Destruction 58 | virtual ~MODMetadata(); 59 | 60 | // ======================================== 61 | // The core functionality 62 | virtual bool ReadMetadata(CFErrorRef *error = nullptr); 63 | virtual bool WriteMetadata(CFErrorRef *error = nullptr); 64 | }; 65 | -------------------------------------------------------------------------------- /Converter/AudioConverter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | #include 35 | 36 | // ======================================== 37 | // Base class for 1:1 PCM converters 38 | // ======================================== 39 | class AudioConverter 40 | { 41 | public: 42 | // ======================================== 43 | virtual ~AudioConverter(); 44 | 45 | inline AudioStreamBasicDescription GetSourceFormat() const { return mSourceFormat; } 46 | inline AudioStreamBasicDescription GetDestinationFormat() const { return mDestinationFormat; } 47 | 48 | // ======================================== 49 | virtual UInt32 Convert(const AudioBufferList *inputBuffer, AudioBufferList *outputBuffer, UInt32 frameCount) = 0; 50 | 51 | protected: 52 | AudioConverter(); 53 | AudioConverter(const AudioConverter& converter); 54 | AudioConverter(const AudioStreamBasicDescription& sourceFormat, const AudioStreamBasicDescription& destinationFormat); 55 | 56 | AudioStreamBasicDescription mSourceFormat; 57 | AudioStreamBasicDescription mDestinationFormat; 58 | }; 59 | -------------------------------------------------------------------------------- /Metadata/TrueAudioMetadata.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | #import "AudioMetadata.h" 35 | 36 | // ======================================== 37 | // An AudioMetadata subclass supporting TrueAudio 38 | // ======================================== 39 | class TrueAudioMetadata : public AudioMetadata 40 | { 41 | 42 | public: 43 | 44 | // ======================================== 45 | // The data types handled by this class 46 | static CFArrayRef CreateSupportedFileExtensions(); 47 | static CFArrayRef CreateSupportedMIMETypes(); 48 | 49 | static bool HandlesFilesWithExtension(CFStringRef extension); 50 | static bool HandlesMIMEType(CFStringRef mimeType); 51 | 52 | // ======================================== 53 | // Creation 54 | TrueAudioMetadata(CFURLRef url); 55 | 56 | // ======================================== 57 | // Destruction 58 | virtual ~TrueAudioMetadata(); 59 | 60 | // ======================================== 61 | // The core functionality 62 | virtual bool ReadMetadata(CFErrorRef *error = nullptr); 63 | virtual bool WriteMetadata(CFErrorRef *error = nullptr); 64 | }; 65 | -------------------------------------------------------------------------------- /Metadata/MP4Metadata.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | #import "AudioMetadata.h" 35 | 36 | // ======================================== 37 | // An AudioMetadata subclass supporting MPEG-4 38 | // ======================================== 39 | class MP4Metadata : public AudioMetadata 40 | { 41 | 42 | public: 43 | 44 | // ======================================== 45 | // The data types handled by this class 46 | static CFArrayRef CreateSupportedFileExtensions(); 47 | static CFArrayRef CreateSupportedMIMETypes(); 48 | 49 | static bool HandlesFilesWithExtension(CFStringRef extension); 50 | static bool HandlesMIMEType(CFStringRef mimeType); 51 | 52 | // ======================================== 53 | // Creation 54 | MP4Metadata(CFURLRef url); 55 | 56 | // ======================================== 57 | // Destruction 58 | virtual ~MP4Metadata(); 59 | 60 | // ======================================== 61 | // The core functionality 62 | virtual bool ReadMetadata(CFErrorRef *error = nullptr); 63 | virtual bool WriteMetadata(CFErrorRef *error = nullptr); 64 | }; 65 | -------------------------------------------------------------------------------- /Metadata/OggSpeexMetadata.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | #import "AudioMetadata.h" 35 | 36 | // ======================================== 37 | // An AudioMetadata subclass supporting Ogg Speex files 38 | // ======================================== 39 | class OggSpeexMetadata : public AudioMetadata 40 | { 41 | 42 | public: 43 | 44 | // ======================================== 45 | // The data types handled by this class 46 | static CFArrayRef CreateSupportedFileExtensions(); 47 | static CFArrayRef CreateSupportedMIMETypes(); 48 | 49 | static bool HandlesFilesWithExtension(CFStringRef extension); 50 | static bool HandlesMIMEType(CFStringRef mimeType); 51 | 52 | // ======================================== 53 | // Creation 54 | OggSpeexMetadata(CFURLRef url); 55 | 56 | // ======================================== 57 | // Destruction 58 | virtual ~OggSpeexMetadata(); 59 | 60 | // ======================================== 61 | // The core functionality 62 | virtual bool ReadMetadata(CFErrorRef *error = nullptr); 63 | virtual bool WriteMetadata(CFErrorRef *error = nullptr); 64 | }; 65 | -------------------------------------------------------------------------------- /Metadata/MP3Metadata.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | #import "AudioMetadata.h" 35 | 36 | // ======================================== 37 | // An AudioMetadata subclass supporting MP3 files 38 | // ======================================== 39 | class MP3Metadata : public AudioMetadata 40 | { 41 | 42 | public: 43 | 44 | // ======================================== 45 | // The data types handled by this class 46 | static CFArrayRef CreateSupportedFileExtensions(); 47 | static CFArrayRef CreateSupportedMIMETypes(); 48 | 49 | static bool HandlesFilesWithExtension(CFStringRef extension); 50 | static bool HandlesMIMEType(CFStringRef mimeType); 51 | 52 | // ======================================== 53 | // Creation 54 | MP3Metadata(CFURLRef url); 55 | 56 | // ======================================== 57 | // Destruction 58 | virtual ~MP3Metadata(); 59 | 60 | // ======================================== 61 | // The core functionality 62 | virtual bool ReadMetadata(CFErrorRef *error = nullptr); 63 | virtual bool WriteMetadata(CFErrorRef *error = nullptr); 64 | }; 65 | -------------------------------------------------------------------------------- /Metadata/AIFFMetadata.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | #import "AudioMetadata.h" 35 | 36 | // ======================================== 37 | // An AudioMetadata subclass supporting AIFF files 38 | // ======================================== 39 | class AIFFMetadata : public AudioMetadata 40 | { 41 | 42 | public: 43 | 44 | // ======================================== 45 | // The data types handled by this class 46 | static CFArrayRef CreateSupportedFileExtensions(); 47 | static CFArrayRef CreateSupportedMIMETypes(); 48 | 49 | static bool HandlesFilesWithExtension(CFStringRef extension); 50 | static bool HandlesMIMEType(CFStringRef mimeType); 51 | 52 | // ======================================== 53 | // Creation 54 | AIFFMetadata(CFURLRef url); 55 | 56 | // ======================================== 57 | // Destruction 58 | virtual ~AIFFMetadata(); 59 | 60 | // ======================================== 61 | // The core functionality 62 | virtual bool ReadMetadata(CFErrorRef *error = nullptr); 63 | virtual bool WriteMetadata(CFErrorRef *error = nullptr); 64 | }; 65 | -------------------------------------------------------------------------------- /Metadata/WAVEMetadata.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | #import "AudioMetadata.h" 35 | 36 | // ======================================== 37 | // An AudioMetadata subclass supporting WAVE files 38 | // ======================================== 39 | class WAVEMetadata : public AudioMetadata 40 | { 41 | 42 | public: 43 | 44 | // ======================================== 45 | // The data types handled by this class 46 | static CFArrayRef CreateSupportedFileExtensions(); 47 | static CFArrayRef CreateSupportedMIMETypes(); 48 | 49 | static bool HandlesFilesWithExtension(CFStringRef extension); 50 | static bool HandlesMIMEType(CFStringRef mimeType); 51 | 52 | // ======================================== 53 | // Creation 54 | WAVEMetadata(CFURLRef url); 55 | 56 | // ======================================== 57 | // Destruction 58 | virtual ~WAVEMetadata(); 59 | 60 | // ======================================== 61 | // The core functionality 62 | virtual bool ReadMetadata(CFErrorRef *error = nullptr); 63 | virtual bool WriteMetadata(CFErrorRef *error = nullptr); 64 | }; 65 | -------------------------------------------------------------------------------- /SimplePlayer/SimplePlayerAppDelegate.mm: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009, 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved 4 | */ 5 | 6 | #import "SimplePlayerAppDelegate.h" 7 | #import "PlayerWindowController.h" 8 | 9 | #include 10 | #include 11 | 12 | @implementation SimplePlayerAppDelegate 13 | 14 | @synthesize playerWindowController = _playerWindowController; 15 | @synthesize openURLPanel = _openURLPanel; 16 | @synthesize openURLPanelTextField = _openURLPanelTextField; 17 | 18 | - (void) dealloc 19 | { 20 | [_playerWindowController release], _playerWindowController = nil; 21 | [_openURLPanel release], _openURLPanel = nil; 22 | [_openURLPanelTextField release], _openURLPanelTextField = nil; 23 | [super dealloc]; 24 | } 25 | 26 | - (void) applicationDidFinishLaunching:(NSNotification *)aNotification 27 | { 28 | #pragma unused(aNotification) 29 | asl_add_log_file(nullptr, STDERR_FILENO); 30 | ::logger::SetCurrentLevel(::logger::debug); 31 | [_playerWindowController showWindow:self]; 32 | } 33 | 34 | - (BOOL) applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication 35 | { 36 | #pragma unused(theApplication) 37 | return YES; 38 | } 39 | 40 | - (BOOL) application:(NSApplication *)theApplication openFile:(NSString *)filename 41 | { 42 | #pragma unused(theApplication) 43 | CFArrayRef supportedTypes = AudioDecoder::CreateSupportedFileExtensions(); 44 | BOOL extensionValid = [(NSArray *)supportedTypes containsObject:[filename pathExtension]]; 45 | CFRelease(supportedTypes), supportedTypes = nullptr; 46 | 47 | if(NO == extensionValid) 48 | return NO; 49 | 50 | return [_playerWindowController playURL:[NSURL fileURLWithPath:filename]]; 51 | } 52 | 53 | - (IBAction) openFile:(id)sender 54 | { 55 | #pragma unused(sender) 56 | NSOpenPanel *openPanel = [NSOpenPanel openPanel]; 57 | 58 | CFArrayRef supportedTypes = AudioDecoder::CreateSupportedFileExtensions(); 59 | 60 | [openPanel setAllowsMultipleSelection:NO]; 61 | [openPanel setCanChooseDirectories:NO]; 62 | [openPanel setAllowedFileTypes:(NSArray *)supportedTypes]; 63 | 64 | if(NSFileHandlingPanelOKButton == [openPanel runModal]) { 65 | NSArray *URLs = [openPanel URLs]; 66 | [_playerWindowController playURL:[URLs objectAtIndex:0]]; 67 | } 68 | 69 | CFRelease(supportedTypes), supportedTypes = nullptr; 70 | } 71 | 72 | - (IBAction) openURL:(id)sender 73 | { 74 | [_openURLPanel center]; 75 | [_openURLPanel makeKeyAndOrderFront:sender]; 76 | } 77 | 78 | - (IBAction) openURLPanelOpenAction:(id)sender 79 | { 80 | [_openURLPanel orderOut:sender]; 81 | NSURL *url = [NSURL URLWithString:[_openURLPanelTextField stringValue]]; 82 | [_playerWindowController playURL:url]; 83 | } 84 | 85 | - (IBAction) openURLPanelCancelAction:(id)sender 86 | { 87 | [_openURLPanel orderOut:sender]; 88 | } 89 | 90 | @end 91 | -------------------------------------------------------------------------------- /Metadata/MonkeysAudioMetadata.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | #import "AudioMetadata.h" 35 | 36 | // ======================================== 37 | // An AudioMetadata subclass supporting Monkey's Audio files 38 | // ======================================== 39 | class MonkeysAudioMetadata : public AudioMetadata 40 | { 41 | 42 | public: 43 | 44 | // ======================================== 45 | // The data types handled by this class 46 | static CFArrayRef CreateSupportedFileExtensions(); 47 | static CFArrayRef CreateSupportedMIMETypes(); 48 | 49 | static bool HandlesFilesWithExtension(CFStringRef extension); 50 | static bool HandlesMIMEType(CFStringRef mimeType); 51 | 52 | // ======================================== 53 | // Creation 54 | MonkeysAudioMetadata(CFURLRef url); 55 | 56 | // ======================================== 57 | // Destruction 58 | virtual ~MonkeysAudioMetadata(); 59 | 60 | // ======================================== 61 | // The core functionality 62 | virtual bool ReadMetadata(CFErrorRef *error = nullptr); 63 | virtual bool WriteMetadata(CFErrorRef *error = nullptr); 64 | }; 65 | -------------------------------------------------------------------------------- /Metadata/WavPackMetadata.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | #import "AudioMetadata.h" 35 | 36 | // ======================================== 37 | // An AudioMetadata subclass supporting WavPack 38 | // ======================================== 39 | class WavPackMetadata : public AudioMetadata 40 | { 41 | 42 | public: 43 | 44 | // ======================================== 45 | // The data types handled by this class 46 | static CFArrayRef CreateSupportedFileExtensions(); 47 | static CFArrayRef CreateSupportedMIMETypes(); 48 | 49 | static bool HandlesFilesWithExtension(CFStringRef extension); 50 | static bool HandlesMIMEType(CFStringRef mimeType); 51 | 52 | // ======================================== 53 | // Creation 54 | WavPackMetadata(CFURLRef url); 55 | 56 | // ======================================== 57 | // Destruction 58 | virtual ~WavPackMetadata(); 59 | 60 | // ======================================== 61 | // The core functionality 62 | virtual bool ReadMetadata(CFErrorRef *error = nullptr); 63 | virtual bool WriteMetadata(CFErrorRef *error = nullptr); 64 | }; 65 | -------------------------------------------------------------------------------- /Metadata/OggFLACMetadata.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | #import "AudioMetadata.h" 35 | 36 | // ======================================== 37 | // An AudioMetadata subclass supporting Ogg FLAC files 38 | // ======================================== 39 | class OggFLACMetadata : public AudioMetadata 40 | { 41 | 42 | public: 43 | 44 | // ======================================== 45 | // The data types handled by this class 46 | static CFArrayRef CreateSupportedFileExtensions(); 47 | static CFArrayRef CreateSupportedMIMETypes(); 48 | 49 | static bool HandlesFilesWithExtension(CFStringRef extension); 50 | static bool HandlesMIMEType(CFStringRef mimeType); 51 | 52 | // ======================================== 53 | // Creation 54 | OggFLACMetadata(CFURLRef url); 55 | 56 | // ======================================== 57 | // Destruction 58 | virtual ~OggFLACMetadata(); 59 | 60 | // ======================================== 61 | // The core functionality 62 | virtual bool ReadMetadata(CFErrorRef *error = nullptr); 63 | virtual bool WriteMetadata(CFErrorRef *error = nullptr); 64 | }; 65 | -------------------------------------------------------------------------------- /Metadata/MusepackMetadata.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | #import "AudioMetadata.h" 35 | 36 | // ======================================== 37 | // An AudioMetadata subclass supporting Musepack files 38 | // ======================================== 39 | class MusepackMetadata : public AudioMetadata 40 | { 41 | 42 | public: 43 | 44 | // ======================================== 45 | // The data types handled by this class 46 | static CFArrayRef CreateSupportedFileExtensions(); 47 | static CFArrayRef CreateSupportedMIMETypes(); 48 | 49 | static bool HandlesFilesWithExtension(CFStringRef extension); 50 | static bool HandlesMIMEType(CFStringRef mimeType); 51 | 52 | // ======================================== 53 | // Creation 54 | MusepackMetadata(CFURLRef url); 55 | 56 | // ======================================== 57 | // Destruction 58 | virtual ~MusepackMetadata(); 59 | 60 | // ======================================== 61 | // The core functionality 62 | virtual bool ReadMetadata(CFErrorRef *error = nullptr); 63 | virtual bool WriteMetadata(CFErrorRef *error = nullptr); 64 | }; 65 | -------------------------------------------------------------------------------- /Metadata/FLACMetadata.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | #import "AudioMetadata.h" 35 | 36 | // ======================================== 37 | // An AudioMetadata subclass supporting the Free Lossless Audio Codec (FLAC) 38 | // ======================================== 39 | class FLACMetadata : public AudioMetadata 40 | { 41 | 42 | public: 43 | 44 | // ======================================== 45 | // The data types handled by this class 46 | static CFArrayRef CreateSupportedFileExtensions(); 47 | static CFArrayRef CreateSupportedMIMETypes(); 48 | 49 | static bool HandlesFilesWithExtension(CFStringRef extension); 50 | static bool HandlesMIMEType(CFStringRef mimeType); 51 | 52 | // ======================================== 53 | // Creation 54 | FLACMetadata(CFURLRef url); 55 | 56 | // ======================================== 57 | // Destruction 58 | virtual ~FLACMetadata(); 59 | 60 | // ======================================== 61 | // The core functionality 62 | virtual bool ReadMetadata(CFErrorRef *error = nullptr); 63 | virtual bool WriteMetadata(CFErrorRef *error = nullptr); 64 | }; 65 | -------------------------------------------------------------------------------- /Metadata/OggVorbisMetadata.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | #import "AudioMetadata.h" 35 | 36 | // ======================================== 37 | // An AudioMetadata subclass supporting Ogg Vorbis files 38 | // ======================================== 39 | class OggVorbisMetadata : public AudioMetadata 40 | { 41 | 42 | public: 43 | 44 | // ======================================== 45 | // The data types handled by this class 46 | static CFArrayRef CreateSupportedFileExtensions(); 47 | static CFArrayRef CreateSupportedMIMETypes(); 48 | 49 | static bool HandlesFilesWithExtension(CFStringRef extension); 50 | static bool HandlesMIMEType(CFStringRef mimeType); 51 | 52 | // ======================================== 53 | // Creation 54 | OggVorbisMetadata(CFURLRef url); 55 | 56 | // ======================================== 57 | // Destruction 58 | virtual ~OggVorbisMetadata(); 59 | 60 | // ======================================== 61 | // The core functionality 62 | virtual bool ReadMetadata(CFErrorRef *error = nullptr); 63 | virtual bool WriteMetadata(CFErrorRef *error = nullptr); 64 | }; 65 | -------------------------------------------------------------------------------- /Guard.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include "Mutex.h" 34 | 35 | // ======================================== 36 | // A wrapper around a pthread mutex and condition variable 37 | // ======================================== 38 | class Guard : public Mutex 39 | { 40 | public: 41 | Guard(); 42 | virtual ~Guard(); 43 | 44 | Guard(const Guard& rhs) = delete; 45 | Guard& operator=(const Guard& rhs) = delete; 46 | 47 | // Wait() and WaitUntil() will throw std::runtime_error if the mutex isn't locked 48 | // WaitUntil() returns true if the request timed out, false otherwise 49 | 50 | void Wait(); 51 | bool WaitUntil(struct timespec absoluteTime); 52 | 53 | void Signal(); 54 | void Broadcast(); 55 | 56 | protected: 57 | pthread_cond_t mCondition; 58 | 59 | public: 60 | class Locker 61 | { 62 | public: 63 | Locker(Guard& guard); 64 | ~Locker(); 65 | 66 | inline void Wait() { mGuard.Wait(); } 67 | inline bool WaitUntil(struct timespec absoluteTime) { return mGuard.WaitUntil(absoluteTime); } 68 | 69 | inline void Signal() { mGuard.Signal(); } 70 | inline void Broadcast() { mGuard.Broadcast(); } 71 | 72 | private: 73 | Guard& mGuard; 74 | bool mReleaseLock; 75 | }; 76 | }; 77 | -------------------------------------------------------------------------------- /Input/FileInputSource.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | #include 35 | 36 | #include "InputSource.h" 37 | 38 | class FileInputSource : public InputSource 39 | { 40 | 41 | public: 42 | 43 | // ======================================== 44 | // Creation 45 | FileInputSource(CFURLRef url); 46 | 47 | // ======================================== 48 | // Destruction 49 | virtual ~FileInputSource(); 50 | 51 | // ======================================== 52 | // Bytestream access 53 | virtual bool Open(CFErrorRef *error = nullptr); 54 | virtual bool Close(CFErrorRef *error = nullptr); 55 | 56 | // ======================================== 57 | // 58 | virtual SInt64 Read(void *buffer, SInt64 byteCount); 59 | virtual inline bool AtEOF() const { return feof(mFile); } 60 | 61 | virtual inline SInt64 GetOffset() const { return ftello(mFile); } 62 | virtual inline SInt64 GetLength() const { return mFilestats.st_size; } 63 | 64 | // ======================================== 65 | // Seeking support 66 | virtual inline bool SupportsSeeking() const { return true; } 67 | virtual bool SeekToOffset(SInt64 offset); 68 | 69 | private: 70 | 71 | struct stat mFilestats; 72 | FILE *mFile; 73 | 74 | }; 75 | -------------------------------------------------------------------------------- /Converter/AudioDitherer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010, 2011 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #include 32 | #include "AudioDitherer.h" 33 | 34 | // arc4random() returns pseudo-random integers in the range [0, 2^32 - 1] 35 | #define ARC4RANDOM_MAX 4294967295.0 36 | 37 | // Evaluates to a random number in the interval [0, 1] 38 | #define DITHER_NOISE (arc4random() / ARC4RANDOM_MAX) 39 | 40 | AudioDitherer::AudioDitherer(DitherType type) 41 | : mDitherType(type) 42 | { 43 | Reset(); 44 | } 45 | 46 | AudioDitherer::~AudioDitherer() 47 | {} 48 | 49 | void AudioDitherer::SetDitherType(DitherType ditherType) 50 | { 51 | mDitherType = ditherType; 52 | Reset(); 53 | } 54 | 55 | void AudioDitherer::Reset() 56 | { 57 | mTriangleState = 0; 58 | } 59 | 60 | void AudioDitherer::Dither(double *buffer, unsigned long frameCount) 61 | { 62 | if(NULL == buffer || 0 == frameCount) 63 | return; 64 | 65 | switch(mDitherType) { 66 | case eNoDither: 67 | break; 68 | 69 | case eRectangularDither: 70 | while(frameCount--) 71 | *buffer++ -= DITHER_NOISE; 72 | break; 73 | 74 | case eTriangularDither: 75 | { 76 | double r; 77 | while(frameCount--) { 78 | r = DITHER_NOISE - 0.5; 79 | *buffer++ -= (r - mTriangleState); 80 | mTriangleState = r; 81 | } 82 | 83 | break; 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /AllocateABL.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | #include "AllocateABL.h" 36 | 37 | AudioBufferList * 38 | AllocateABL(const AudioStreamBasicDescription& format, UInt32 capacityFrames) 39 | { 40 | return AllocateABL(format.mChannelsPerFrame, format.mBytesPerFrame, !(kAudioFormatFlagIsNonInterleaved & format.mFormatFlags), capacityFrames); 41 | } 42 | 43 | AudioBufferList * 44 | AllocateABL(UInt32 channelsPerFrame, UInt32 bytesPerFrame, bool interleaved, UInt32 capacityFrames) 45 | { 46 | AudioBufferList *bufferList = nullptr; 47 | 48 | UInt32 numBuffers = interleaved ? 1 : channelsPerFrame; 49 | UInt32 channelsPerBuffer = interleaved ? channelsPerFrame : 1; 50 | 51 | bufferList = static_cast(calloc(1, offsetof(AudioBufferList, mBuffers) + (sizeof(AudioBuffer) * numBuffers))); 52 | 53 | bufferList->mNumberBuffers = numBuffers; 54 | 55 | for(UInt32 bufferIndex = 0; bufferIndex < bufferList->mNumberBuffers; ++bufferIndex) { 56 | bufferList->mBuffers[bufferIndex].mData = static_cast(calloc(capacityFrames, bytesPerFrame)); 57 | bufferList->mBuffers[bufferIndex].mDataByteSize = capacityFrames * bytesPerFrame; 58 | bufferList->mBuffers[bufferIndex].mNumberChannels = channelsPerBuffer; 59 | } 60 | 61 | return bufferList; 62 | } 63 | -------------------------------------------------------------------------------- /CreateDisplayNameForURL.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #include 32 | #if !TARGET_OS_IPHONE 33 | # include 34 | #endif 35 | 36 | #include "CreateDisplayNameForURL.h" 37 | #include "Logger.h" 38 | 39 | CFStringRef 40 | CreateDisplayNameForURL(CFURLRef url) 41 | { 42 | assert(nullptr != url); 43 | 44 | CFStringRef displayName = nullptr; 45 | 46 | #if !TARGET_OS_IPHONE 47 | CFStringRef scheme = CFURLCopyScheme(url); 48 | if(scheme) { 49 | bool isFileURL = (kCFCompareEqualTo == CFStringCompare(CFSTR("file"), scheme, kCFCompareCaseInsensitive)); 50 | CFRelease(scheme), scheme = nullptr; 51 | 52 | if(isFileURL) { 53 | OSStatus result = LSCopyDisplayNameForURL(url, &displayName); 54 | 55 | if(noErr != result) { 56 | LOGGER_WARNING("org.sbooth.AudioEngine", "LSCopyDisplayNameForURL failed: " << result); 57 | displayName = CFURLCopyLastPathComponent(url); 58 | } 59 | } 60 | else { 61 | displayName = CFURLGetString(url); 62 | CFRetain(displayName); 63 | } 64 | } 65 | // If scheme is nullptr the URL is probably invalid, but can still be logged 66 | else { 67 | displayName = CFURLGetString(url); 68 | CFRetain(displayName); 69 | } 70 | #else 71 | displayName = CFURLGetString(url); 72 | CFRetain(displayName); 73 | #endif 74 | 75 | return displayName; 76 | } 77 | -------------------------------------------------------------------------------- /Metadata/TagLibStringUtilities.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #include "TagLibStringUtilities.h" 32 | #include "Logger.h" 33 | 34 | TagLib::String 35 | TagLib::StringFromCFString(CFStringRef s) 36 | { 37 | if(nullptr == s) 38 | return String::null; 39 | 40 | CFRange range = CFRangeMake(0, CFStringGetLength(s)); 41 | CFIndex count; 42 | 43 | // Determine the length of the string in UTF-8 44 | CFStringGetBytes(s, range, kCFStringEncodingUTF8, 0, false, nullptr, 0, &count); 45 | 46 | char *buf = new char [count + 1]; 47 | 48 | // Convert it 49 | CFIndex used; 50 | CFIndex converted = CFStringGetBytes(s, range, kCFStringEncodingUTF8, 0, false, reinterpret_cast(buf), count, &used); 51 | 52 | if(CFStringGetLength(s) != converted) 53 | LOGGER_WARNING("org.sbooth.AudioEngine", "CFStringGetBytes failed: converted " << converted << " of " << CFStringGetLength(s) << " characters"); 54 | 55 | // Add terminator 56 | buf[used] = '\0'; 57 | 58 | String result(buf, String::UTF8); 59 | 60 | delete [] buf; 61 | 62 | return result; 63 | } 64 | 65 | void TagLib::AddStringToCFDictionary(CFMutableDictionaryRef d, CFStringRef key, String value) 66 | { 67 | if(nullptr == d || nullptr == key || value.isNull()) 68 | return; 69 | 70 | CFStringRef string = CFStringCreateWithCString(kCFAllocatorDefault, value.toCString(true), kCFStringEncodingUTF8); 71 | CFDictionarySetValue(d, key, string); 72 | CFRelease(string), string = nullptr; 73 | } 74 | -------------------------------------------------------------------------------- /SimplePlayer-iOS/SimplePlayer_iOSAppDelegate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #import 32 | 33 | #ifdef __cplusplus 34 | # include "AudioPlayer.h" 35 | #endif 36 | 37 | @interface SimplePlayer_iOSAppDelegate : NSObject 38 | { 39 | @private 40 | UIWindow *_window; 41 | UIButton *_playButton; 42 | UIButton *_backwardButton; 43 | UIButton *_forwardButton; 44 | UISlider *_slider; 45 | UITextField *_elapsed; 46 | UITextField *_remaining; 47 | UILabel *_title; 48 | 49 | #ifdef __cplusplus 50 | AudioPlayer *_player; 51 | #else 52 | void *_player; 53 | #endif 54 | NSTimer *_uiTimer; 55 | 56 | BOOL _resume; 57 | } 58 | 59 | @property (nonatomic, retain) IBOutlet UIWindow * window; 60 | @property (nonatomic, retain) IBOutlet UISlider * slider; 61 | @property (nonatomic, retain) IBOutlet UIButton * playButton; 62 | @property (nonatomic, retain) IBOutlet UIButton * backwardButton; 63 | @property (nonatomic, retain) IBOutlet UIButton * forwardButton; 64 | @property (nonatomic, retain) IBOutlet UITextField * elapsed; 65 | @property (nonatomic, retain) IBOutlet UITextField * remaining; 66 | @property (nonatomic, retain) IBOutlet UILabel * title; 67 | 68 | - (IBAction) playPause:(id)sender; 69 | 70 | - (IBAction) seekForward:(id)sender; 71 | - (IBAction) seekBackward:(id)sender; 72 | 73 | - (IBAction) seek:(id)sender; 74 | 75 | // Attempt to play the specified file- returns YES if successful 76 | - (BOOL) playFile:(NSString *)file; 77 | 78 | @end 79 | -------------------------------------------------------------------------------- /Player/DecoderStateData.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009, 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | #include 35 | 36 | class AudioDecoder; 37 | 38 | // ======================================== 39 | // Enums 40 | // ======================================== 41 | enum { 42 | eDecoderStateDataFlagDecodingStarted = 1u << 0, 43 | eDecoderStateDataFlagDecodingFinished = 1u << 1, 44 | eDecoderStateDataFlagRenderingStarted = 1u << 2, 45 | eDecoderStateDataFlagRenderingFinished = 1u << 3, 46 | eDecoderStateDataFlagStopDecoding = 1u << 4 47 | }; 48 | 49 | // ======================================== 50 | // State data for decoders that are decoding and/or rendering 51 | // ======================================== 52 | class DecoderStateData 53 | { 54 | 55 | public: 56 | 57 | DecoderStateData(AudioDecoder *decoder); 58 | ~DecoderStateData(); 59 | 60 | DecoderStateData(const DecoderStateData& rhs) = delete; 61 | DecoderStateData& operator=(const DecoderStateData& rhs) = delete; 62 | 63 | void AllocateBufferList(UInt32 capacityFrames); 64 | void DeallocateBufferList(); 65 | 66 | void ResetBufferList(); 67 | 68 | UInt32 ReadAudio(UInt32 frameCount); 69 | 70 | AudioDecoder *mDecoder; 71 | 72 | AudioBufferList *mBufferList; 73 | UInt32 mBufferCapacityFrames; 74 | 75 | SInt64 mTimeStamp; 76 | 77 | SInt64 mTotalFrames; 78 | volatile SInt64 mFramesRendered; 79 | 80 | SInt64 mFrameToSeek; 81 | 82 | volatile uint32_t mFlags; 83 | 84 | private: 85 | 86 | DecoderStateData(); 87 | 88 | }; 89 | -------------------------------------------------------------------------------- /Input/InMemoryFileInputSource.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | #include "InputSource.h" 35 | 36 | // ======================================== 37 | // InputSource serving bytes from a file fully loaded in RAM 38 | // ======================================== 39 | class InMemoryFileInputSource : public InputSource 40 | { 41 | 42 | public: 43 | 44 | // ======================================== 45 | // Creation 46 | InMemoryFileInputSource(CFURLRef url); 47 | 48 | // ======================================== 49 | // Destruction 50 | virtual ~InMemoryFileInputSource(); 51 | 52 | // ======================================== 53 | // Bytestream access 54 | virtual bool Open(CFErrorRef *error = nullptr); 55 | virtual bool Close(CFErrorRef *error = nullptr); 56 | 57 | virtual inline bool IsOpen() const { return (nullptr != mMemory);} 58 | 59 | // ======================================== 60 | // 61 | virtual SInt64 Read(void *buffer, SInt64 byteCount); 62 | virtual bool AtEOF() const { return ((mCurrentPosition - mMemory) == mFilestats.st_size); } 63 | 64 | virtual inline SInt64 GetOffset() const { return (mCurrentPosition - mMemory); } 65 | virtual inline SInt64 GetLength() const { return mFilestats.st_size; } 66 | 67 | // ======================================== 68 | // Seeking support 69 | virtual inline bool SupportsSeeking() const { return true; } 70 | virtual bool SeekToOffset(SInt64 offset); 71 | 72 | private: 73 | 74 | struct stat mFilestats; 75 | int8_t *mMemory; 76 | int8_t *mCurrentPosition; 77 | 78 | }; 79 | -------------------------------------------------------------------------------- /Input/MemoryMappedFileInputSource.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | #include "InputSource.h" 35 | 36 | // ======================================== 37 | // InputSource serving bytes from a memory-mapped file 38 | // ======================================== 39 | class MemoryMappedFileInputSource : public InputSource 40 | { 41 | 42 | public: 43 | 44 | // ======================================== 45 | // Creation 46 | MemoryMappedFileInputSource(CFURLRef url); 47 | 48 | // ======================================== 49 | // Destruction 50 | virtual ~MemoryMappedFileInputSource(); 51 | 52 | // ======================================== 53 | // Bytestream access 54 | virtual bool Open(CFErrorRef *error = nullptr); 55 | virtual bool Close(CFErrorRef *error = nullptr); 56 | 57 | virtual inline bool IsOpen() const { return (nullptr != mMemory);} 58 | 59 | // ======================================== 60 | // 61 | virtual SInt64 Read(void *buffer, SInt64 byteCount); 62 | virtual bool AtEOF() const { return ((mCurrentPosition - mMemory) == mFilestats.st_size); } 63 | 64 | virtual inline SInt64 GetOffset() const { return (mCurrentPosition - mMemory); } 65 | virtual inline SInt64 GetLength() const { return mFilestats.st_size; } 66 | 67 | // ======================================== 68 | // Seeking support 69 | virtual inline bool SupportsSeeking() const { return true; } 70 | virtual bool SeekToOffset(SInt64 offset); 71 | 72 | private: 73 | 74 | struct stat mFilestats; 75 | int8_t *mMemory; 76 | int8_t *mCurrentPosition; 77 | 78 | }; 79 | -------------------------------------------------------------------------------- /Mutex.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | 35 | // ======================================== 36 | // A wrapper around a pthread mutex 37 | // ======================================== 38 | class Mutex 39 | { 40 | public: 41 | Mutex(); 42 | virtual ~Mutex(); 43 | 44 | Mutex(const Mutex& rhs) = delete; 45 | Mutex& operator=(const Mutex& rhs) = delete; 46 | 47 | // Lock() and Unlock() return true if the operation was successful, false otherwise 48 | // TryLock() returns true if the lock is held by the current thread, false otherwise 49 | // All three may throw std::runtime_exception if something bad happens 50 | 51 | bool Lock(); 52 | void Unlock(); 53 | 54 | bool TryLock(); 55 | bool TryLock(bool& acquiredLock); 56 | 57 | inline bool Owned() const { return pthread_equal(mOwner, pthread_self()); } 58 | 59 | protected: 60 | pthread_mutex_t mMutex; 61 | pthread_t mOwner; 62 | 63 | public: 64 | 65 | // ======================================== 66 | // Scope-based helpers for Mutex 67 | // ======================================== 68 | 69 | // Uses Mutex::Lock() 70 | class Locker 71 | { 72 | public: 73 | Locker(Mutex& mutex); 74 | ~Locker(); 75 | 76 | private: 77 | Mutex& mMutex; 78 | bool mReleaseLock; 79 | }; 80 | 81 | // Uses Mutex::TryLock() 82 | class Tryer 83 | { 84 | public: 85 | Tryer(Mutex& mutex); 86 | ~Tryer(); 87 | 88 | // Returns true if mutex is owned and locked, false otherwise 89 | inline operator bool() const { return mLocked; } 90 | 91 | private: 92 | Mutex& mMutex; 93 | bool mLocked; 94 | bool mReleaseLock; 95 | }; 96 | }; 97 | -------------------------------------------------------------------------------- /Input/HTTPInputSource.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | 35 | #if TARGET_OS_IPHONE 36 | # include 37 | #else 38 | #include 39 | #endif 40 | #include "InputSource.h" 41 | 42 | class HTTPInputSource : public InputSource 43 | { 44 | 45 | public: 46 | 47 | // ======================================== 48 | // Creation 49 | HTTPInputSource(CFURLRef url); 50 | 51 | // ======================================== 52 | // Destruction 53 | virtual ~HTTPInputSource(); 54 | 55 | // ======================================== 56 | // Bytestream access 57 | virtual bool Open(CFErrorRef *error = nullptr); 58 | virtual bool Close(CFErrorRef *error = nullptr); 59 | 60 | // ======================================== 61 | // 62 | virtual SInt64 Read(void *buffer, SInt64 byteCount); 63 | virtual inline bool AtEOF() const { return mEOSReached; } 64 | 65 | virtual inline SInt64 GetOffset() const { return mOffset; } 66 | virtual SInt64 GetLength() const; 67 | 68 | // ======================================== 69 | // Seeking support 70 | virtual inline bool SupportsSeeking() const { return true; } 71 | virtual bool SeekToOffset(SInt64 offset); 72 | 73 | // ======================================== 74 | CFStringRef CopyContentMIMEType() const; 75 | 76 | private: 77 | 78 | CFHTTPMessageRef mRequest; 79 | CFReadStreamRef mReadStream; 80 | CFDictionaryRef mResponseHeaders; 81 | bool mEOSReached; 82 | SInt64 mOffset; 83 | SInt64 mDesiredOffset; 84 | 85 | public: 86 | 87 | // ======================================== 88 | // Callbacks- for internal use only 89 | void HandleNetworkEvent(CFReadStreamRef stream, CFStreamEventType type); 90 | }; 91 | -------------------------------------------------------------------------------- /Player/DecoderStateData.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009, 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #include "DecoderStateData.h" 32 | #include "AudioDecoder.h" 33 | #include "AllocateABL.h" 34 | #include "DeallocateABL.h" 35 | 36 | DecoderStateData::DecoderStateData() 37 | : mDecoder(nullptr), mBufferList(nullptr), mBufferCapacityFrames(0), mTimeStamp(0), mTotalFrames(0), mFramesRendered(0), mFrameToSeek(-1), mFlags(0) 38 | {} 39 | 40 | DecoderStateData::DecoderStateData(AudioDecoder *decoder) 41 | : DecoderStateData() 42 | { 43 | assert(nullptr != decoder); 44 | mDecoder = decoder; 45 | 46 | // NB: The decoder may return an estimate of the total frames 47 | mTotalFrames = mDecoder->GetTotalFrames(); 48 | } 49 | 50 | DecoderStateData::~DecoderStateData() 51 | { 52 | // Delete the decoder 53 | if(mDecoder) 54 | delete mDecoder, mDecoder = nullptr; 55 | 56 | DeallocateBufferList(); 57 | } 58 | 59 | void DecoderStateData::AllocateBufferList(UInt32 capacityFrames) 60 | { 61 | DeallocateBufferList(); 62 | 63 | mBufferCapacityFrames = capacityFrames; 64 | mBufferList = AllocateABL(mDecoder->GetFormat(), mBufferCapacityFrames); 65 | } 66 | 67 | void DecoderStateData::DeallocateBufferList() 68 | { 69 | if(mBufferList) { 70 | mBufferCapacityFrames = 0; 71 | mBufferList = DeallocateABL(mBufferList); 72 | } 73 | } 74 | 75 | void DecoderStateData::ResetBufferList() 76 | { 77 | AudioStreamBasicDescription formatDescription = mDecoder->GetFormat(); 78 | 79 | for(UInt32 i = 0; i < mBufferList->mNumberBuffers; ++i) 80 | mBufferList->mBuffers[i].mDataByteSize = mBufferCapacityFrames * formatDescription.mBytesPerFrame; 81 | } 82 | 83 | UInt32 DecoderStateData::ReadAudio(UInt32 frameCount) 84 | { 85 | if(nullptr == mDecoder) 86 | return 0; 87 | 88 | ResetBufferList(); 89 | 90 | return mDecoder->ReadAudio(mBufferList, frameCount); 91 | } 92 | -------------------------------------------------------------------------------- /Metadata/CFDictionaryUtilities.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #include "CFDictionaryUtilities.h" 32 | 33 | void AddIntToDictionary(CFMutableDictionaryRef d, CFStringRef key, int value) 34 | { 35 | if(nullptr == d || nullptr == key) 36 | return; 37 | 38 | CFNumberRef num = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &value); 39 | if(num) { 40 | CFDictionarySetValue(d, key, num); 41 | CFRelease(num), num = nullptr; 42 | } 43 | } 44 | 45 | void AddIntToDictionaryAsString(CFMutableDictionaryRef d, CFStringRef key, int value) 46 | { 47 | if(nullptr == d || nullptr == key) 48 | return; 49 | 50 | CFStringRef str = CFStringCreateWithFormat(kCFAllocatorDefault, nullptr, CFSTR("%d"), value); 51 | if(str) { 52 | CFDictionarySetValue(d, key, str); 53 | CFRelease(str), str = nullptr; 54 | } 55 | } 56 | 57 | void AddLongLongToDictionary(CFMutableDictionaryRef d, CFStringRef key, long long value) 58 | { 59 | if(nullptr == d || nullptr == key) 60 | return; 61 | 62 | CFNumberRef num = CFNumberCreate(kCFAllocatorDefault, kCFNumberLongLongType, &value); 63 | if(num) { 64 | CFDictionarySetValue(d, key, num); 65 | CFRelease(num), num = nullptr; 66 | } 67 | } 68 | 69 | void AddFloatToDictionary(CFMutableDictionaryRef d, CFStringRef key, float value) 70 | { 71 | if(nullptr == d || nullptr == key) 72 | return; 73 | 74 | CFNumberRef num = CFNumberCreate(kCFAllocatorDefault, kCFNumberFloatType, &value); 75 | if(num) { 76 | CFDictionarySetValue(d, key, num); 77 | CFRelease(num), num = nullptr; 78 | } 79 | } 80 | 81 | void AddDoubleToDictionary(CFMutableDictionaryRef d, CFStringRef key, double value) 82 | { 83 | if(nullptr == d || nullptr == key) 84 | return; 85 | 86 | CFNumberRef num = CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, &value); 87 | if(num) { 88 | CFDictionarySetValue(d, key, num); 89 | CFRelease(num), num = nullptr; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /SFBAudioEngine.xcodeproj/xcuserdata/indragie.xcuserdatad/xcschemes/SimplePlayer.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 51 | 52 | 58 | 59 | 60 | 61 | 62 | 63 | 69 | 70 | 76 | 77 | 78 | 79 | 81 | 82 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /SFBAudioEngine.xcodeproj/xcuserdata/indragie.xcuserdatad/xcschemes/SimplePlayer-iOS.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 51 | 52 | 58 | 59 | 60 | 61 | 62 | 63 | 69 | 70 | 76 | 77 | 78 | 79 | 81 | 82 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /Decoders/CoreAudioDecoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | #include "AudioDecoder.h" 35 | 36 | // ======================================== 37 | // An AudioDecoder subclass supporting all formats handled by Core Audio 38 | // ======================================== 39 | class CoreAudioDecoder : public AudioDecoder 40 | { 41 | 42 | public: 43 | 44 | // ======================================== 45 | // The data types handled by this class 46 | static CFArrayRef CreateSupportedFileExtensions(); 47 | static CFArrayRef CreateSupportedMIMETypes(); 48 | 49 | static bool HandlesFilesWithExtension(CFStringRef extension); 50 | static bool HandlesMIMEType(CFStringRef mimeType); 51 | 52 | // ======================================== 53 | // Creation 54 | CoreAudioDecoder(InputSource *inputSource); 55 | 56 | // ======================================== 57 | // Destruction 58 | virtual ~CoreAudioDecoder(); 59 | 60 | // ======================================== 61 | // Audio access 62 | virtual bool Open(CFErrorRef *error = nullptr); 63 | virtual bool Close(CFErrorRef *error = nullptr); 64 | 65 | // ======================================== 66 | // Attempt to read frameCount frames of audio, returning the actual number of frames read 67 | virtual UInt32 ReadAudio(AudioBufferList *bufferList, UInt32 frameCount); 68 | 69 | // ======================================== 70 | // Source audio information 71 | virtual SInt64 GetTotalFrames() const; 72 | virtual SInt64 GetCurrentFrame() const; 73 | 74 | // ======================================== 75 | // Seeking support 76 | virtual inline bool SupportsSeeking() const { return mInputSource->SupportsSeeking(); } 77 | virtual SInt64 SeekToFrame(SInt64 frame); 78 | 79 | private: 80 | 81 | AudioFileID mAudioFile; 82 | ExtAudioFileRef mExtAudioFile; 83 | bool mUseM4AWorkarounds; 84 | SInt64 mCurrentFrame; 85 | }; 86 | -------------------------------------------------------------------------------- /Input/InputSource.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #include "InputSource.h" 32 | #include "FileInputSource.h" 33 | #include "MemoryMappedFileInputSource.h" 34 | #include "InMemoryFileInputSource.h" 35 | #include "HTTPInputSource.h" 36 | 37 | // ======================================== 38 | // Error Codes 39 | // ======================================== 40 | const CFStringRef InputSourceErrorDomain = CFSTR("org.sbooth.AudioEngine.ErrorDomain.InputSource"); 41 | 42 | #pragma mark Static Methods 43 | 44 | InputSource * InputSource::CreateInputSourceForURL(CFURLRef url, int flags, CFErrorRef *error) 45 | { 46 | if(nullptr == url) 47 | return nullptr; 48 | 49 | InputSource *inputSource = nullptr; 50 | 51 | CFStringRef scheme = CFURLCopyScheme(url); 52 | 53 | // If there is no scheme the URL is invalid 54 | if(nullptr == scheme) { 55 | if(error) 56 | *error = CFErrorCreate(kCFAllocatorDefault, kCFErrorDomainPOSIX, EINVAL, nullptr); 57 | return nullptr; 58 | } 59 | 60 | if(kCFCompareEqualTo == CFStringCompare(CFSTR("file"), scheme, kCFCompareCaseInsensitive)) { 61 | if(InputSourceFlagMemoryMapFiles & flags) 62 | inputSource = new MemoryMappedFileInputSource(url); 63 | else if(InputSourceFlagLoadFilesInMemory & flags) 64 | inputSource = new InMemoryFileInputSource(url); 65 | else 66 | inputSource = new FileInputSource(url); 67 | } 68 | else if(kCFCompareEqualTo == CFStringCompare(CFSTR("http"), scheme, kCFCompareCaseInsensitive)) 69 | inputSource = new HTTPInputSource(url); 70 | 71 | CFRelease(scheme), scheme = nullptr; 72 | 73 | return inputSource; 74 | } 75 | 76 | #pragma mark Creation and Destruction 77 | 78 | InputSource::InputSource() 79 | : mURL(nullptr), mIsOpen(false) 80 | {} 81 | 82 | InputSource::InputSource(CFURLRef url) 83 | : mURL(nullptr), mIsOpen(false) 84 | { 85 | assert(nullptr != url); 86 | 87 | mURL = static_cast(CFRetain(url)); 88 | } 89 | 90 | InputSource::~InputSource() 91 | { 92 | if(mURL) 93 | CFRelease(mURL), mURL = nullptr; 94 | } 95 | -------------------------------------------------------------------------------- /Decoders/MonkeysAudioDecoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | #include 35 | 36 | #import "AudioDecoder.h" 37 | 38 | class APEIOInterface; 39 | class IAPEDecompress; 40 | 41 | // ======================================== 42 | // An AudioDecoder subclass supporting Monkey's Audio 43 | // ======================================== 44 | class MonkeysAudioDecoder : public AudioDecoder 45 | { 46 | 47 | public: 48 | 49 | // ======================================== 50 | // The data types handled by this class 51 | static CFArrayRef CreateSupportedFileExtensions(); 52 | static CFArrayRef CreateSupportedMIMETypes(); 53 | 54 | static bool HandlesFilesWithExtension(CFStringRef extension); 55 | static bool HandlesMIMEType(CFStringRef mimeType); 56 | 57 | // ======================================== 58 | // Creation 59 | MonkeysAudioDecoder(InputSource *inputSource); 60 | 61 | // ======================================== 62 | // Destruction 63 | virtual ~MonkeysAudioDecoder(); 64 | 65 | // ======================================== 66 | // Audio access 67 | virtual bool Open(CFErrorRef *error = nullptr); 68 | virtual bool Close(CFErrorRef *error = nullptr); 69 | 70 | // ======================================== 71 | // The native format of the source audio 72 | virtual CFStringRef CreateSourceFormatDescription() const; 73 | 74 | // ======================================== 75 | // Attempt to read frameCount frames of audio, returning the actual number of frames read 76 | virtual UInt32 ReadAudio(AudioBufferList *bufferList, UInt32 frameCount); 77 | 78 | // ======================================== 79 | // Source audio information 80 | virtual inline SInt64 GetTotalFrames() const; 81 | virtual inline SInt64 GetCurrentFrame() const; 82 | 83 | // ======================================== 84 | // Seeking support 85 | virtual inline bool SupportsSeeking() const { return mInputSource->SupportsSeeking(); } 86 | virtual SInt64 SeekToFrame(SInt64 frame); 87 | 88 | private: 89 | 90 | APEIOInterface *mIOInterface; 91 | IAPEDecompress *mDecompressor; 92 | }; 93 | -------------------------------------------------------------------------------- /Semaphore.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010, 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #include 32 | #include 33 | 34 | #include "Semaphore.h" 35 | #include "Logger.h" 36 | 37 | Semaphore::Semaphore() 38 | { 39 | kern_return_t result = semaphore_create(mach_task_self(), &mSemaphore, SYNC_POLICY_FIFO, 0); 40 | 41 | if(KERN_SUCCESS != result) { 42 | LOGGER_CRIT("org.sbooth.AudioEngine.Semaphore", "semaphore_create failed: " << mach_error_string(result)); 43 | throw std::runtime_error("Unable to create the semaphore"); 44 | } 45 | } 46 | 47 | Semaphore::~Semaphore() 48 | { 49 | kern_return_t result = semaphore_destroy(mach_task_self(), mSemaphore); 50 | 51 | if(KERN_SUCCESS != result) 52 | LOGGER_ERR("org.sbooth.AudioEngine.Semaphore", "semaphore_destroy failed: " << mach_error_string(result)); 53 | } 54 | 55 | bool Semaphore::Signal() 56 | { 57 | kern_return_t result = semaphore_signal(mSemaphore); 58 | 59 | if(KERN_SUCCESS != result) { 60 | LOGGER_WARNING("org.sbooth.AudioEngine.Semaphore", "Couldn't signal the semaphore: " << mach_error_string(result)); 61 | return false; 62 | } 63 | 64 | return true; 65 | } 66 | 67 | bool Semaphore::SignalAll() 68 | { 69 | kern_return_t result = semaphore_signal_all(mSemaphore); 70 | 71 | if(KERN_SUCCESS != result) { 72 | LOGGER_WARNING("org.sbooth.AudioEngine.Semaphore", "Couldn't signal the semaphore: " << mach_error_string(result)); 73 | return false; 74 | } 75 | 76 | return true; 77 | } 78 | 79 | bool Semaphore::Wait() 80 | { 81 | kern_return_t result = semaphore_wait(mSemaphore); 82 | 83 | if(KERN_SUCCESS != result) { 84 | LOGGER_WARNING("org.sbooth.AudioEngine.Semaphore", "Semaphore couldn't wait: " << mach_error_string(result)); 85 | return false; 86 | } 87 | 88 | return true; 89 | } 90 | 91 | bool Semaphore::TimedWait(mach_timespec_t duration) 92 | { 93 | kern_return_t result = semaphore_timedwait(mSemaphore, duration); 94 | 95 | if(KERN_SUCCESS != result && KERN_OPERATION_TIMED_OUT != result) { 96 | LOGGER_WARNING("org.sbooth.AudioEngine.Semaphore", "Semaphore couldn't timedwait: " << mach_error_string(result)); 97 | return false; 98 | } 99 | 100 | return true; 101 | } 102 | -------------------------------------------------------------------------------- /Decoders/MODDecoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, 2012 Stephen F. Booth 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * - Neither the name of Stephen F. Booth nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | #include 35 | 36 | #include 37 | 38 | #import "AudioDecoder.h" 39 | 40 | // ======================================== 41 | // An AudioDecoder subclass supporting MOD files 42 | // ======================================== 43 | class MODDecoder : public AudioDecoder 44 | { 45 | 46 | public: 47 | 48 | // ======================================== 49 | // The data types handled by this class 50 | static CFArrayRef CreateSupportedFileExtensions(); 51 | static CFArrayRef CreateSupportedMIMETypes(); 52 | 53 | static bool HandlesFilesWithExtension(CFStringRef extension); 54 | static bool HandlesMIMEType(CFStringRef mimeType); 55 | 56 | // ======================================== 57 | // Creation 58 | MODDecoder(InputSource *inputSource); 59 | 60 | // ======================================== 61 | // Destruction 62 | virtual ~MODDecoder(); 63 | 64 | // ======================================== 65 | // Audio access 66 | virtual bool Open(CFErrorRef *error = nullptr); 67 | virtual bool Close(CFErrorRef *error = nullptr); 68 | 69 | // ======================================== 70 | // The native format of the source audio 71 | virtual CFStringRef CreateSourceFormatDescription() const; 72 | 73 | // ======================================== 74 | // Attempt to read frameCount frames of audio, returning the actual number of frames read 75 | virtual UInt32 ReadAudio(AudioBufferList *bufferList, UInt32 frameCount); 76 | 77 | // ======================================== 78 | // Source audio information 79 | virtual inline SInt64 GetTotalFrames() const { return mTotalFrames; } 80 | virtual inline SInt64 GetCurrentFrame() const { return mCurrentFrame; } 81 | 82 | // ======================================== 83 | // Seeking support 84 | virtual inline bool SupportsSeeking() const { return mInputSource->SupportsSeeking(); } 85 | virtual SInt64 SeekToFrame(SInt64 frame); 86 | 87 | private: 88 | 89 | DUMBFILE_SYSTEM dfs; 90 | DUMBFILE *df; 91 | DUH *duh; 92 | DUH_SIGRENDERER *dsr; 93 | 94 | SInt64 mTotalFrames; 95 | SInt64 mCurrentFrame; 96 | }; 97 | --------------------------------------------------------------------------------