2006-01-20 15:34:02 +00:00
|
|
|
//
|
2006-04-02 15:44:08 +00:00
|
|
|
// Node.h
|
2006-01-20 15:34:02 +00:00
|
|
|
// CogNew
|
|
|
|
//
|
2006-09-04 18:46:18 +00:00
|
|
|
// Created by Vincent Spader on 1/4/06.
|
|
|
|
// Copyright 2006 Vincent Spader. All rights reserved.
|
2006-01-20 15:34:02 +00:00
|
|
|
//
|
|
|
|
|
2022-02-06 11:08:34 +00:00
|
|
|
#import "ChunkList.h"
|
2006-01-20 15:34:02 +00:00
|
|
|
#import "Semaphore.h"
|
2022-02-07 05:49:27 +00:00
|
|
|
#import <Cocoa/Cocoa.h>
|
2006-01-20 15:34:02 +00:00
|
|
|
|
2022-06-09 07:27:55 +00:00
|
|
|
#import <os/workgroup.h>
|
|
|
|
|
2007-03-04 16:00:26 +00:00
|
|
|
#define BUFFER_SIZE 1024 * 1024
|
2006-01-20 15:34:02 +00:00
|
|
|
#define CHUNK_SIZE 16 * 1024
|
|
|
|
|
|
|
|
@interface Node : NSObject {
|
2022-02-06 11:08:34 +00:00
|
|
|
ChunkList *buffer;
|
2022-02-07 05:49:27 +00:00
|
|
|
Semaphore *semaphore;
|
|
|
|
|
|
|
|
NSRecursiveLock *accessLock;
|
|
|
|
|
2016-05-05 20:05:39 +00:00
|
|
|
id __weak previousNode;
|
|
|
|
id __weak controller;
|
2022-02-07 05:49:27 +00:00
|
|
|
|
2007-10-03 20:23:14 +00:00
|
|
|
BOOL shouldReset;
|
2022-02-07 05:49:27 +00:00
|
|
|
|
|
|
|
BOOL shouldContinue;
|
|
|
|
BOOL endOfStream; // All data is now in buffer
|
2007-03-19 00:19:47 +00:00
|
|
|
BOOL initialBufferFilled;
|
2022-02-07 05:49:27 +00:00
|
|
|
|
|
|
|
AudioStreamBasicDescription nodeFormat;
|
2022-02-07 08:56:05 +00:00
|
|
|
uint32_t nodeChannelConfig;
|
2022-02-07 05:49:27 +00:00
|
|
|
BOOL nodeLossless;
|
2022-06-09 07:27:55 +00:00
|
|
|
|
|
|
|
os_workgroup_t wg;
|
|
|
|
os_workgroup_join_token_s wgToken;
|
2006-01-20 15:34:02 +00:00
|
|
|
}
|
2022-02-08 03:18:45 +00:00
|
|
|
- (id _Nullable)initWithController:(id _Nonnull)c previous:(id _Nullable)p;
|
2006-01-20 15:34:02 +00:00
|
|
|
|
2022-02-08 03:18:45 +00:00
|
|
|
- (void)writeData:(const void *_Nonnull)ptr amount:(size_t)a;
|
|
|
|
- (AudioChunk *_Nonnull)readChunk:(size_t)maxFrames;
|
|
|
|
|
|
|
|
- (BOOL)peekFormat:(AudioStreamBasicDescription *_Nonnull)format channelConfig:(uint32_t *_Nonnull)config;
|
2006-01-20 15:34:02 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (void)process; // Should be overwriten by subclass
|
2022-02-08 03:18:45 +00:00
|
|
|
- (void)threadEntry:(id _Nullable)arg;
|
2006-01-20 15:34:02 +00:00
|
|
|
|
2022-06-09 07:27:55 +00:00
|
|
|
- (void)followWorkgroup;
|
|
|
|
- (void)leaveWorkgroup;
|
|
|
|
|
2006-01-20 15:34:02 +00:00
|
|
|
- (void)launchThread;
|
|
|
|
|
2007-10-03 20:23:14 +00:00
|
|
|
- (void)setShouldReset:(BOOL)s;
|
|
|
|
- (BOOL)shouldReset;
|
|
|
|
|
2022-02-08 03:18:45 +00:00
|
|
|
- (void)setPreviousNode:(id _Nullable)p;
|
|
|
|
- (id _Nullable)previousNode;
|
2006-01-20 15:34:02 +00:00
|
|
|
|
|
|
|
- (BOOL)shouldContinue;
|
|
|
|
- (void)setShouldContinue:(BOOL)s;
|
|
|
|
|
2022-02-08 03:18:45 +00:00
|
|
|
- (ChunkList *_Nonnull)buffer;
|
2022-02-07 05:49:27 +00:00
|
|
|
- (void)resetBuffer; // WARNING! DANGER WILL ROBINSON!
|
2006-01-20 15:34:02 +00:00
|
|
|
|
2022-02-06 11:08:34 +00:00
|
|
|
- (AudioStreamBasicDescription)nodeFormat;
|
2022-02-07 08:56:05 +00:00
|
|
|
- (uint32_t)nodeChannelConfig;
|
2022-02-06 11:08:34 +00:00
|
|
|
- (BOOL)nodeLossless;
|
|
|
|
|
2022-02-08 03:18:45 +00:00
|
|
|
- (Semaphore *_Nonnull)semaphore;
|
2006-01-20 15:34:02 +00:00
|
|
|
|
2016-06-30 05:10:29 +00:00
|
|
|
//-(void)resetBuffer;
|
2007-10-03 20:23:14 +00:00
|
|
|
|
2006-04-02 15:44:08 +00:00
|
|
|
- (BOOL)endOfStream;
|
|
|
|
- (void)setEndOfStream:(BOOL)e;
|
2006-01-20 15:34:02 +00:00
|
|
|
|
2022-01-14 07:05:32 +00:00
|
|
|
- (double)secondsBuffered;
|
|
|
|
|
2006-01-20 15:34:02 +00:00
|
|
|
@end
|