2006-01-20 15:34:02 +00:00
|
|
|
//
|
|
|
|
// OutputCoreAudio.h
|
|
|
|
// Cog
|
|
|
|
//
|
2006-09-04 18:46:18 +00:00
|
|
|
// Created by Vincent Spader on 8/2/05.
|
|
|
|
// Copyright 2005 Vincent Spader. All rights reserved.
|
2006-01-20 15:34:02 +00:00
|
|
|
//
|
|
|
|
|
2020-03-23 08:46:41 +00:00
|
|
|
#import <AssertMacros.h>
|
2006-01-20 15:34:02 +00:00
|
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
#import <AVFoundation/AVFoundation.h>
|
2006-01-20 15:34:02 +00:00
|
|
|
#import <AudioToolbox/AudioToolbox.h>
|
|
|
|
#import <AudioUnit/AudioUnit.h>
|
2022-02-07 05:49:27 +00:00
|
|
|
#import <CoreAudio/AudioHardware.h>
|
2022-01-16 15:32:47 +00:00
|
|
|
#import <CoreAudio/CoreAudioTypes.h>
|
2006-01-20 15:34:02 +00:00
|
|
|
|
2022-01-15 10:09:26 +00:00
|
|
|
#import <stdatomic.h>
|
|
|
|
|
2022-02-06 11:08:34 +00:00
|
|
|
#import "Downmix.h"
|
|
|
|
|
2022-02-13 07:04:03 +00:00
|
|
|
#import "VisualizationController.h"
|
|
|
|
|
2022-01-15 06:46:41 +00:00
|
|
|
#import "Semaphore.h"
|
|
|
|
|
2022-01-19 08:41:42 +00:00
|
|
|
//#define OUTPUT_LOG
|
|
|
|
#ifdef OUTPUT_LOG
|
|
|
|
#import <stdio.h>
|
|
|
|
#endif
|
|
|
|
|
2007-02-24 20:36:27 +00:00
|
|
|
@class OutputNode;
|
|
|
|
|
2006-01-20 15:34:02 +00:00
|
|
|
@interface OutputCoreAudio : NSObject {
|
2022-02-07 05:49:27 +00:00
|
|
|
OutputNode *outputController;
|
|
|
|
|
|
|
|
Semaphore *writeSemaphore;
|
|
|
|
Semaphore *readSemaphore;
|
|
|
|
|
|
|
|
BOOL stopInvoked;
|
|
|
|
BOOL running;
|
|
|
|
BOOL stopping;
|
|
|
|
BOOL stopped;
|
|
|
|
BOOL started;
|
|
|
|
BOOL paused;
|
|
|
|
BOOL stopNext;
|
2022-02-08 06:44:56 +00:00
|
|
|
BOOL restarted;
|
2022-02-07 05:49:27 +00:00
|
|
|
|
|
|
|
BOOL eqEnabled;
|
|
|
|
|
|
|
|
BOOL streamFormatStarted;
|
|
|
|
|
|
|
|
atomic_long bytesRendered;
|
|
|
|
atomic_long bytesHdcdSustained;
|
|
|
|
|
|
|
|
BOOL listenerapplied;
|
|
|
|
BOOL observersapplied;
|
|
|
|
|
|
|
|
float volume;
|
2022-02-14 07:37:58 +00:00
|
|
|
float eqPreamp;
|
2022-02-07 05:49:27 +00:00
|
|
|
|
|
|
|
AVAudioFormat *_deviceFormat;
|
|
|
|
|
|
|
|
AudioDeviceID outputDeviceID;
|
|
|
|
AudioStreamBasicDescription deviceFormat; // info about the default device
|
|
|
|
AudioStreamBasicDescription streamFormat; // stream format last seen in render callback
|
|
|
|
|
2022-02-13 07:04:03 +00:00
|
|
|
AudioStreamBasicDescription visFormat; // Mono format for vis
|
|
|
|
|
2022-02-07 08:56:05 +00:00
|
|
|
uint32_t deviceChannelConfig;
|
|
|
|
uint32_t streamChannelConfig;
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
AUAudioUnit *_au;
|
|
|
|
size_t _bufferSize;
|
|
|
|
|
|
|
|
AudioUnit _eq;
|
|
|
|
|
|
|
|
DownmixProcessor *downmixer;
|
2022-02-13 07:04:03 +00:00
|
|
|
DownmixProcessor *downmixerForVis;
|
|
|
|
|
|
|
|
VisualizationController *visController;
|
2022-02-07 05:49:27 +00:00
|
|
|
|
2022-01-19 08:41:42 +00:00
|
|
|
#ifdef OUTPUT_LOG
|
2022-02-07 05:49:27 +00:00
|
|
|
FILE *_logFile;
|
2022-01-19 08:41:42 +00:00
|
|
|
#endif
|
2006-01-20 15:34:02 +00:00
|
|
|
}
|
|
|
|
|
2007-02-24 20:36:27 +00:00
|
|
|
- (id)initWithController:(OutputNode *)c;
|
2006-01-20 15:34:02 +00:00
|
|
|
|
|
|
|
- (BOOL)setup;
|
2020-02-17 17:20:48 +00:00
|
|
|
- (OSStatus)setOutputDeviceByID:(AudioDeviceID)deviceID;
|
|
|
|
- (BOOL)setOutputDeviceWithDeviceDict:(NSDictionary *)deviceDict;
|
2006-01-20 15:34:02 +00:00
|
|
|
- (void)start;
|
2007-02-20 01:02:23 +00:00
|
|
|
- (void)pause;
|
|
|
|
- (void)resume;
|
|
|
|
- (void)stop;
|
2006-01-20 15:34:02 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (void)setVolume:(double)v;
|
2006-01-20 15:34:02 +00:00
|
|
|
|
2022-01-17 09:22:15 +00:00
|
|
|
- (void)setEqualizerEnabled:(BOOL)enabled;
|
|
|
|
|
2022-01-19 10:08:57 +00:00
|
|
|
- (void)sustainHDCD;
|
|
|
|
|
2006-01-20 15:34:02 +00:00
|
|
|
@end
|