2007-02-24 20:36:27 +00:00
|
|
|
//
|
|
|
|
// AudioController.h
|
|
|
|
// Cog
|
|
|
|
//
|
|
|
|
// Created by Vincent Spader on 8/7/05.
|
|
|
|
// Copyright 2005 Vincent Spader. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
|
2022-01-14 07:05:32 +00:00
|
|
|
#import <CogAudio/Semaphore.h>
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
#import <AVFoundation/AVFoundation.h>
|
2022-01-16 15:32:47 +00:00
|
|
|
#import <AudioToolbox/AudioToolbox.h>
|
|
|
|
#import <AudioUnit/AudioUnit.h>
|
2022-02-07 05:49:27 +00:00
|
|
|
#import <CoreAudio/CoreAudio.h>
|
2022-01-16 15:32:47 +00:00
|
|
|
#import <CoreAudio/CoreAudioTypes.h>
|
|
|
|
|
2022-06-06 15:18:33 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
#import <atomic>
|
|
|
|
using std::atomic_int;
|
|
|
|
using std::atomic_bool;
|
|
|
|
#else
|
2022-01-14 07:05:32 +00:00
|
|
|
#import <stdatomic.h>
|
2022-06-06 15:18:33 +00:00
|
|
|
#endif
|
2022-01-14 07:05:32 +00:00
|
|
|
|
2007-02-24 20:36:27 +00:00
|
|
|
@class BufferChain;
|
|
|
|
@class OutputNode;
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
@interface AudioPlayer : NSObject {
|
2007-02-24 20:36:27 +00:00
|
|
|
BufferChain *bufferChain;
|
|
|
|
OutputNode *output;
|
2022-02-07 05:49:27 +00:00
|
|
|
|
2008-02-13 01:50:39 +00:00
|
|
|
double volume;
|
|
|
|
|
2007-02-24 20:36:27 +00:00
|
|
|
NSMutableArray *chainQueue;
|
2022-02-07 05:49:27 +00:00
|
|
|
|
2007-02-24 20:36:27 +00:00
|
|
|
NSURL *nextStream;
|
|
|
|
id nextStreamUserInfo;
|
2022-02-07 05:49:27 +00:00
|
|
|
NSDictionary *nextStreamRGInfo;
|
|
|
|
|
2022-06-28 04:46:36 +00:00
|
|
|
id previousUserInfo; // Track currently last heard track for play counts
|
|
|
|
|
2007-02-24 20:36:27 +00:00
|
|
|
id delegate;
|
2022-02-07 05:49:27 +00:00
|
|
|
|
2007-03-19 00:19:47 +00:00
|
|
|
BOOL outputLaunched;
|
2009-02-28 19:11:22 +00:00
|
|
|
BOOL endOfInputReached;
|
2022-02-07 05:49:27 +00:00
|
|
|
BOOL startedPaused;
|
|
|
|
BOOL initialBufferFilled;
|
|
|
|
|
|
|
|
Semaphore *semaphore;
|
|
|
|
|
|
|
|
atomic_bool resettingNow;
|
|
|
|
atomic_int refCount;
|
|
|
|
|
|
|
|
int currentPlaybackStatus;
|
|
|
|
|
|
|
|
BOOL shouldContinue;
|
2007-02-24 20:36:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (id)init;
|
|
|
|
|
|
|
|
- (void)setDelegate:(id)d;
|
|
|
|
- (id)delegate;
|
|
|
|
|
|
|
|
- (void)play:(NSURL *)url;
|
2022-02-07 05:49:27 +00:00
|
|
|
- (void)play:(NSURL *)url withUserInfo:(id)userInfo withRGInfo:(NSDictionary *)rgi;
|
|
|
|
- (void)play:(NSURL *)url withUserInfo:(id)userInfo withRGInfo:(NSDictionary *)rgi startPaused:(BOOL)paused;
|
|
|
|
- (void)play:(NSURL *)url withUserInfo:(id)userInfo withRGInfo:(NSDictionary *)rgi startPaused:(BOOL)paused andSeekTo:(double)time;
|
2007-02-24 20:36:27 +00:00
|
|
|
|
|
|
|
- (void)stop;
|
|
|
|
- (void)pause;
|
|
|
|
- (void)resume;
|
|
|
|
|
|
|
|
- (void)seekToTime:(double)time;
|
|
|
|
- (void)setVolume:(double)v;
|
2008-02-13 01:50:39 +00:00
|
|
|
- (double)volume;
|
2008-02-17 18:44:11 +00:00
|
|
|
- (double)volumeUp:(double)amount;
|
|
|
|
- (double)volumeDown:(double)amount;
|
2007-02-24 20:36:27 +00:00
|
|
|
|
|
|
|
- (double)amountPlayed;
|
2022-06-19 06:00:08 +00:00
|
|
|
- (double)amountPlayedInterval;
|
2007-02-24 20:36:27 +00:00
|
|
|
|
|
|
|
- (void)setNextStream:(NSURL *)url;
|
2022-02-07 05:49:27 +00:00
|
|
|
- (void)setNextStream:(NSURL *)url withUserInfo:(id)userInfo withRGInfo:(NSDictionary *)rgi;
|
2009-02-28 18:57:21 +00:00
|
|
|
- (void)resetNextStreams;
|
2007-02-24 20:36:27 +00:00
|
|
|
|
2022-02-08 06:44:56 +00:00
|
|
|
- (void)restartPlaybackAtCurrentPosition;
|
|
|
|
|
2022-02-12 15:29:02 +00:00
|
|
|
- (void)pushInfo:(NSDictionary *)info toTrack:(id)userInfo;
|
2022-02-09 03:56:39 +00:00
|
|
|
|
2007-02-24 20:36:27 +00:00
|
|
|
+ (NSArray *)fileTypes;
|
2007-03-09 01:16:06 +00:00
|
|
|
+ (NSArray *)schemes;
|
2007-10-09 01:20:46 +00:00
|
|
|
+ (NSArray *)containerTypes;
|
2007-02-24 20:36:27 +00:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
@interface AudioPlayer (Private) // Dont use this stuff!
|
2007-02-24 20:36:27 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (OutputNode *)output;
|
|
|
|
- (BufferChain *)bufferChain;
|
2007-02-24 20:36:27 +00:00
|
|
|
- (id)initWithDelegate:(id)d;
|
|
|
|
|
2008-02-22 03:46:04 +00:00
|
|
|
- (void)setPlaybackStatus:(int)status waitUntilDone:(BOOL)wait;
|
2007-02-24 20:36:27 +00:00
|
|
|
- (void)setPlaybackStatus:(int)s;
|
|
|
|
|
|
|
|
- (void)requestNextStream:(id)userInfo;
|
|
|
|
- (void)requestNextStreamMainThread:(id)userInfo;
|
2009-02-28 18:57:21 +00:00
|
|
|
|
2007-02-24 20:36:27 +00:00
|
|
|
- (void)notifyStreamChanged:(id)userInfo;
|
|
|
|
- (void)notifyStreamChangedMainThread:(id)userInfo;
|
|
|
|
|
2022-01-18 04:43:08 +00:00
|
|
|
- (void)beginEqualizer:(AudioUnit)eq;
|
|
|
|
- (void)refreshEqualizer:(AudioUnit)eq;
|
|
|
|
- (void)endEqualizer:(AudioUnit)eq;
|
|
|
|
|
2007-10-11 02:08:29 +00:00
|
|
|
- (BOOL)endOfInputReached:(BufferChain *)sender;
|
2007-02-24 20:36:27 +00:00
|
|
|
- (void)setShouldContinue:(BOOL)s;
|
2016-06-30 05:10:29 +00:00
|
|
|
//- (BufferChain *)bufferChain;
|
2007-03-19 00:19:47 +00:00
|
|
|
- (void)launchOutputThread;
|
2022-06-24 06:17:31 +00:00
|
|
|
- (BOOL)selectNextBuffer;
|
2007-02-24 20:36:27 +00:00
|
|
|
- (void)endOfInputPlayed;
|
2022-06-19 06:00:08 +00:00
|
|
|
- (void)reportPlayCount;
|
2022-02-07 05:49:27 +00:00
|
|
|
- (void)sendDelegateMethod:(SEL)selector withVoid:(void *)obj waitUntilDone:(BOOL)wait;
|
2007-02-24 20:36:27 +00:00
|
|
|
- (void)sendDelegateMethod:(SEL)selector withObject:(id)obj waitUntilDone:(BOOL)wait;
|
2009-03-05 17:03:30 +00:00
|
|
|
- (void)sendDelegateMethod:(SEL)selector withObject:(id)obj withObject:(id)obj2 waitUntilDone:(BOOL)wait;
|
2022-01-15 10:09:26 +00:00
|
|
|
|
|
|
|
- (BOOL)chainQueueHasTracks;
|
2007-02-24 20:36:27 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
@protocol AudioPlayerDelegate
|
2022-02-07 05:49:27 +00:00
|
|
|
- (void)audioPlayer:(AudioPlayer *)player willEndStream:(id)userInfo; // You must use setNextStream in this method
|
2009-03-05 17:03:30 +00:00
|
|
|
- (void)audioPlayer:(AudioPlayer *)player didBeginStream:(id)userInfo;
|
2021-09-25 20:17:00 +00:00
|
|
|
- (void)audioPlayer:(AudioPlayer *)player didChangeStatus:(id)status userInfo:(id)userInfo;
|
2022-02-22 04:55:42 +00:00
|
|
|
- (void)audioPlayer:(AudioPlayer *)player didStopNaturally:(id)userInfo;
|
2022-01-16 15:32:47 +00:00
|
|
|
- (void)audioPlayer:(AudioPlayer *)player displayEqualizer:(AudioUnit)eq;
|
2022-01-18 04:43:08 +00:00
|
|
|
- (void)audioPlayer:(AudioPlayer *)player refreshEqualizer:(AudioUnit)eq;
|
2022-01-16 15:32:47 +00:00
|
|
|
- (void)audioPlayer:(AudioPlayer *)player removeEqualizer:(AudioUnit)eq;
|
2022-01-21 07:53:45 +00:00
|
|
|
- (void)audioPlayer:(AudioPlayer *)player sustainHDCD:(id)userInfo;
|
2022-02-08 06:44:56 +00:00
|
|
|
- (void)audioPlayer:(AudioPlayer *)player restartPlaybackAtCurrentPosition:(id)userInfo;
|
2022-02-09 03:56:39 +00:00
|
|
|
- (void)audioPlayer:(AudioPlayer *)player pushInfo:(NSDictionary *)info toTrack:(id)userInfo;
|
2022-06-19 06:00:08 +00:00
|
|
|
- (void)audioPlayer:(AudioPlayer *)player reportPlayCountForTrack:(id)userInfo;
|
2022-02-10 10:15:48 +00:00
|
|
|
- (void)audioPlayer:(AudioPlayer *)player setError:(NSNumber *)status toTrack:(id)userInfo;
|
2007-02-24 20:36:27 +00:00
|
|
|
@end
|