2 * Copyright 2001-2002, Haiku.
3 * Distributed under the terms of the MIT License.
5 * Author: Christopher ML Zumwalt May (zummy@users.sf.net)
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
;
22 media_node producer
, consumer
;
24 media_destination destination
;
26 media_node timeSource
;
30 class GameSoundBuffer
{
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();
41 void Play(void * data
, int64 frames
);
45 virtual void * Data() { return NULL
; }
46 const gs_audio_format
& Format() const;
48 bool IsLooping() const;
49 void SetLooping(bool loop
);
51 status_t
SetGain(float gain
, bigtime_t duration
);
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
);
61 virtual void FillBuffer(void * data
, int64 frames
) = 0;
63 gs_audio_format fFormat
;
68 Connection
* fConnection
;
77 float fPan
, fPanLeft
, fPanRight
;
83 class SimpleSoundBuffer
: public GameSoundBuffer
{
85 SimpleSoundBuffer(const gs_audio_format
* format
,
88 virtual ~SimpleSoundBuffer();
90 virtual void * Data() { return fBuffer
; }
95 virtual void FillBuffer(void * data
, int64 frames
);
104 class StreamingSoundBuffer
: public GameSoundBuffer
{
106 StreamingSoundBuffer(const gs_audio_format
* format
,
107 const void * streamHook
,
108 size_t inBufferFrameCount
,
109 size_t inBufferCount
);
110 virtual ~StreamingSoundBuffer();
114 virtual void FillBuffer(void * data
, int64 frames
);