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