Public Member Functions | List of all members
GameProducer Class Reference

A MediaKit producer node which mixes sound from the GameKit and sends them to the audio mixer. More...

Inherits BBufferProducer, and BMediaEventLooper.

Public Member Functions

 GameProducer (GameSoundBuffer *object, const gs_audio_format *format)
 Initializes the GameProducer with the passed in GameSoundBuffer and gs_audio_format. More...
 
 ~GameProducer ()
 Destroys the GameProducer object and stops the BMediaEventLooper thread. More...
 
void AdditionalBufferRequested (const media_source &source, media_buffer_id prev_buffer, bigtime_t prev_time, const media_seek_tag *prev_tag)
 Offline modes are not supported for now, does nothing. More...
 
BMediaAddOnAddOn (int32 *internal_id) const
 Unimplemented. More...
 
void Connect (status_t error, const media_source &source, const media_destination &destination, const media_format &format, char *ioName)
 Connects to the output device. More...
 
void Disconnect (const media_source &what, const media_destination &where)
 Disconnects from the output device. More...
 
status_t DisposeOutputCookie (int32 cookie)
 Does nothing because the cookie has no use as of yet. More...
 
void EnableOutput (const media_source &what, bool enabled, int32 *_deprecated_)
 Enable or disable an output. More...
 
status_t FormatChangeRequested (const media_source &source, const media_destination &destination, media_format *io_format, int32 *_deprecated_)
 We don't support any other formats, so we just reject any format changes. More...
 
status_t FormatProposal (const media_source &output, media_format *format)
 Attempts to change the media format. More...
 
status_t FormatSuggestionRequested (media_type type, int32 quality, media_format *format)
 Checks if a certain media format works with the GameProducer. More...
 
status_t GetLatency (bigtime_t *_latency)
 Gets the total latency, including internal downstream plus scheduling. More...
 
status_t GetNextOutput (int32 *cookie, media_output *_output)
 Gets the next output cookie. More...
 
void HandleEvent (const media_timed_event *event, bigtime_t lateness, bool realTimeEvent=false)
 Handles when an event is triggered. More...
 
status_t HandleMessage (int32 message, const void *data, size_t size)
 Private messages are not supported, returns B_ERROR. More...
 
void LatencyChanged (const media_source &source, const media_destination &destination, bigtime_t new_latency, uint32 flags)
 Sets the event latency in the case that the latency changed. More...
 
void LateNoticeReceived (const media_source &what, bigtime_t howMuch, bigtime_t performanceDuration)
 Attempts to catch up to the buffer. More...
 
void NodeRegistered ()
 Handles when an output source node is registered. More...
 
status_t PrepareToConnect (const media_source &what, const media_destination &where, media_format *format, media_source *_source, char *out_name)
 Confirms that the media format and wild cards are valid. More...
 
status_t SetBufferGroup (const media_source &forSource, BBufferGroup *group)
 Changes the buffer group from the current one, to the specified one. More...
 
status_t SetPlayRate (int32 numerator, int32 denominator)
 Play rates are not supported, returns B_ERROR. More...
 
void SetRunMode (run_mode mode)
 Offline mode is not supported. More...
 

Detailed Description

A MediaKit producer node which mixes sound from the GameKit and sends them to the audio mixer.

Since
Haiku R1

Constructor & Destructor Documentation

◆ GameProducer()

GameProducer::GameProducer ( GameSoundBuffer *  object,
const gs_audio_format *  format 
)

Initializes the GameProducer with the passed in GameSoundBuffer and gs_audio_format.

Parameters
objectThe GameSoundBuffer to 'sync' the GameProducer with.
formatThe gs_audio_format to set the GameProducer's format.
Since
Haiku R1

◆ ~GameProducer()

GameProducer::~GameProducer ( )

Destroys the GameProducer object and stops the BMediaEventLooper thread.

Since
Haiku R1

Member Function Documentation

◆ AdditionalBufferRequested()

void GameProducer::AdditionalBufferRequested ( const media_source &  source,
media_buffer_id  prev_buffer,
bigtime_t  prev_time,
const media_seek_tag *  prev_tag 
)

Offline modes are not supported for now, does nothing.

Parameters
sourceThe media output source.
prev_bufferThe previous buffer.
prev_timeThe previous buffer time.
prev_tagThe previous buffer delimiter.
Since
Haiku R1

◆ AddOn()

BMediaAddOn * GameProducer::AddOn ( int32 *  internal_id) const
virtual

Unimplemented.

Since
Haiku R1

Implements BMediaNode.

◆ Connect()

void GameProducer::Connect ( status_t  error,
const media_source &  source,
const media_destination &  destination,
const media_format &  format,
char *  ioName 
)

Connects to the output device.

Parameters
errorThe variable that holds an error, should one arise.
sourceThe output source to connect to.
destinationThe media destination, that is connected to.
formatThe variable that holds the format type.
ioNameThe variable that holds the output name.

◆ Disconnect()

void GameProducer::Disconnect ( const media_source &  what,
const media_destination &  where 
)

Disconnects from the output device.

Parameters
whatThe media destination.
whereThe media's output source.
Since
Haiku R1

◆ DisposeOutputCookie()

status_t GameProducer::DisposeOutputCookie ( int32  cookie)

Does nothing because the cookie has no use as of yet.

Parameters
cookieThe cookie index.
Returns
Always returns B_OK.
Since
Haiku R1

◆ EnableOutput()

void GameProducer::EnableOutput ( const media_source &  what,
bool  enabled,
int32 *  _deprecated_ 
)

Enable or disable an output.

Attention
This method is deprecated.
Parameters
whatThe media output source.
enabledSets the output to enabled or disabled.
_deprecated_This method is deprecated.
Since
Haiku R1

◆ FormatChangeRequested()

status_t GameProducer::FormatChangeRequested ( const media_source &  source,
const media_destination &  destination,
media_format *  io_format,
int32 *  _deprecated_ 
)

We don't support any other formats, so we just reject any format changes.

Attention
This method is deprecated.
Parameters
sourceThe output source.
destinationThe media's destination.
io_formatThe format of the media
_deprecated_This method is deprecated.
Returns
B_ERROR as this function is deprecated, it has been removed, and now only returns B_ERROR.
Since
Haiku R1

◆ FormatProposal()

status_t GameProducer::FormatProposal ( const media_source &  output,
media_format *  format 
)

Attempts to change the media format.

Warning
Only supports raw audio and wildcard audio types.
Parameters
outputThe source that the media outputs to.
formatThe type of media being proposed.
Returns
A status code.
Return values
B_OKThe format is supported.
B_MEDIA_BAD_SOURCEThe output doesn't match the current output source.
B_MEDIA_BAD_FORMATThe format is not supported.
Since
Haiku R1

◆ FormatSuggestionRequested()

status_t GameProducer::FormatSuggestionRequested ( media_type  type,
int32  quality,
media_format *  format 
)

Checks if a certain media format works with the GameProducer.

Warning
Only supports raw audio at this point.
Parameters
typeThe media format being tested.
qualityThe quality of the media – Not used in the method.
formatThe media format to send through.
Returns
A status code.
Return values
B_OKtype is supported.
B_BAD_VALUENo format was received.
B_MEDIA_BAD_FORMATThe format is not supported.
Since
Haiku R1

◆ GetLatency()

status_t GameProducer::GetLatency ( bigtime_t _latency)

Gets the total latency, including internal downstream plus scheduling.

Parameters
_latencyGets set to the current latency.
Returns
B_OK.
Since
Haiku R1

◆ GetNextOutput()

status_t GameProducer::GetNextOutput ( int32 *  cookie,
media_output *  _output 
)

Gets the next output cookie.

Cookie can only be zero, as GameProducer supports one output.

Parameters
cookieThe output cookie value.
_outputThe output that the cookie represents.
Returns
A status code.
Return values
B_OKThe cookie was successfully incremented.
B_BAD_INDEXThe cookie is not equal to zero.
Since
Haiku R1

◆ HandleEvent()

void GameProducer::HandleEvent ( const media_timed_event *  event,
bigtime_t  lateness,
bool  realTimeEvent = false 
)
virtual

Handles when an event is triggered.

Parameters
eventThe type of event.
latenessUnused.
realTimeEventUnused.
Since
Haiku R1

Implements BMediaEventLooper.

◆ HandleMessage()

status_t GameProducer::HandleMessage ( int32  message,
const void *  data,
size_t  size 
)
virtual

Private messages are not supported, returns B_ERROR.

Parameters
messageThe message to be sent.
dataThe data to be sent.
sizeThe size of the message.
Returns
Always returns B_ERROR since private messages aren't supported.
Since
Haiku R1

Reimplemented from BMediaNode.

◆ LatencyChanged()

void GameProducer::LatencyChanged ( const media_source &  source,
const media_destination &  destination,
bigtime_t  new_latency,
uint32  flags 
)

Sets the event latency in the case that the latency changed.

Parameters
sourceThe media output source.
destinationThe connected output destination.
new_latencyThe new amount of latency.
flagsUnused.
Since
Haiku R1

◆ LateNoticeReceived()

void GameProducer::LateNoticeReceived ( const media_source &  what,
bigtime_t  howMuch,
bigtime_t  performanceDuration 
)

Attempts to catch up to the buffer.

Parameters
whatThe media output source.
howMuchThe amount of 'lateness'.
performanceDurationUnused.
Since
Haiku R1

◆ NodeRegistered()

void GameProducer::NodeRegistered ( )
virtual

Handles when an output source node is registered.

Since
Haiku R1

Reimplemented from BMediaEventLooper.

◆ PrepareToConnect()

status_t GameProducer::PrepareToConnect ( const media_source &  what,
const media_destination &  where,
media_format *  format,
media_source *  _source,
char *  out_name 
)

Confirms that the media format and wild cards are valid.

Parameters
whatThe media source to output to.
whereThe destination for the connection.
formatThe format to finish specializing.
_sourceThe output source that the method retrieves.
out_nameThe variable that holds the output name.
Returns
A status code.
Return values
B_OKThe connection preparations have finished.
B_MEDIA_BAD_SOURCEThe output doesn't match the current output source.
B_MEDIA_ALREADY_CONNECTEDThe GameProducer is already connected.
B_MEDIA_BAD_FORMATThe format is not supported.
Since
Haiku R1

◆ SetBufferGroup()

status_t GameProducer::SetBufferGroup ( const media_source &  forSource,
BBufferGroup *  newGroup 
)

Changes the buffer group from the current one, to the specified one.

Parameters
forSourceThe output source. Can't be equivalent to the current output source.
newGroupThe new BBufferGroup to assign the buffer group to.
Returns
A status code.
Return values
B_OKThe change has succeeded.
B_MEDIA_BAD_SOURCEforSource is equal to the current output source.
B_BAD_VALUEThe new BBufferGroup's buffer list returns an error.
Since
Haiku R1

◆ SetPlayRate()

status_t GameProducer::SetPlayRate ( int32  numerator,
int32  denominator 
)

Play rates are not supported, returns B_ERROR.

Parameters
numeratorThe top part of the fraction.
denominatorThe bottom part of the fraction.
Returns
Always returns B_ERROR since play rates aren't supported.
Since
Haiku R1

◆ SetRunMode()

void GameProducer::SetRunMode ( run_mode  mode)
virtual

Offline mode is not supported.

Parameters
modeThe mode of running.
Since
Haiku R1

Reimplemented from BMediaEventLooper.