xref: /haiku/docs/user/game/GameProducer.dox (revision dd3b190b55747576443300d2d3531dde5bde3741)
18786818cSJohn Scipione/*
238f6a824SJohn Scipione * Copyright 2002-2010 Haiku, Inc. All rights reserved.
38786818cSJohn Scipione * Distributed under the terms of the MIT License.
48786818cSJohn Scipione *
58786818cSJohn Scipione * Authors:
68786818cSJohn Scipione *		Christopher ML Zumwalt May, zummy@users.sf.net
78786818cSJohn Scipione *		Omri Barak
8820dca4dSJohn Scipione *
98786818cSJohn Scipione * Proofreaders:
108786818cSJohn Scipione *		John Scipione, jscipione@gmail.com
11820dca4dSJohn Scipione *
128786818cSJohn Scipione * Corresponds to:
138786818cSJohn Scipione *		src/kits/game/GameProducer.h    rev 43514
148786818cSJohn Scipione *		src/kits/game/GameProducer.cpp  rev 43514
158786818cSJohn Scipione */
168786818cSJohn Scipione
178786818cSJohn Scipione
188786818cSJohn Scipione/*!
198786818cSJohn Scipione	\file GameProducer.h
20820dca4dSJohn Scipione	\ingroup game
21820dca4dSJohn Scipione	\ingroup libbe
228786818cSJohn Scipione	\brief Provides the GameProducer class.
238786818cSJohn Scipione*/
248786818cSJohn Scipione
258786818cSJohn Scipione
268786818cSJohn Scipione/*!
278786818cSJohn Scipione	\class GameProducer
288786818cSJohn Scipione	\ingroup game
298786818cSJohn Scipione	\ingroup libbe
308786818cSJohn Scipione	\brief A MediaKit producer node which mixes sound from the GameKit
318786818cSJohn Scipione	       and sends them to the audio mixer.
32*dd3b190bSJohn Scipione
33*dd3b190bSJohn Scipione	\since Haiku R1
348786818cSJohn Scipione*/
358786818cSJohn Scipione
368786818cSJohn Scipione
378786818cSJohn Scipione/*!
388786818cSJohn Scipione	\fn GameProducer::GameProducer(GameSoundBuffer* object,
398786818cSJohn Scipione		const gs_audio_format* format);
408786818cSJohn Scipione	\brief Initializes the GameProducer with the passed in GameSoundBuffer
418786818cSJohn Scipione	       and gs_audio_format.
428786818cSJohn Scipione
438786818cSJohn Scipione	\param object The GameSoundBuffer to 'sync' the GameProducer with.
448786818cSJohn Scipione	\param format The gs_audio_format to set the GameProducer's format.
45*dd3b190bSJohn Scipione
46*dd3b190bSJohn Scipione	\since Haiku R1
478786818cSJohn Scipione*/
488786818cSJohn Scipione
498786818cSJohn Scipione
508786818cSJohn Scipione/*!
518786818cSJohn Scipione	\fn GameProducer::~GameProducer()
528786818cSJohn Scipione	\brief Destroys the GameProducer object and stops the BMediaEventLooper
538786818cSJohn Scipione	       thread.
54*dd3b190bSJohn Scipione
55*dd3b190bSJohn Scipione	\since Haiku R1
568786818cSJohn Scipione*/
578786818cSJohn Scipione
588786818cSJohn Scipione
598786818cSJohn Scipione/*!
608786818cSJohn Scipione	\fn BMediaAddOn* GameProducer::AddOn(int32* internal_id) const
618786818cSJohn Scipione	\brief Unimplemented.
62*dd3b190bSJohn Scipione
63*dd3b190bSJohn Scipione	\since Haiku R1
648786818cSJohn Scipione*/
658786818cSJohn Scipione
668786818cSJohn Scipione
678786818cSJohn Scipione/*!
688786818cSJohn Scipione	\fn status_t GameProducer::FormatSuggestionRequested(media_type type,
698786818cSJohn Scipione		int32 quality, media_format* format)
708786818cSJohn Scipione	\brief Checks if a certain media format works with the GameProducer.
718786818cSJohn Scipione
728786818cSJohn Scipione	\warning Only supports raw audio at this point.
738786818cSJohn Scipione
748786818cSJohn Scipione	\param type The media format being tested.
758786818cSJohn Scipione	\param quality The quality of the media -- Not used in the method.
768786818cSJohn Scipione	\param format The media format to send through.
778786818cSJohn Scipione
788786818cSJohn Scipione	\returns A status code.
798786818cSJohn Scipione	\retval B_OK \a type is supported.
808786818cSJohn Scipione	\retval B_BAD_VALUE No \a format was received.
818786818cSJohn Scipione	\retval B_MEDIA_BAD_FORMAT The \a format is not supported.
82*dd3b190bSJohn Scipione
83*dd3b190bSJohn Scipione	\since Haiku R1
848786818cSJohn Scipione*/
858786818cSJohn Scipione
868786818cSJohn Scipione
878786818cSJohn Scipione/*!
888786818cSJohn Scipione	\fn status_t GameProducer::FormatProposal(const media_source& output,
898786818cSJohn Scipione		media_format* format)
908786818cSJohn Scipione	\brief Attempts to change the media format.
918786818cSJohn Scipione
928786818cSJohn Scipione	\warning Only supports raw audio and wildcard audio types.
938786818cSJohn Scipione
948786818cSJohn Scipione	\param output The source that the media outputs to.
958786818cSJohn Scipione	\param format The type of media being proposed.
968786818cSJohn Scipione
978786818cSJohn Scipione	\returns A status code.
988786818cSJohn Scipione	\retval B_OK The \a format is supported.
998786818cSJohn Scipione	\retval B_MEDIA_BAD_SOURCE The \a output doesn't match the current
1008786818cSJohn Scipione	        output source.
1018786818cSJohn Scipione	\retval B_MEDIA_BAD_FORMAT The \a format is not supported.
1028786818cSJohn Scipione
103*dd3b190bSJohn Scipione	\since Haiku R1
1048786818cSJohn Scipione*/
1058786818cSJohn Scipione
1068786818cSJohn Scipione
1078786818cSJohn Scipione/*!
1088786818cSJohn Scipione	\fn status_t GameProducer::FormatChangeRequested(const media_source& source,
1098786818cSJohn Scipione		const media_destination& destination, media_format* io_format,
1108786818cSJohn Scipione		int32* _deprecated_)
1118786818cSJohn Scipione	\brief We don't support any other formats, so we just reject any format changes.
1128786818cSJohn Scipione
1138786818cSJohn Scipione	\attention This method is deprecated.
1148786818cSJohn Scipione
1158786818cSJohn Scipione	\param source The output source.
1168786818cSJohn Scipione	\param destination The media's destination.
1178786818cSJohn Scipione	\param io_format The format of the media
1188786818cSJohn Scipione	\param _deprecated_ This method is deprecated.
1198786818cSJohn Scipione
1208786818cSJohn Scipione	\returns B_ERROR as this function is deprecated, it has been removed, and
1218786818cSJohn Scipione	         now only returns \a B_ERROR.
122*dd3b190bSJohn Scipione
123*dd3b190bSJohn Scipione	\since Haiku R1
1248786818cSJohn Scipione*/
1258786818cSJohn Scipione
1268786818cSJohn Scipione
1278786818cSJohn Scipione/*!
1288786818cSJohn Scipione	\fn status_t GameProducer::GetNextOutput(int32* cookie,
129*dd3b190bSJohn Scipione		media_output* _output)
1308786818cSJohn Scipione	\brief Gets the next output cookie.
1318786818cSJohn Scipione
1328786818cSJohn Scipione	Cookie can only be zero, as GameProducer supports one output.
1338786818cSJohn Scipione
1348786818cSJohn Scipione	\param cookie The output cookie value.
135*dd3b190bSJohn Scipione	\param _output The output that the cookie represents.
1368786818cSJohn Scipione
1378786818cSJohn Scipione	\returns A status code.
1388786818cSJohn Scipione	\retval B_OK The cookie was successfully incremented.
1398786818cSJohn Scipione	\retval B_BAD_INDEX The cookie is not equal to zero.
140*dd3b190bSJohn Scipione
141*dd3b190bSJohn Scipione	\since Haiku R1
1428786818cSJohn Scipione*/
1438786818cSJohn Scipione
1448786818cSJohn Scipione
1458786818cSJohn Scipione/*!
1468786818cSJohn Scipione	\fn status_t GameProducer::DisposeOutputCookie(int32 cookie)
1478786818cSJohn Scipione	\brief Does nothing because the cookie has no use as of yet.
1488786818cSJohn Scipione
1498786818cSJohn Scipione	\param cookie The cookie index.
1508786818cSJohn Scipione
1518786818cSJohn Scipione	\return Always returns B_OK.
152*dd3b190bSJohn Scipione
153*dd3b190bSJohn Scipione	\since Haiku R1
1548786818cSJohn Scipione*/
1558786818cSJohn Scipione
1568786818cSJohn Scipione
1578786818cSJohn Scipione/*!
158*dd3b190bSJohn Scipione	\fn status_t GameProducer::SetBufferGroup(const media_source& forSource,
1598786818cSJohn Scipione		BBufferGroup* newGroup)
1608786818cSJohn Scipione	\brief Changes the buffer group from the current one, to the specified one.
1618786818cSJohn Scipione
162*dd3b190bSJohn Scipione	\param forSource The output source. Can't be equivalent to the current
1638786818cSJohn Scipione		output source.
1648786818cSJohn Scipione	\param newGroup The new BBufferGroup to assign the buffer group to.
1658786818cSJohn Scipione
1668786818cSJohn Scipione	\returns A status code.
1678786818cSJohn Scipione	\retval B_OK The change has succeeded.
168*dd3b190bSJohn Scipione	\retval B_MEDIA_BAD_SOURCE \a forSource is equal to the current output source.
1698786818cSJohn Scipione	\retval B_BAD_VALUE The new BBufferGroup's buffer list returns an error.
170*dd3b190bSJohn Scipione
171*dd3b190bSJohn Scipione	\since Haiku R1
1728786818cSJohn Scipione*/
1738786818cSJohn Scipione
1748786818cSJohn Scipione
1758786818cSJohn Scipione/*!
176*dd3b190bSJohn Scipione	\fn status_t GameProducer::GetLatency(bigtime_t* _latency)
1778786818cSJohn Scipione	\brief Gets the total latency, including internal downstream plus scheduling.
1788786818cSJohn Scipione
179*dd3b190bSJohn Scipione	\param _latency Gets set to the current latency.
1808786818cSJohn Scipione
1818786818cSJohn Scipione	\returns B_OK.
182*dd3b190bSJohn Scipione
183*dd3b190bSJohn Scipione	\since Haiku R1
1848786818cSJohn Scipione*/
1858786818cSJohn Scipione
1868786818cSJohn Scipione
1878786818cSJohn Scipione/*!
1888786818cSJohn Scipione	\fn status_t GameProducer::PrepareToConnect(const media_source& what,
1898786818cSJohn Scipione		const media_destination& where, media_format* format,
190*dd3b190bSJohn Scipione		media_source* _source, char* out_name)
1918786818cSJohn Scipione	\brief Confirms that the media format and wild cards are valid.
1928786818cSJohn Scipione
1938786818cSJohn Scipione	\param what The media source to output to.
1948786818cSJohn Scipione	\param where The destination for the connection.
1958786818cSJohn Scipione	\param format The format to finish specializing.
196*dd3b190bSJohn Scipione	\param _source The output source that the method retrieves.
1978786818cSJohn Scipione	\param out_name The variable that holds the output name.
1988786818cSJohn Scipione
1998786818cSJohn Scipione	\returns A status code.
2008786818cSJohn Scipione	\retval B_OK The connection preparations have finished.
2018786818cSJohn Scipione	\retval B_MEDIA_BAD_SOURCE The \a output doesn't match the current output source.
2028786818cSJohn Scipione	\retval B_MEDIA_ALREADY_CONNECTED The GameProducer is already connected.
2038786818cSJohn Scipione	\retval B_MEDIA_BAD_FORMAT The \a format is not supported.
2048786818cSJohn Scipione
205*dd3b190bSJohn Scipione
206*dd3b190bSJohn Scipione	\since Haiku R1
2078786818cSJohn Scipione*/
2088786818cSJohn Scipione
2098786818cSJohn Scipione
2108786818cSJohn Scipione/*!
2118786818cSJohn Scipione	\fn void GameProducer::Connect(status_t error, const media_source& source,
212*dd3b190bSJohn Scipione		const media_destination& destination, const media_format& format,
213*dd3b190bSJohn Scipione		char* ioName)
2148786818cSJohn Scipione	\brief Connects to the output device.
2158786818cSJohn Scipione
2168786818cSJohn Scipione	\param error The variable that holds an error, should one arise.
2178786818cSJohn Scipione	\param source The output source to connect to.
2188786818cSJohn Scipione	\param destination The media destination, that is connected to.
2198786818cSJohn Scipione	\param format The variable that holds the format type.
220*dd3b190bSJohn Scipione	\param ioName The variable that holds the output name.
2218786818cSJohn Scipione*/
2228786818cSJohn Scipione
2238786818cSJohn Scipione
2248786818cSJohn Scipione/*!
225*dd3b190bSJohn Scipione	\fn void GameProducer::Disconnect(const media_source& what,
226*dd3b190bSJohn Scipione		const media_destination& where)
2278786818cSJohn Scipione	\brief Disconnects from the output device.
2288786818cSJohn Scipione
2298786818cSJohn Scipione	\param what The media destination.
2308786818cSJohn Scipione	\param where The media's output source.
231*dd3b190bSJohn Scipione
232*dd3b190bSJohn Scipione	\since Haiku R1
2338786818cSJohn Scipione*/
2348786818cSJohn Scipione
2358786818cSJohn Scipione
2368786818cSJohn Scipione/*!
2378786818cSJohn Scipione	\fn void GameProducer::LateNoticeReceived(const media_source& what,
238*dd3b190bSJohn Scipione		bigtime_t howMuch, bigtime_t performanceDuration)
2398786818cSJohn Scipione	\brief Attempts to catch up to the buffer.
2408786818cSJohn Scipione
2418786818cSJohn Scipione	\param what The media output source.
242*dd3b190bSJohn Scipione	\param howMuch The amount of 'lateness'.
243*dd3b190bSJohn Scipione	\param performanceDuration Unused.
244*dd3b190bSJohn Scipione
245*dd3b190bSJohn Scipione	\since Haiku R1
2468786818cSJohn Scipione*/
2478786818cSJohn Scipione
2488786818cSJohn Scipione
2498786818cSJohn Scipione/*!
2508786818cSJohn Scipione	\fn void GameProducer::EnableOutput(const media_source& what,
2518786818cSJohn Scipione		bool enabled, int32* _deprecated_)
2528786818cSJohn Scipione	\brief Enable or disable an output.
2538786818cSJohn Scipione
2548786818cSJohn Scipione	\attention This method is deprecated.
2558786818cSJohn Scipione
2568786818cSJohn Scipione	\param what The media output source.
2578786818cSJohn Scipione	\param enabled Sets the output to enabled or disabled.
2588786818cSJohn Scipione	\param _deprecated_ This method is deprecated.
259*dd3b190bSJohn Scipione
260*dd3b190bSJohn Scipione	\since Haiku R1
2618786818cSJohn Scipione*/
2628786818cSJohn Scipione
2638786818cSJohn Scipione
2648786818cSJohn Scipione/*!
265*dd3b190bSJohn Scipione	\fn status_t GameProducer::SetPlayRate(int32 numerator, int32 denominator)
2668786818cSJohn Scipione	\brief Play rates are not supported, returns \c B_ERROR.
2678786818cSJohn Scipione
268*dd3b190bSJohn Scipione	\param numerator The top part of the fraction.
269*dd3b190bSJohn Scipione	\param denominator The bottom part of the fraction.
2708786818cSJohn Scipione
2718786818cSJohn Scipione	\return Always returns \c B_ERROR since play rates aren't supported.
272*dd3b190bSJohn Scipione
273*dd3b190bSJohn Scipione	\since Haiku R1
2748786818cSJohn Scipione*/
2758786818cSJohn Scipione
2768786818cSJohn Scipione
2778786818cSJohn Scipione/*!
2788786818cSJohn Scipione	\fn status_t GameProducer::HandleMessage(int32 message, const void* data,
2798786818cSJohn Scipione		size_t size)
2808786818cSJohn Scipione	\brief Private messages are not supported, returns \c B_ERROR.
2818786818cSJohn Scipione
2828786818cSJohn Scipione	\param message The message to be sent.
2838786818cSJohn Scipione	\param data The data to be sent.
2848786818cSJohn Scipione	\param size The size of the message.
2858786818cSJohn Scipione
2868786818cSJohn Scipione	\returns Always returns \c B_ERROR since private messages aren't supported.
287*dd3b190bSJohn Scipione
288*dd3b190bSJohn Scipione	\since Haiku R1
2898786818cSJohn Scipione*/
2908786818cSJohn Scipione
2918786818cSJohn Scipione
2928786818cSJohn Scipione/*!
2938786818cSJohn Scipione	\fn void GameProducer::AdditionalBufferRequested(
2948786818cSJohn Scipione		const media_source& source,
2958786818cSJohn Scipione		media_buffer_id prev_buffer, bigtime_t prev_time,
2968786818cSJohn Scipione		const media_seek_tag* prev_tag)
2978786818cSJohn Scipione	\brief Offline modes are not supported for now, does nothing.
2988786818cSJohn Scipione
2998786818cSJohn Scipione	\param source The media output source.
3008786818cSJohn Scipione	\param prev_buffer The previous buffer.
3018786818cSJohn Scipione	\param prev_time The previous buffer time.
3028786818cSJohn Scipione	\param prev_tag The previous buffer delimiter.
303*dd3b190bSJohn Scipione
304*dd3b190bSJohn Scipione	\since Haiku R1
3058786818cSJohn Scipione*/
3068786818cSJohn Scipione
3078786818cSJohn Scipione
3088786818cSJohn Scipione/*!
3098786818cSJohn Scipione	\fn void GameProducer::LatencyChanged(const media_source& source,
3108786818cSJohn Scipione		const media_destination& destination, bigtime_t new_latency,
3118786818cSJohn Scipione		uint32 flags)
3128786818cSJohn Scipione	\brief Sets the event latency in the case that the latency changed.
3138786818cSJohn Scipione
3148786818cSJohn Scipione	\param source The media output source.
3158786818cSJohn Scipione	\param destination The connected output destination.
3168786818cSJohn Scipione	\param new_latency The new amount of latency.
3178786818cSJohn Scipione	\param flags Unused.
318*dd3b190bSJohn Scipione
319*dd3b190bSJohn Scipione	\since Haiku R1
3208786818cSJohn Scipione*/
3218786818cSJohn Scipione
3228786818cSJohn Scipione
3238786818cSJohn Scipione/*!
3248786818cSJohn Scipione	\fn void GameProducer::NodeRegistered()
3258786818cSJohn Scipione	\brief Handles when an output source node is registered.
326*dd3b190bSJohn Scipione
327*dd3b190bSJohn Scipione	\since Haiku R1
3288786818cSJohn Scipione*/
3298786818cSJohn Scipione
3308786818cSJohn Scipione
3318786818cSJohn Scipione/*!
3328786818cSJohn Scipione	\fn void GameProducer::SetRunMode(run_mode mode)
3338786818cSJohn Scipione	\brief Offline mode is not supported.
3348786818cSJohn Scipione
3358786818cSJohn Scipione	\param mode The mode of running.
336*dd3b190bSJohn Scipione
337*dd3b190bSJohn Scipione	\since Haiku R1
3388786818cSJohn Scipione*/
3398786818cSJohn Scipione
3408786818cSJohn Scipione
3418786818cSJohn Scipione/*!
342*dd3b190bSJohn Scipione	\fn void GameProducer::HandleEvent(const media_timed_event* event,
343*dd3b190bSJohn Scipione		bigtime_t lateness, bool realTimeEvent)
3448786818cSJohn Scipione	\brief Handles when an event is triggered.
3458786818cSJohn Scipione
3468786818cSJohn Scipione	\param event The type of event.
3478786818cSJohn Scipione	\param lateness Unused.
3488786818cSJohn Scipione	\param realTimeEvent Unused.
349*dd3b190bSJohn Scipione
350*dd3b190bSJohn Scipione	\since Haiku R1
3518786818cSJohn Scipione*/
352