1*8786818cSJohn Scipione/* 2*8786818cSJohn Scipione * Copyright 2002-2010 Haiku Inc. All rights reserved. 3*8786818cSJohn Scipione * Distributed under the terms of the MIT License. 4*8786818cSJohn Scipione * 5*8786818cSJohn Scipione * Authors: 6*8786818cSJohn Scipione * Christopher ML Zumwalt May, zummy@users.sf.net 7*8786818cSJohn Scipione * Omri Barak 8*8786818cSJohn Scipione * Proofreaders: 9*8786818cSJohn Scipione * John Scipione, jscipione@gmail.com 10*8786818cSJohn Scipione * Corresponds to: 11*8786818cSJohn Scipione * src/kits/game/GameProducer.h rev 43514 12*8786818cSJohn Scipione * src/kits/game/GameProducer.cpp rev 43514 13*8786818cSJohn Scipione */ 14*8786818cSJohn Scipione 15*8786818cSJohn Scipione 16*8786818cSJohn Scipione/*! 17*8786818cSJohn Scipione \file GameProducer.h 18*8786818cSJohn Scipione \brief Provides the GameProducer class. 19*8786818cSJohn Scipione*/ 20*8786818cSJohn Scipione 21*8786818cSJohn Scipione 22*8786818cSJohn Scipione/*! 23*8786818cSJohn Scipione \class GameProducer 24*8786818cSJohn Scipione \ingroup game 25*8786818cSJohn Scipione \ingroup libbe 26*8786818cSJohn Scipione \brief A MediaKit producer node which mixes sound from the GameKit 27*8786818cSJohn Scipione and sends them to the audio mixer. 28*8786818cSJohn Scipione*/ 29*8786818cSJohn Scipione 30*8786818cSJohn Scipione 31*8786818cSJohn Scipione/*! 32*8786818cSJohn Scipione \fn GameProducer::GameProducer(GameSoundBuffer * object, 33*8786818cSJohn Scipione const gs_audio_format * format); 34*8786818cSJohn Scipione \brief Initializes the GameProducer with the passed in GameSoundBuffer 35*8786818cSJohn Scipione and gs_audio_format. 36*8786818cSJohn Scipione 37*8786818cSJohn Scipione \param object The GameSoundBuffer to 'sync' the GameProducer with. 38*8786818cSJohn Scipione \param format The gs_audio_format to set the GameProducer's format. 39*8786818cSJohn Scipione*/ 40*8786818cSJohn Scipione 41*8786818cSJohn Scipione 42*8786818cSJohn Scipione/*! 43*8786818cSJohn Scipione \fn GameProducer::~GameProducer() 44*8786818cSJohn Scipione \brief Destroys the GameProducer object and stops the BMediaEventLooper 45*8786818cSJohn Scipione thread. 46*8786818cSJohn Scipione*/ 47*8786818cSJohn Scipione 48*8786818cSJohn Scipione 49*8786818cSJohn Scipione/*! 50*8786818cSJohn Scipione \fn BMediaAddOn* GameProducer::AddOn(int32 *internal_id) const 51*8786818cSJohn Scipione \brief Unimplemented. 52*8786818cSJohn Scipione*/ 53*8786818cSJohn Scipione 54*8786818cSJohn Scipione 55*8786818cSJohn Scipione/*! 56*8786818cSJohn Scipione \fn status_t GameProducer::FormatSuggestionRequested(media_type type, 57*8786818cSJohn Scipione int32 quality, media_format* format) 58*8786818cSJohn Scipione \brief Checks if a certain media format works with the GameProducer. 59*8786818cSJohn Scipione 60*8786818cSJohn Scipione \warning Only supports raw audio at this point. 61*8786818cSJohn Scipione 62*8786818cSJohn Scipione \param type The media format being tested. 63*8786818cSJohn Scipione \param quality The quality of the media -- Not used in the method. 64*8786818cSJohn Scipione \param format The media format to send through. 65*8786818cSJohn Scipione 66*8786818cSJohn Scipione \returns A status code. 67*8786818cSJohn Scipione \retval B_OK \a type is supported. 68*8786818cSJohn Scipione \retval B_BAD_VALUE No \a format was received. 69*8786818cSJohn Scipione \retval B_MEDIA_BAD_FORMAT The \a format is not supported. 70*8786818cSJohn Scipione*/ 71*8786818cSJohn Scipione 72*8786818cSJohn Scipione 73*8786818cSJohn Scipione/*! 74*8786818cSJohn Scipione \fn status_t GameProducer::FormatProposal(const media_source& output, 75*8786818cSJohn Scipione media_format* format) 76*8786818cSJohn Scipione \brief Attempts to change the media format. 77*8786818cSJohn Scipione 78*8786818cSJohn Scipione \warning Only supports raw audio and wildcard audio types. 79*8786818cSJohn Scipione 80*8786818cSJohn Scipione \param output The source that the media outputs to. 81*8786818cSJohn Scipione \param format The type of media being proposed. 82*8786818cSJohn Scipione 83*8786818cSJohn Scipione \returns A status code. 84*8786818cSJohn Scipione \retval B_OK The \a format is supported. 85*8786818cSJohn Scipione \retval B_MEDIA_BAD_SOURCE The \a output doesn't match the current 86*8786818cSJohn Scipione output source. 87*8786818cSJohn Scipione \retval B_MEDIA_BAD_FORMAT The \a format is not supported. 88*8786818cSJohn Scipione 89*8786818cSJohn Scipione*/ 90*8786818cSJohn Scipione 91*8786818cSJohn Scipione 92*8786818cSJohn Scipione/*! 93*8786818cSJohn Scipione \fn status_t GameProducer::FormatChangeRequested(const media_source& source, 94*8786818cSJohn Scipione const media_destination& destination, media_format* io_format, 95*8786818cSJohn Scipione int32* _deprecated_) 96*8786818cSJohn Scipione \brief We don't support any other formats, so we just reject any format changes. 97*8786818cSJohn Scipione 98*8786818cSJohn Scipione \attention This method is deprecated. 99*8786818cSJohn Scipione 100*8786818cSJohn Scipione \param source The output source. 101*8786818cSJohn Scipione \param destination The media's destination. 102*8786818cSJohn Scipione \param io_format The format of the media 103*8786818cSJohn Scipione \param _deprecated_ This method is deprecated. 104*8786818cSJohn Scipione 105*8786818cSJohn Scipione \returns B_ERROR as this function is deprecated, it has been removed, and 106*8786818cSJohn Scipione now only returns \a B_ERROR. 107*8786818cSJohn Scipione*/ 108*8786818cSJohn Scipione 109*8786818cSJohn Scipione 110*8786818cSJohn Scipione/*! 111*8786818cSJohn Scipione \fn status_t GameProducer::GetNextOutput(int32* cookie, 112*8786818cSJohn Scipione media_output* out_output) 113*8786818cSJohn Scipione \brief Gets the next output cookie. 114*8786818cSJohn Scipione 115*8786818cSJohn Scipione Cookie can only be zero, as GameProducer supports one output. 116*8786818cSJohn Scipione 117*8786818cSJohn Scipione \param cookie The output cookie value. 118*8786818cSJohn Scipione \param out_output The output that the cookie represents. 119*8786818cSJohn Scipione 120*8786818cSJohn Scipione \returns A status code. 121*8786818cSJohn Scipione \retval B_OK The cookie was successfully incremented. 122*8786818cSJohn Scipione \retval B_BAD_INDEX The cookie is not equal to zero. 123*8786818cSJohn Scipione*/ 124*8786818cSJohn Scipione 125*8786818cSJohn Scipione 126*8786818cSJohn Scipione/*! 127*8786818cSJohn Scipione \fn status_t GameProducer::DisposeOutputCookie(int32 cookie) 128*8786818cSJohn Scipione \brief Does nothing because the cookie has no use as of yet. 129*8786818cSJohn Scipione 130*8786818cSJohn Scipione \param cookie The cookie index. 131*8786818cSJohn Scipione 132*8786818cSJohn Scipione \return Always returns B_OK. 133*8786818cSJohn Scipione*/ 134*8786818cSJohn Scipione 135*8786818cSJohn Scipione 136*8786818cSJohn Scipione/*! 137*8786818cSJohn Scipione \fn status_t GameProducer::SetBufferGroup(const media_source& for_source, 138*8786818cSJohn Scipione BBufferGroup* newGroup) 139*8786818cSJohn Scipione \brief Changes the buffer group from the current one, to the specified one. 140*8786818cSJohn Scipione 141*8786818cSJohn Scipione \param for_source The output source. Can't be equivalent to the current 142*8786818cSJohn Scipione output source. 143*8786818cSJohn Scipione \param newGroup The new BBufferGroup to assign the buffer group to. 144*8786818cSJohn Scipione 145*8786818cSJohn Scipione \returns A status code. 146*8786818cSJohn Scipione \retval B_OK The change has succeeded. 147*8786818cSJohn Scipione \retval B_MEDIA_BAD_SOURCE \a for_source is equal to the current output source. 148*8786818cSJohn Scipione \retval B_BAD_VALUE The new BBufferGroup's buffer list returns an error. 149*8786818cSJohn Scipione*/ 150*8786818cSJohn Scipione 151*8786818cSJohn Scipione 152*8786818cSJohn Scipione/*! 153*8786818cSJohn Scipione \fn status_t GameProducer::GetLatency(bigtime_t* out_latency) 154*8786818cSJohn Scipione \brief Gets the total latency, including internal downstream plus scheduling. 155*8786818cSJohn Scipione 156*8786818cSJohn Scipione \param out_latency Gets set to the current latency. 157*8786818cSJohn Scipione 158*8786818cSJohn Scipione \returns B_OK. 159*8786818cSJohn Scipione*/ 160*8786818cSJohn Scipione 161*8786818cSJohn Scipione 162*8786818cSJohn Scipione/*! 163*8786818cSJohn Scipione \fn status_t GameProducer::PrepareToConnect(const media_source& what, 164*8786818cSJohn Scipione const media_destination& where, media_format* format, 165*8786818cSJohn Scipione media_source* out_source, char* out_name) 166*8786818cSJohn Scipione \brief Confirms that the media format and wild cards are valid. 167*8786818cSJohn Scipione 168*8786818cSJohn Scipione \param what The media source to output to. 169*8786818cSJohn Scipione \param where The destination for the connection. 170*8786818cSJohn Scipione \param format The format to finish specializing. 171*8786818cSJohn Scipione \param out_source The output source that the method retrieves. 172*8786818cSJohn Scipione \param out_name The variable that holds the output name. 173*8786818cSJohn Scipione 174*8786818cSJohn Scipione \returns A status code. 175*8786818cSJohn Scipione \retval B_OK The connection preparations have finished. 176*8786818cSJohn Scipione \retval B_MEDIA_BAD_SOURCE The \a output doesn't match the current output source. 177*8786818cSJohn Scipione \retval B_MEDIA_ALREADY_CONNECTED The GameProducer is already connected. 178*8786818cSJohn Scipione \retval B_MEDIA_BAD_FORMAT The \a format is not supported. 179*8786818cSJohn Scipione 180*8786818cSJohn Scipione*/ 181*8786818cSJohn Scipione 182*8786818cSJohn Scipione 183*8786818cSJohn Scipione/*! 184*8786818cSJohn Scipione \fn void GameProducer::Connect(status_t error, const media_source& source, 185*8786818cSJohn Scipione const media_destination& destination, const media_format& format, char* io_name) 186*8786818cSJohn Scipione \brief Connects to the output device. 187*8786818cSJohn Scipione 188*8786818cSJohn Scipione \param error The variable that holds an error, should one arise. 189*8786818cSJohn Scipione \param source The output source to connect to. 190*8786818cSJohn Scipione \param destination The media destination, that is connected to. 191*8786818cSJohn Scipione \param format The variable that holds the format type. 192*8786818cSJohn Scipione \param io_name The variable that holds the output name. 193*8786818cSJohn Scipione*/ 194*8786818cSJohn Scipione 195*8786818cSJohn Scipione 196*8786818cSJohn Scipione/*! 197*8786818cSJohn Scipione \fn void GameProducer::Disconnect(const media_source& what, const media_destination& where) 198*8786818cSJohn Scipione \brief Disconnects from the output device. 199*8786818cSJohn Scipione 200*8786818cSJohn Scipione \param what The media destination. 201*8786818cSJohn Scipione \param where The media's output source. 202*8786818cSJohn Scipione*/ 203*8786818cSJohn Scipione 204*8786818cSJohn Scipione 205*8786818cSJohn Scipione/*! 206*8786818cSJohn Scipione \fn void GameProducer::LateNoticeReceived(const media_source& what, 207*8786818cSJohn Scipione bigtime_t how_much, bigtime_t performance_time) 208*8786818cSJohn Scipione \brief Attempts to catch up to the buffer. 209*8786818cSJohn Scipione 210*8786818cSJohn Scipione \param what The media output source. 211*8786818cSJohn Scipione \param how_much The amount of 'lateness'. 212*8786818cSJohn Scipione \param performance_time Unused. 213*8786818cSJohn Scipione*/ 214*8786818cSJohn Scipione 215*8786818cSJohn Scipione 216*8786818cSJohn Scipione/*! 217*8786818cSJohn Scipione \fn void GameProducer::EnableOutput(const media_source& what, 218*8786818cSJohn Scipione bool enabled, int32* _deprecated_) 219*8786818cSJohn Scipione \brief Enable or disable an output. 220*8786818cSJohn Scipione 221*8786818cSJohn Scipione \attention This method is deprecated. 222*8786818cSJohn Scipione 223*8786818cSJohn Scipione \param what The media output source. 224*8786818cSJohn Scipione \param enabled Sets the output to enabled or disabled. 225*8786818cSJohn Scipione \param _deprecated_ This method is deprecated. 226*8786818cSJohn Scipione*/ 227*8786818cSJohn Scipione 228*8786818cSJohn Scipione 229*8786818cSJohn Scipione/*! 230*8786818cSJohn Scipione \fn status_t GameProducer::SetPlayRate(int32 numer, int32 denom) 231*8786818cSJohn Scipione \brief Play rates are not supported, returns \c B_ERROR. 232*8786818cSJohn Scipione 233*8786818cSJohn Scipione \param numer The top part of the fraction. 234*8786818cSJohn Scipione \param denom The bottom part of the fraction. 235*8786818cSJohn Scipione 236*8786818cSJohn Scipione \return Always returns \c B_ERROR since play rates aren't supported. 237*8786818cSJohn Scipione*/ 238*8786818cSJohn Scipione 239*8786818cSJohn Scipione 240*8786818cSJohn Scipione/*! 241*8786818cSJohn Scipione \fn status_t GameProducer::HandleMessage(int32 message, const void* data, 242*8786818cSJohn Scipione size_t size) 243*8786818cSJohn Scipione \brief Private messages are not supported, returns \c B_ERROR. 244*8786818cSJohn Scipione 245*8786818cSJohn Scipione \param message The message to be sent. 246*8786818cSJohn Scipione \param data The data to be sent. 247*8786818cSJohn Scipione \param size The size of the message. 248*8786818cSJohn Scipione 249*8786818cSJohn Scipione \returns Always returns \c B_ERROR since private messages aren't supported. 250*8786818cSJohn Scipione*/ 251*8786818cSJohn Scipione 252*8786818cSJohn Scipione 253*8786818cSJohn Scipione/*! 254*8786818cSJohn Scipione \fn void GameProducer::AdditionalBufferRequested( 255*8786818cSJohn Scipione const media_source& source, 256*8786818cSJohn Scipione media_buffer_id prev_buffer, bigtime_t prev_time, 257*8786818cSJohn Scipione const media_seek_tag* prev_tag) 258*8786818cSJohn Scipione \brief Offline modes are not supported for now, does nothing. 259*8786818cSJohn Scipione 260*8786818cSJohn Scipione \param source The media output source. 261*8786818cSJohn Scipione \param prev_buffer The previous buffer. 262*8786818cSJohn Scipione \param prev_time The previous buffer time. 263*8786818cSJohn Scipione \param prev_tag The previous buffer delimiter. 264*8786818cSJohn Scipione*/ 265*8786818cSJohn Scipione 266*8786818cSJohn Scipione 267*8786818cSJohn Scipione/*! 268*8786818cSJohn Scipione \fn void GameProducer::LatencyChanged(const media_source& source, 269*8786818cSJohn Scipione const media_destination& destination, bigtime_t new_latency, 270*8786818cSJohn Scipione uint32 flags) 271*8786818cSJohn Scipione \brief Sets the event latency in the case that the latency changed. 272*8786818cSJohn Scipione 273*8786818cSJohn Scipione \param source The media output source. 274*8786818cSJohn Scipione \param destination The connected output destination. 275*8786818cSJohn Scipione \param new_latency The new amount of latency. 276*8786818cSJohn Scipione \param flags Unused. 277*8786818cSJohn Scipione*/ 278*8786818cSJohn Scipione 279*8786818cSJohn Scipione 280*8786818cSJohn Scipione/*! 281*8786818cSJohn Scipione \fn void GameProducer::NodeRegistered() 282*8786818cSJohn Scipione \brief Handles when an output source node is registered. 283*8786818cSJohn Scipione*/ 284*8786818cSJohn Scipione 285*8786818cSJohn Scipione 286*8786818cSJohn Scipione/*! 287*8786818cSJohn Scipione \fn void GameProducer::SetRunMode(run_mode mode) 288*8786818cSJohn Scipione \brief Offline mode is not supported. 289*8786818cSJohn Scipione 290*8786818cSJohn Scipione \param mode The mode of running. 291*8786818cSJohn Scipione*/ 292*8786818cSJohn Scipione 293*8786818cSJohn Scipione 294*8786818cSJohn Scipione/*! 295*8786818cSJohn Scipione \fn void GameProducer::HandleEvent(const media_timed_event* event, bigtime_t lateness, 296*8786818cSJohn Scipione bool realTimeEvent) 297*8786818cSJohn Scipione \brief Handles when an event is triggered. 298*8786818cSJohn Scipione 299*8786818cSJohn Scipione \param event The type of event. 300*8786818cSJohn Scipione \param lateness Unused. 301*8786818cSJohn Scipione \param realTimeEvent Unused. 302*8786818cSJohn Scipione*/ 303