tcp: Fix 64 bit build with debugging features enabled.
[haiku.git] / src / kits / media / legacy / OldSubscriber.h
blobb0d139d510a1ff70aee6cfcff896c64193988c27
1 /******************************************************************************
3 File: Subscriber.h
5 Description: Support for communication with a buffer stream server
7 Copyright 1995-97, Be Incorporated
9 ******************************************************************************/
11 #ifndef _SUBSCRIBER_H
12 #define _SUBSCRIBER_H
14 #include <MediaDefs.h>
16 #include "OldBufferStream.h"
18 /* ================
19 declarations
20 ================ */
22 typedef bool (*enter_stream_hook)(void *userData, char *buffer, size_t count,
23 void *header);
24 typedef status_t (*exit_stream_hook)(void *userData, status_t error);
26 /* ================
27 Class definition for BSubscriber
28 ================ */
30 class BSubscriber
32 public:
33 BSubscriber(const char *name = NULL);
34 virtual ~BSubscriber();
36 /* ================
37 Gaining access to the Buffer Stream
38 ================ */
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;
49 /* ================
50 Streaming functions.
51 ================ */
53 virtual status_t EnterStream(subscriber_id neighbor,
54 bool before,
55 void *userData,
56 enter_stream_hook entryFunction,
57 exit_stream_hook exitFunction,
58 bool background);
60 virtual status_t ExitStream(bool synch=FALSE);
62 bool IsInStream() const;
64 /* ================
65 Protected members (may be used by inherited classes)
66 ================ */
68 protected:
70 static status_t _ProcessLoop(void *arg);
71 virtual status_t ProcessLoop();
72 BAbstractBufferStream *Stream() const;
74 /* ================
75 Private members
76 ================ */
78 private:
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;
94 sem_id fSynchLock;
96 int32 fFileID; /* reserved for future use */
97 uint32 _reserved[4];
100 #endif // #ifdef _SUBSCRIBER_H