BPicture: Fix archive constructor.
[haiku.git] / src / kits / game / GameProducer.h
blob8d576c9dc3cf29b9e20070600c088f04f4228cdb
1 //------------------------------------------------------------------------------
2 // Copyright (c) 2001-2002, OpenBeOS
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining a
5 // copy of this software and associated documentation files (the "Software"),
6 // to deal in the Software without restriction, including without limitation
7 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 // and/or sell copies of the Software, and to permit persons to whom the
9 // Software is furnished to do so, subject to the following conditions:
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 // DEALINGS IN THE SOFTWARE.
22 // File Name: GameProducer.cpp
23 // Author: Christopher ML Zumwalt May (zummy@users.sf.net)
24 // Description: A MediaKit producer node which mixes sound from the GameKit
25 // and sends them to the audio mixer
26 //------------------------------------------------------------------------------
27 #ifndef _GAME_PRODUCER_H
28 #define _GAME_PRODUCER_H
31 #include <media/BufferProducer.h>
32 #include <media/MediaEventLooper.h>
33 #include <GameSoundDefs.h>
36 class GameSoundBuffer;
39 class GameProducer : public BBufferProducer, public BMediaEventLooper {
40 public:
41 GameProducer(GameSoundBuffer* object,
42 const gs_audio_format * format);
43 ~GameProducer();
45 // BMediaNode methods
46 BMediaAddOn* AddOn(int32* internal_id) const;
48 // BBufferProducer methods
49 status_t FormatSuggestionRequested(media_type type,
50 int32 quality, media_format* format);
52 status_t FormatProposal(const media_source& output,
53 media_format* format);
55 status_t FormatChangeRequested(const media_source& source,
56 const media_destination& destination,
57 media_format* io_format,
58 int32* _deprecated_);
60 status_t GetNextOutput(int32* cookie,
61 media_output* _output);
63 status_t DisposeOutputCookie(int32 cookie);
65 status_t SetBufferGroup(const media_source& forSource,
66 BBufferGroup* group);
69 status_t GetLatency(bigtime_t* _latency);
71 status_t PrepareToConnect(const media_source& what,
72 const media_destination& where,
73 media_format* format,
74 media_source* _source,
75 char* out_name);
77 void Connect(status_t error,
78 const media_source& source,
79 const media_destination& destination,
80 const media_format& format,
81 char* ioName);
83 void Disconnect(const media_source& what,
84 const media_destination& where);
86 void LateNoticeReceived(const media_source& what,
87 bigtime_t howMuch,
88 bigtime_t performanceDuration);
90 void EnableOutput(const media_source & what,
91 bool enabled, int32* _deprecated_);
93 status_t SetPlayRate(int32 numerator, int32 denominator);
95 status_t HandleMessage(int32 message, const void* data,
96 size_t size);
98 void AdditionalBufferRequested(const media_source& source,
99 media_buffer_id prev_buffer,
100 bigtime_t prev_time,
101 const media_seek_tag* prev_tag);
103 void LatencyChanged(const media_source& source,
104 const media_destination& destination,
105 bigtime_t new_latency,
106 uint32 flags);
108 // BMediaEventLooper methods
109 void NodeRegistered();
110 void SetRunMode(run_mode mode);
111 void HandleEvent(const media_timed_event* event,
112 bigtime_t lateness,
113 bool realTimeEvent = false);
115 // GameProducer
116 status_t StartPlaying(GameSoundBuffer* sound);
117 status_t StopPlaying(GameSoundBuffer* sound);
118 bool IsPlaying(GameSoundBuffer* sound) const;
120 int32 SoundCount() const;
122 private:
123 BBuffer* FillNextBuffer(bigtime_t event_time);
125 BBufferGroup* fBufferGroup;
126 bigtime_t fLatency;
127 bigtime_t fInternalLatency;
128 media_output fOutput;
129 bool fOutputEnabled;
130 media_format fPreferredFormat;
132 bigtime_t fStartTime;
133 size_t fFrameSize;
134 int64 fFramesSent;
135 GameSoundBuffer* fObject;
136 size_t fBufferSize;
140 #endif // _GAME_PRODUCER_H