MusicKit  0.0.0
SndStreamClient.h
00001 
00002 //
00003 //  $Id$
00004 //
00005 //  Original Author: SKoT McDonald, <skot@tomandandy.com>
00006 //
00007 //  Copyright (c) 2001, The MusicKit Project.  All rights reserved.
00008 //
00009 //  Permission is granted to use and modify this code for commercial and 
00010 //  non-commercial purposes so long as the author attribution and copyright 
00011 //  messages remain intact and accompany all relevant code.
00012 //
00014 
00015 #ifndef __SNDSTREAMCLIENT__
00016 #define __SNDSTREAMCLIENT__
00017 
00018 #import <Foundation/Foundation.h>
00019 
00020 // Output buffer lock states (conditions).
00021 enum {
00022     OB_notInit,
00023     OB_isInit
00024 };
00025 
00026 @class SndAudioBuffer; 
00027 @class SndAudioBufferQueue;
00028 @class SndStreamManager;
00029 @class SndAudioProcessorChain;
00030 
00032 // SndStreamClientDelegate
00034 
00040 @protocol SndStreamClientDelegate
00041 
00046 - inputBufferSkipped: (id) sender;
00047 
00052 - outputBufferSkipped: (id) sender;
00053 
00058 - didProcessStreamBuffer: (id) sender;
00059 
00060 @end
00061 
00063 // SndStreamClient
00065 
00092 @interface SndStreamClient : NSObject
00093 {
00095     SndAudioBuffer  *exposedOutputBuffer;
00097     SndAudioBuffer  *synthOutputBuffer;
00099     SndAudioBuffer  *synthInputBuffer;
00101     SndAudioBufferQueue *outputQueue;
00103     SndAudioBufferQueue *inputQueue;
00104     
00106     NSConditionLock *synthThreadLock;
00108     NSConditionLock *outputBufferLock;
00110     NSConditionLock *managerConnectionLock;
00111     
00113     BOOL       active;
00115     BOOL       needsInput;
00117     BOOL       generatesOutput;
00119     SndAudioProcessorChain *processorChain;
00121     SndStreamManager *manager;
00123     id         delegate;    
00125     double     clientNowTime;
00129     double     lastManagerTime;
00130     
00132     NSString  *clientName;
00133     
00134 @private
00136     BOOL       delegateRespondsToOutputBufferSkipSelector;
00138     BOOL       delegateRespondsToInputBufferSkipSelector;
00140     BOOL       delegateRespondsToDidProcessBufferSelector;
00141 }
00142 
00147 + streamClient;
00148 
00155 - (NSString *) description;
00156 
00170 - welcomeClientWithInputBuffer: (SndAudioBuffer *) inputBuffer 
00171                   outputBuffer: (SndAudioBuffer *) outputBuffer
00172                        manager: (SndStreamManager *) streamManager;
00173 
00189 - (BOOL) startProcessingNextBufferWithInput: (SndAudioBuffer *) inB nowTime: (double) t;
00190 
00198 - (double) preemptQueuedStream;
00199  
00203 - (void) processingThread;
00204 
00211 - (SndAudioBuffer *) outputBuffer;
00212 
00219 - (SndAudioBuffer *) synthOutputBuffer;
00220 
00226 - (void) rotateSynthOutputBuffer;
00227 
00233 - (SndAudioBuffer *) synthInputBuffer;
00234 
00240 - (void) finishStreaming;
00241 
00255 - (void) processBuffers; 
00256 
00273 - (double) synthesisTime;
00274 
00279 - (void) resetTime: (double) originTimeInSeconds;
00280 
00295 - (double) streamTime;
00296 
00301 - (BOOL) isActive;
00302 
00309 - setDetectPeaks: (BOOL) detectPeaks;
00310 
00319 - getPeakLeft: (float *) leftPeak right: (float *) rightPeak;
00320 
00325 - (BOOL) generatesOutput;
00326 
00331 - (BOOL) needsInput;
00332 
00341 - setGeneratesOutput: (BOOL) b;
00342 
00356 - setNeedsInput: (BOOL) yesOrNo;
00357 
00365 - lockOutputBuffer;
00366 
00371 - unlockOutputBuffer;
00372 
00381 - prepareToStreamWithBuffer: (SndAudioBuffer *) buff;
00382 
00390 - didFinishStreaming;
00391 
00396 - (SndAudioProcessorChain *) audioProcessorChain;
00397 
00402 - (void) setAudioProcessorChain: (SndAudioProcessorChain *) newAudioProcessorChain;
00403 
00409 - (void) setDelegate: (id) d;
00410 
00415 - (id) delegate;
00416 
00420 - (int) inputBufferCount;
00421 
00425 - (int) outputBufferCount;
00426 
00432 - (BOOL) setInputBufferCount: (int) n;
00433 
00439 - (BOOL) setOutputBufferCount: (int) n;
00440 
00447 - (double) outputLatencyInSeconds;
00448 
00455 - (long) outputLatencyInSamples;
00456 
00464 - (long) instantaneousOutputLatencyInSamples;
00465 
00473 - (long) instantaneousInputLatencyInSamples;
00474 
00479 - (NSString *) clientName;
00480 
00489 - setClientName: (NSString *) name;
00490 
00496 - offlineProcessBuffer: (SndAudioBuffer *) anAudioBuffer nowTime: (double) t;
00497 
00498 @end
00499 
00501 
00502 #endif