forked from decarbonization/PlayerKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PlayerKitDefines.cpp
48 lines (36 loc) · 1.49 KB
/
PlayerKitDefines.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
* PlayerKitDefines.h
* PlayerKit
*
* Created by Peter MacWhinnie on 7/1/08.
* Copyright 2008 Roundabout Software. All rights reserved.
*
*/
#import "CAStreamBasicDescription.h"
CFStringRef const PKEffectsErrorDomain = CFSTR("PKEffectsErrorDomain");
CFStringRef const PKPlaybackErrorDomain = CFSTR("PKPlaybackErrorDomain");
Float64 const kPKCanonicalSampleRate = 44100.0;
UInt64 const kPKCanonicalBaseBufferSize = (1024 * 10);
extern "C" Boolean PKStreamFormatIsCanonical(AudioStreamBasicDescription inFormat)
{
CAStreamBasicDescription format(inFormat);
return format.IsCanonical() && !format.IsInterleaved() && (format.mSampleRate == kPKCanonicalSampleRate);
}
#pragma mark -
extern "C" CFErrorRef PKCopyError(CFStringRef domain, CFIndex errorCode, CFDictionaryRef inUserInfo, CFStringRef format, ...)
{
va_list formatList;
va_start(formatList, format);
CFStringRef errorString = CFStringCreateWithFormatAndArguments(kCFAllocatorDefault, NULL, format, formatList);
va_end(formatList);
CFMutableDictionaryRef userInfo = NULL;
if(inUserInfo)
userInfo = CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 0, inUserInfo);
else
userInfo = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
CFDictionarySetValue(userInfo, kCFErrorLocalizedDescriptionKey, errorString);
CFErrorRef error = CFErrorCreate(kCFAllocatorDefault, domain, errorCode, userInfo);
CFRelease(errorString);
CFRelease(userInfo);
return error;
}