-
Notifications
You must be signed in to change notification settings - Fork 2
/
PKAudioPlayerInternal.h
56 lines (42 loc) · 1.65 KB
/
PKAudioPlayerInternal.h
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
49
50
51
52
53
54
55
56
/*
* PKAudioPlayerInternal.h
* PlayerKit
*
* Created by Peter MacWhinnie on 10/16/10.
* Copyright 2010 __MyCompanyName__. All rights reserved.
*
*/
#import "PKAudioPlayer.h"
#import <AudioToolbox/AudioToolbox.h>
#import "PKAudioPlayerEngine.h"
#import "PKDecoder.h"
#pragma mark Types
///The struct used to represent the internal state of the PKAudioPlayer.
typedef struct PKAudioPlayer {
//Engine
PKAudioPlayerEngine *engine;
//Decoder
PKDecoder *decoder;
AudioConverterRef decoderConverter;
AudioBufferList *decoderConverterBuffers;
//State
volatile int32_t isPaused;
volatile int32_t hasBroadcastedPresence;
volatile int32_t preserveExistingBuffersOnResume;
CFStringRef sessionID;
//Pulse
dispatch_block_t mPulseHandler;
dispatch_queue_t mPulseHandlerQueue;
} PKAudioPlayer;
///The singleton instance of the audio player state.
PK_EXTERN PK_VISIBILITY_HIDDEN PKAudioPlayer AudioPlayerState;
#pragma mark -
#pragma mark Tools
#define CFDICT(keys, values) CFDictionaryCreate(kCFAllocatorDefault, (const void *[])keys, (const void *[])values, sizeof((const void *[])keys) / sizeof(const void *), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)
#define CHECK_STATE_INITIALIZED() ({ if(OSMemoryBarrier(), AudioPlayerStateInitCount == 0) RBAssert(0, CFSTR("Attempted use of PKAudioPlayer before PKAudioPlayerInit has been called.")); })
#pragma mark -
#pragma mark Controlling Playback
///Set the decoder for the audio player to use.
PK_EXTERN Boolean PKAudioPlayerSetDecoder(PKDecoder *decoder, CFErrorRef *outError);
///Get the decoder the audio player is currently using, if any.
PK_EXTERN PKDecoder *PKAudioPlayerGetDecoder();