1 /******************************************************************************
5 Description: Support for communication with a buffer stream server
7 Copyright 1995-97, Be Incorporated
9 ******************************************************************************/
14 #include <MediaDefs.h>
16 #include "OldBufferStream.h"
22 typedef bool (*enter_stream_hook
)(void *userData
, char *buffer
, size_t count
,
24 typedef status_t (*exit_stream_hook
)(void *userData
, status_t error
);
27 Class definition for BSubscriber
33 BSubscriber(const char *name
= NULL
);
34 virtual ~BSubscriber();
37 Gaining access to the Buffer Stream
40 virtual status_t
Subscribe(BAbstractBufferStream
* stream
);
41 virtual status_t
Unsubscribe();
43 subscriber_id
ID() const;
44 const char *Name() const;
46 void SetTimeout(bigtime_t microseconds
);
47 bigtime_t
Timeout() const;
53 virtual status_t
EnterStream(subscriber_id neighbor
,
56 enter_stream_hook entryFunction
,
57 exit_stream_hook exitFunction
,
60 virtual status_t
ExitStream(bool synch
=FALSE
);
62 bool IsInStream() const;
65 Protected members (may be used by inherited classes)
70 static status_t
_ProcessLoop(void *arg
);
71 virtual status_t
ProcessLoop();
72 BAbstractBufferStream
*Stream() const;
80 virtual void _ReservedSubscriber1();
81 virtual void _ReservedSubscriber2();
82 virtual void _ReservedSubscriber3();
84 char *fName
; /* name given to constructor */
85 subscriber_id fSubID
; /* our subscriber_id */
86 sem_id fSem
; /* stream semaphore */
87 BAbstractBufferStream
*fStream
; /* buffer stream */
88 void *fUserData
; /* arg to fStreamFn and fCompletionFn */
89 enter_stream_hook fStreamFn
; /* per-buffer user function */
90 exit_stream_hook fCompletionFn
; /* called after streaming stops */
91 bool fCallStreamFn
; /* true while we should call fStreamFn */
92 bigtime_t fTimeout
; /* time out while awaiting buffers */
93 thread_id fBackThread
;
96 int32 fFileID
; /* reserved for future use */
100 #endif // #ifdef _SUBSCRIBER_H