tcp: Fix 64 bit build with debugging features enabled.
[haiku.git] / src / kits / game / GameSoundBuffer.h
blob3c5d17688fd26427c089b1145d1e38b78e7f4f83
1 /*
2 * Copyright 2001-2002, Haiku.
3 * Distributed under the terms of the MIT License.
5 * Author: Christopher ML Zumwalt May (zummy@users.sf.net)
6 */
8 #ifndef _GAMESOUNDBUFFER_H
9 #define _GAMESOUNDBUFFER_H
12 #include <GameSoundDefs.h>
13 #include <MediaDefs.h>
14 #include <MediaNode.h>
16 const int32 kPausedAttribute = B_GS_FIRST_PRIVATE_ATTRIBUTE;
18 class GameProducer;
19 struct _gs_ramp;
20 struct Connection
22 media_node producer, consumer;
23 media_source source;
24 media_destination destination;
25 media_format format;
26 media_node timeSource;
30 class GameSoundBuffer {
31 public:
33 GameSoundBuffer(const gs_audio_format* format);
34 virtual ~GameSoundBuffer();
36 virtual status_t Connect(media_node * consumer);
37 status_t StartPlaying();
38 status_t StopPlaying();
39 bool IsPlaying();
41 void Play(void * data, int64 frames);
42 void UpdateMods();
43 virtual void Reset();
45 virtual void * Data() { return NULL; }
46 const gs_audio_format & Format() const;
48 bool IsLooping() const;
49 void SetLooping(bool loop);
50 float Gain() const;
51 status_t SetGain(float gain, bigtime_t duration);
52 float Pan() const;
53 status_t SetPan(float pan, bigtime_t duration);
55 virtual status_t GetAttributes(gs_attribute * attributes,
56 size_t attributeCount);
57 virtual status_t SetAttributes(gs_attribute * attributes,
58 size_t attributeCount);
59 protected:
61 virtual void FillBuffer(void * data, int64 frames) = 0;
63 gs_audio_format fFormat;
64 bool fLooping;
66 size_t fFrameSize;
68 Connection * fConnection;
69 GameProducer * fNode;
71 private:
73 bool fIsConnected;
74 bool fIsPlaying;
76 float fGain;
77 float fPan, fPanLeft, fPanRight;
78 _gs_ramp* fGainRamp;
79 _gs_ramp* fPanRamp;
83 class SimpleSoundBuffer : public GameSoundBuffer {
84 public:
85 SimpleSoundBuffer(const gs_audio_format* format,
86 const void * data,
87 int64 frames = 0);
88 virtual ~SimpleSoundBuffer();
90 virtual void * Data() { return fBuffer; }
91 virtual void Reset();
93 protected:
95 virtual void FillBuffer(void * data, int64 frames);
97 private:
98 char * fBuffer;
99 size_t fBufferSize;
100 size_t fPosition;
104 class StreamingSoundBuffer : public GameSoundBuffer {
105 public:
106 StreamingSoundBuffer(const gs_audio_format * format,
107 const void * streamHook,
108 size_t inBufferFrameCount,
109 size_t inBufferCount);
110 virtual ~StreamingSoundBuffer();
112 protected:
114 virtual void FillBuffer(void * data, int64 frames);
116 private:
118 void * fStreamHook;
121 #endif