18786818cSJohn Scipione/* 2*38f6a824SJohn 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 88786818cSJohn Scipione * Proofreaders: 98786818cSJohn Scipione * John Scipione, jscipione@gmail.com 108786818cSJohn Scipione * Corresponds to: 118786818cSJohn Scipione * src/kits/game/GameProducer.h rev 43514 128786818cSJohn Scipione * src/kits/game/GameProducer.cpp rev 43514 138786818cSJohn Scipione */ 148786818cSJohn Scipione 158786818cSJohn Scipione 168786818cSJohn Scipione/*! 178786818cSJohn Scipione \file GameProducer.h 188786818cSJohn Scipione \brief Provides the GameProducer class. 198786818cSJohn Scipione*/ 208786818cSJohn Scipione 218786818cSJohn Scipione 228786818cSJohn Scipione/*! 238786818cSJohn Scipione \class GameProducer 248786818cSJohn Scipione \ingroup game 258786818cSJohn Scipione \ingroup libbe 268786818cSJohn Scipione \brief A MediaKit producer node which mixes sound from the GameKit 278786818cSJohn Scipione and sends them to the audio mixer. 288786818cSJohn Scipione*/ 298786818cSJohn Scipione 308786818cSJohn Scipione 318786818cSJohn Scipione/*! 328786818cSJohn Scipione \fn GameProducer::GameProducer(GameSoundBuffer * object, 338786818cSJohn Scipione const gs_audio_format * format); 348786818cSJohn Scipione \brief Initializes the GameProducer with the passed in GameSoundBuffer 358786818cSJohn Scipione and gs_audio_format. 368786818cSJohn Scipione 378786818cSJohn Scipione \param object The GameSoundBuffer to 'sync' the GameProducer with. 388786818cSJohn Scipione \param format The gs_audio_format to set the GameProducer's format. 398786818cSJohn Scipione*/ 408786818cSJohn Scipione 418786818cSJohn Scipione 428786818cSJohn Scipione/*! 438786818cSJohn Scipione \fn GameProducer::~GameProducer() 448786818cSJohn Scipione \brief Destroys the GameProducer object and stops the BMediaEventLooper 458786818cSJohn Scipione thread. 468786818cSJohn Scipione*/ 478786818cSJohn Scipione 488786818cSJohn Scipione 498786818cSJohn Scipione/*! 508786818cSJohn Scipione \fn BMediaAddOn* GameProducer::AddOn(int32 *internal_id) const 518786818cSJohn Scipione \brief Unimplemented. 528786818cSJohn Scipione*/ 538786818cSJohn Scipione 548786818cSJohn Scipione 558786818cSJohn Scipione/*! 568786818cSJohn Scipione \fn status_t GameProducer::FormatSuggestionRequested(media_type type, 578786818cSJohn Scipione int32 quality, media_format* format) 588786818cSJohn Scipione \brief Checks if a certain media format works with the GameProducer. 598786818cSJohn Scipione 608786818cSJohn Scipione \warning Only supports raw audio at this point. 618786818cSJohn Scipione 628786818cSJohn Scipione \param type The media format being tested. 638786818cSJohn Scipione \param quality The quality of the media -- Not used in the method. 648786818cSJohn Scipione \param format The media format to send through. 658786818cSJohn Scipione 668786818cSJohn Scipione \returns A status code. 678786818cSJohn Scipione \retval B_OK \a type is supported. 688786818cSJohn Scipione \retval B_BAD_VALUE No \a format was received. 698786818cSJohn Scipione \retval B_MEDIA_BAD_FORMAT The \a format is not supported. 708786818cSJohn Scipione*/ 718786818cSJohn Scipione 728786818cSJohn Scipione 738786818cSJohn Scipione/*! 748786818cSJohn Scipione \fn status_t GameProducer::FormatProposal(const media_source& output, 758786818cSJohn Scipione media_format* format) 768786818cSJohn Scipione \brief Attempts to change the media format. 778786818cSJohn Scipione 788786818cSJohn Scipione \warning Only supports raw audio and wildcard audio types. 798786818cSJohn Scipione 808786818cSJohn Scipione \param output The source that the media outputs to. 818786818cSJohn Scipione \param format The type of media being proposed. 828786818cSJohn Scipione 838786818cSJohn Scipione \returns A status code. 848786818cSJohn Scipione \retval B_OK The \a format is supported. 858786818cSJohn Scipione \retval B_MEDIA_BAD_SOURCE The \a output doesn't match the current 868786818cSJohn Scipione output source. 878786818cSJohn Scipione \retval B_MEDIA_BAD_FORMAT The \a format is not supported. 888786818cSJohn Scipione 898786818cSJohn Scipione*/ 908786818cSJohn Scipione 918786818cSJohn Scipione 928786818cSJohn Scipione/*! 938786818cSJohn Scipione \fn status_t GameProducer::FormatChangeRequested(const media_source& source, 948786818cSJohn Scipione const media_destination& destination, media_format* io_format, 958786818cSJohn Scipione int32* _deprecated_) 968786818cSJohn Scipione \brief We don't support any other formats, so we just reject any format changes. 978786818cSJohn Scipione 988786818cSJohn Scipione \attention This method is deprecated. 998786818cSJohn Scipione 1008786818cSJohn Scipione \param source The output source. 1018786818cSJohn Scipione \param destination The media's destination. 1028786818cSJohn Scipione \param io_format The format of the media 1038786818cSJohn Scipione \param _deprecated_ This method is deprecated. 1048786818cSJohn Scipione 1058786818cSJohn Scipione \returns B_ERROR as this function is deprecated, it has been removed, and 1068786818cSJohn Scipione now only returns \a B_ERROR. 1078786818cSJohn Scipione*/ 1088786818cSJohn Scipione 1098786818cSJohn Scipione 1108786818cSJohn Scipione/*! 1118786818cSJohn Scipione \fn status_t GameProducer::GetNextOutput(int32* cookie, 1128786818cSJohn Scipione media_output* out_output) 1138786818cSJohn Scipione \brief Gets the next output cookie. 1148786818cSJohn Scipione 1158786818cSJohn Scipione Cookie can only be zero, as GameProducer supports one output. 1168786818cSJohn Scipione 1178786818cSJohn Scipione \param cookie The output cookie value. 1188786818cSJohn Scipione \param out_output The output that the cookie represents. 1198786818cSJohn Scipione 1208786818cSJohn Scipione \returns A status code. 1218786818cSJohn Scipione \retval B_OK The cookie was successfully incremented. 1228786818cSJohn Scipione \retval B_BAD_INDEX The cookie is not equal to zero. 1238786818cSJohn Scipione*/ 1248786818cSJohn Scipione 1258786818cSJohn Scipione 1268786818cSJohn Scipione/*! 1278786818cSJohn Scipione \fn status_t GameProducer::DisposeOutputCookie(int32 cookie) 1288786818cSJohn Scipione \brief Does nothing because the cookie has no use as of yet. 1298786818cSJohn Scipione 1308786818cSJohn Scipione \param cookie The cookie index. 1318786818cSJohn Scipione 1328786818cSJohn Scipione \return Always returns B_OK. 1338786818cSJohn Scipione*/ 1348786818cSJohn Scipione 1358786818cSJohn Scipione 1368786818cSJohn Scipione/*! 1378786818cSJohn Scipione \fn status_t GameProducer::SetBufferGroup(const media_source& for_source, 1388786818cSJohn Scipione BBufferGroup* newGroup) 1398786818cSJohn Scipione \brief Changes the buffer group from the current one, to the specified one. 1408786818cSJohn Scipione 1418786818cSJohn Scipione \param for_source The output source. Can't be equivalent to the current 1428786818cSJohn Scipione output source. 1438786818cSJohn Scipione \param newGroup The new BBufferGroup to assign the buffer group to. 1448786818cSJohn Scipione 1458786818cSJohn Scipione \returns A status code. 1468786818cSJohn Scipione \retval B_OK The change has succeeded. 1478786818cSJohn Scipione \retval B_MEDIA_BAD_SOURCE \a for_source is equal to the current output source. 1488786818cSJohn Scipione \retval B_BAD_VALUE The new BBufferGroup's buffer list returns an error. 1498786818cSJohn Scipione*/ 1508786818cSJohn Scipione 1518786818cSJohn Scipione 1528786818cSJohn Scipione/*! 1538786818cSJohn Scipione \fn status_t GameProducer::GetLatency(bigtime_t* out_latency) 1548786818cSJohn Scipione \brief Gets the total latency, including internal downstream plus scheduling. 1558786818cSJohn Scipione 1568786818cSJohn Scipione \param out_latency Gets set to the current latency. 1578786818cSJohn Scipione 1588786818cSJohn Scipione \returns B_OK. 1598786818cSJohn Scipione*/ 1608786818cSJohn Scipione 1618786818cSJohn Scipione 1628786818cSJohn Scipione/*! 1638786818cSJohn Scipione \fn status_t GameProducer::PrepareToConnect(const media_source& what, 1648786818cSJohn Scipione const media_destination& where, media_format* format, 1658786818cSJohn Scipione media_source* out_source, char* out_name) 1668786818cSJohn Scipione \brief Confirms that the media format and wild cards are valid. 1678786818cSJohn Scipione 1688786818cSJohn Scipione \param what The media source to output to. 1698786818cSJohn Scipione \param where The destination for the connection. 1708786818cSJohn Scipione \param format The format to finish specializing. 1718786818cSJohn Scipione \param out_source The output source that the method retrieves. 1728786818cSJohn Scipione \param out_name The variable that holds the output name. 1738786818cSJohn Scipione 1748786818cSJohn Scipione \returns A status code. 1758786818cSJohn Scipione \retval B_OK The connection preparations have finished. 1768786818cSJohn Scipione \retval B_MEDIA_BAD_SOURCE The \a output doesn't match the current output source. 1778786818cSJohn Scipione \retval B_MEDIA_ALREADY_CONNECTED The GameProducer is already connected. 1788786818cSJohn Scipione \retval B_MEDIA_BAD_FORMAT The \a format is not supported. 1798786818cSJohn Scipione 1808786818cSJohn Scipione*/ 1818786818cSJohn Scipione 1828786818cSJohn Scipione 1838786818cSJohn Scipione/*! 1848786818cSJohn Scipione \fn void GameProducer::Connect(status_t error, const media_source& source, 1858786818cSJohn Scipione const media_destination& destination, const media_format& format, char* io_name) 1868786818cSJohn Scipione \brief Connects to the output device. 1878786818cSJohn Scipione 1888786818cSJohn Scipione \param error The variable that holds an error, should one arise. 1898786818cSJohn Scipione \param source The output source to connect to. 1908786818cSJohn Scipione \param destination The media destination, that is connected to. 1918786818cSJohn Scipione \param format The variable that holds the format type. 1928786818cSJohn Scipione \param io_name The variable that holds the output name. 1938786818cSJohn Scipione*/ 1948786818cSJohn Scipione 1958786818cSJohn Scipione 1968786818cSJohn Scipione/*! 1978786818cSJohn Scipione \fn void GameProducer::Disconnect(const media_source& what, const media_destination& where) 1988786818cSJohn Scipione \brief Disconnects from the output device. 1998786818cSJohn Scipione 2008786818cSJohn Scipione \param what The media destination. 2018786818cSJohn Scipione \param where The media's output source. 2028786818cSJohn Scipione*/ 2038786818cSJohn Scipione 2048786818cSJohn Scipione 2058786818cSJohn Scipione/*! 2068786818cSJohn Scipione \fn void GameProducer::LateNoticeReceived(const media_source& what, 2078786818cSJohn Scipione bigtime_t how_much, bigtime_t performance_time) 2088786818cSJohn Scipione \brief Attempts to catch up to the buffer. 2098786818cSJohn Scipione 2108786818cSJohn Scipione \param what The media output source. 2118786818cSJohn Scipione \param how_much The amount of 'lateness'. 2128786818cSJohn Scipione \param performance_time Unused. 2138786818cSJohn Scipione*/ 2148786818cSJohn Scipione 2158786818cSJohn Scipione 2168786818cSJohn Scipione/*! 2178786818cSJohn Scipione \fn void GameProducer::EnableOutput(const media_source& what, 2188786818cSJohn Scipione bool enabled, int32* _deprecated_) 2198786818cSJohn Scipione \brief Enable or disable an output. 2208786818cSJohn Scipione 2218786818cSJohn Scipione \attention This method is deprecated. 2228786818cSJohn Scipione 2238786818cSJohn Scipione \param what The media output source. 2248786818cSJohn Scipione \param enabled Sets the output to enabled or disabled. 2258786818cSJohn Scipione \param _deprecated_ This method is deprecated. 2268786818cSJohn Scipione*/ 2278786818cSJohn Scipione 2288786818cSJohn Scipione 2298786818cSJohn Scipione/*! 2308786818cSJohn Scipione \fn status_t GameProducer::SetPlayRate(int32 numer, int32 denom) 2318786818cSJohn Scipione \brief Play rates are not supported, returns \c B_ERROR. 2328786818cSJohn Scipione 2338786818cSJohn Scipione \param numer The top part of the fraction. 2348786818cSJohn Scipione \param denom The bottom part of the fraction. 2358786818cSJohn Scipione 2368786818cSJohn Scipione \return Always returns \c B_ERROR since play rates aren't supported. 2378786818cSJohn Scipione*/ 2388786818cSJohn Scipione 2398786818cSJohn Scipione 2408786818cSJohn Scipione/*! 2418786818cSJohn Scipione \fn status_t GameProducer::HandleMessage(int32 message, const void* data, 2428786818cSJohn Scipione size_t size) 2438786818cSJohn Scipione \brief Private messages are not supported, returns \c B_ERROR. 2448786818cSJohn Scipione 2458786818cSJohn Scipione \param message The message to be sent. 2468786818cSJohn Scipione \param data The data to be sent. 2478786818cSJohn Scipione \param size The size of the message. 2488786818cSJohn Scipione 2498786818cSJohn Scipione \returns Always returns \c B_ERROR since private messages aren't supported. 2508786818cSJohn Scipione*/ 2518786818cSJohn Scipione 2528786818cSJohn Scipione 2538786818cSJohn Scipione/*! 2548786818cSJohn Scipione \fn void GameProducer::AdditionalBufferRequested( 2558786818cSJohn Scipione const media_source& source, 2568786818cSJohn Scipione media_buffer_id prev_buffer, bigtime_t prev_time, 2578786818cSJohn Scipione const media_seek_tag* prev_tag) 2588786818cSJohn Scipione \brief Offline modes are not supported for now, does nothing. 2598786818cSJohn Scipione 2608786818cSJohn Scipione \param source The media output source. 2618786818cSJohn Scipione \param prev_buffer The previous buffer. 2628786818cSJohn Scipione \param prev_time The previous buffer time. 2638786818cSJohn Scipione \param prev_tag The previous buffer delimiter. 2648786818cSJohn Scipione*/ 2658786818cSJohn Scipione 2668786818cSJohn Scipione 2678786818cSJohn Scipione/*! 2688786818cSJohn Scipione \fn void GameProducer::LatencyChanged(const media_source& source, 2698786818cSJohn Scipione const media_destination& destination, bigtime_t new_latency, 2708786818cSJohn Scipione uint32 flags) 2718786818cSJohn Scipione \brief Sets the event latency in the case that the latency changed. 2728786818cSJohn Scipione 2738786818cSJohn Scipione \param source The media output source. 2748786818cSJohn Scipione \param destination The connected output destination. 2758786818cSJohn Scipione \param new_latency The new amount of latency. 2768786818cSJohn Scipione \param flags Unused. 2778786818cSJohn Scipione*/ 2788786818cSJohn Scipione 2798786818cSJohn Scipione 2808786818cSJohn Scipione/*! 2818786818cSJohn Scipione \fn void GameProducer::NodeRegistered() 2828786818cSJohn Scipione \brief Handles when an output source node is registered. 2838786818cSJohn Scipione*/ 2848786818cSJohn Scipione 2858786818cSJohn Scipione 2868786818cSJohn Scipione/*! 2878786818cSJohn Scipione \fn void GameProducer::SetRunMode(run_mode mode) 2888786818cSJohn Scipione \brief Offline mode is not supported. 2898786818cSJohn Scipione 2908786818cSJohn Scipione \param mode The mode of running. 2918786818cSJohn Scipione*/ 2928786818cSJohn Scipione 2938786818cSJohn Scipione 2948786818cSJohn Scipione/*! 2958786818cSJohn Scipione \fn void GameProducer::HandleEvent(const media_timed_event* event, bigtime_t lateness, 2968786818cSJohn Scipione bool realTimeEvent) 2978786818cSJohn Scipione \brief Handles when an event is triggered. 2988786818cSJohn Scipione 2998786818cSJohn Scipione \param event The type of event. 3008786818cSJohn Scipione \param lateness Unused. 3018786818cSJohn Scipione \param realTimeEvent Unused. 3028786818cSJohn Scipione*/ 303