Style fixes to the Game Kit, focus on docs

This commit is contained in:
John Scipione
2014-06-11 16:44:48 -04:00
parent ac9714d8a4
commit 37fedaf849
6 changed files with 216 additions and 229 deletions
+70 -70
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2008, Haiku. * Copyright 2001-2008 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -54,106 +54,106 @@ typedef struct {
class BDirectWindow : public BWindow { class BDirectWindow : public BWindow {
public: public:
BDirectWindow(BRect frame, const char *title, BDirectWindow(BRect frame, const char* title,
window_type type, uint32 flags, window_type type, uint32 flags,
uint32 workspace = B_CURRENT_WORKSPACE); uint32 workspace = B_CURRENT_WORKSPACE);
BDirectWindow(BRect frame, const char *title, BDirectWindow(BRect frame, const char* title,
window_look look, window_feel feel, window_look look, window_feel feel,
uint32 flags, uint32 flags,
uint32 workspace = B_CURRENT_WORKSPACE); uint32 workspace = B_CURRENT_WORKSPACE);
virtual ~BDirectWindow(); virtual ~BDirectWindow();
static BArchivable* Instantiate(BMessage *data); static BArchivable* Instantiate(BMessage* data);
virtual status_t Archive(BMessage *data, virtual status_t Archive(BMessage* data,
bool deep = true) const; bool deep = true) const;
virtual void Quit(); virtual void Quit();
virtual void DispatchMessage(BMessage *message, virtual void DispatchMessage(BMessage* message,
BHandler *handler); BHandler* handler);
virtual void MessageReceived(BMessage *message); virtual void MessageReceived(BMessage* message);
virtual void FrameMoved(BPoint newPosition); virtual void FrameMoved(BPoint newPosition);
virtual void WorkspacesChanged(uint32 oldWorkspaces, virtual void WorkspacesChanged(uint32 oldWorkspaces,
uint32 newWorkspaces); uint32 newWorkspaces);
virtual void WorkspaceActivated(int32 workspaceIndex, virtual void WorkspaceActivated(int32 workspaceIndex,
bool state); bool state);
virtual void FrameResized(float newWidth, float newHeight); virtual void FrameResized(float newWidth, float newHeight);
virtual void Minimize(bool minimize); virtual void Minimize(bool minimize);
virtual void Zoom(BPoint recPosition, float recWidth, virtual void Zoom(BPoint recPosition, float recWidth,
float recHeight); float recHeight);
virtual void ScreenChanged(BRect screenFrame, virtual void ScreenChanged(BRect screenFrame,
color_space depth); color_space depth);
virtual void MenusBeginning(); virtual void MenusBeginning();
virtual void MenusEnded(); virtual void MenusEnded();
virtual void WindowActivated(bool state); virtual void WindowActivated(bool state);
virtual void Show(); virtual void Show();
virtual void Hide(); virtual void Hide();
virtual BHandler* ResolveSpecifier(BMessage *message, virtual BHandler* ResolveSpecifier(BMessage* message,
int32 index, BMessage *specifier, int32 index, BMessage* specifier,
int32 form, const char *property); int32 what, const char* property);
virtual status_t GetSupportedSuites(BMessage *data); virtual status_t GetSupportedSuites(BMessage* data);
virtual status_t Perform(perform_code code, void *arg); virtual status_t Perform(perform_code code, void* arg);
private: private:
virtual void task_looper(); virtual void task_looper();
virtual BMessage* ConvertToMessage(void *raw, int32 code); virtual BMessage* ConvertToMessage(void* raw, int32 code);
public: public:
virtual void DirectConnected(direct_buffer_info *info); virtual void DirectConnected(direct_buffer_info* info);
status_t GetClippingRegion(BRegion *region, status_t GetClippingRegion(BRegion* region,
BPoint *origin = NULL) const; BPoint* origin = NULL) const;
status_t SetFullScreen(bool enable); status_t SetFullScreen(bool enable);
bool IsFullScreen() const; bool IsFullScreen() const;
static bool SupportsWindowMode( static bool SupportsWindowMode(
screen_id id = B_MAIN_SCREEN_ID); screen_id id = B_MAIN_SCREEN_ID);
private: private:
typedef BWindow inherited; typedef BWindow inherited;
virtual void _ReservedDirectWindow1(); virtual void _ReservedDirectWindow1();
virtual void _ReservedDirectWindow2(); virtual void _ReservedDirectWindow2();
virtual void _ReservedDirectWindow3(); virtual void _ReservedDirectWindow3();
virtual void _ReservedDirectWindow4(); virtual void _ReservedDirectWindow4();
BDirectWindow(); BDirectWindow();
BDirectWindow(BDirectWindow& other); BDirectWindow(BDirectWindow& other);
BDirectWindow& operator=(BDirectWindow& other); BDirectWindow& operator=(BDirectWindow& other);
static int32 _daemon_thread(void* arg); static int32 _daemon_thread(void* arg);
int32 _DirectDaemon(); int32 _DirectDaemon();
bool _LockDirect() const; bool _LockDirect() const;
void _UnlockDirect() const; void _UnlockDirect() const;
void _InitData(); void _InitData();
void _DisposeData(); void _DisposeData();
bool fDaemonKiller; bool fDaemonKiller;
bool fConnectionEnable; bool fConnectionEnable;
bool fIsFullScreen; bool fIsFullScreen;
bool _unused; bool _unused;
bool fInDirectConnect; bool fInDirectConnect;
int32 fDirectLock; int32 fDirectLock;
sem_id fDirectSem; sem_id fDirectSem;
uint32 fDirectLockCount; uint32 fDirectLockCount;
thread_id fDirectLockOwner; thread_id fDirectLockOwner;
char* fDirectLockStack; char* fDirectLockStack;
sem_id fDisableSem; sem_id fDisableSem;
sem_id fDisableSemAck; sem_id fDisableSemAck;
uint32 fInitStatus; uint32 fInitStatus;
uint32 fInfoAreaSize; uint32 fInfoAreaSize;
uint32 _reserved[2]; uint32 _reserved[2];
area_id fClonedClippingArea; area_id fClonedClippingArea;
area_id fSourceClippingArea; area_id fSourceClippingArea;
thread_id fDirectDaemonId; thread_id fDirectDaemonId;
direct_buffer_info* fBufferDesc; direct_buffer_info* fBufferDesc;
uint32 _more_reserved_[17]; uint32 _more_reserved_[17];
}; };
+2 -3
View File
@@ -94,15 +94,14 @@ private:
size_t fFrameSize; size_t fFrameSize;
size_t fBufferSize; size_t fBufferSize;
size_t fPlayPosition; size_t fPlayPosition;
thread_id fReadThread; thread_id fReadThread;
port_id fPort; port_id fPort;
_gs_ramp* fPausing; _gs_ramp* fPausing;
bool fPaused; bool fPaused;
float fPauseGain; float fPauseGain;
uint32 _reserved[9]; uint32 _reserved[9];
}; };
+25 -24
View File
@@ -1,10 +1,10 @@
/* /*
* Copyright 2003-2009, Haiku Inc. * Copyright 2003-2009 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors: * Authors:
* Stefano Ceccherini <[email protected]> * Stefano Ceccherini <[email protected]>
* Carwyn Jones <[email protected]> * Carwyn Jones <[email protected]>
*
* Distributed under the terms of the MIT License.
*/ */
@@ -164,7 +164,7 @@ print_direct_buffer_info(const direct_buffer_info &info)
// #pragma mark - // #pragma mark -
BDirectWindow::BDirectWindow(BRect frame, const char *title, window_type type, BDirectWindow::BDirectWindow(BRect frame, const char* title, window_type type,
uint32 flags, uint32 workspace) uint32 flags, uint32 workspace)
: :
BWindow(frame, title, type, flags, workspace) BWindow(frame, title, type, flags, workspace)
@@ -173,7 +173,7 @@ BDirectWindow::BDirectWindow(BRect frame, const char *title, window_type type,
} }
BDirectWindow::BDirectWindow(BRect frame, const char *title, window_look look, BDirectWindow::BDirectWindow(BRect frame, const char* title, window_look look,
window_feel feel, uint32 flags, uint32 workspace) window_feel feel, uint32 flags, uint32 workspace)
: :
BWindow(frame, title, look, feel, flags, workspace) BWindow(frame, title, look, feel, flags, workspace)
@@ -191,15 +191,15 @@ BDirectWindow::~BDirectWindow()
// #pragma mark - BWindow API implementation // #pragma mark - BWindow API implementation
BArchivable * BArchivable*
BDirectWindow::Instantiate(BMessage *data) BDirectWindow::Instantiate(BMessage* data)
{ {
return NULL; return NULL;
} }
status_t status_t
BDirectWindow::Archive(BMessage *data, bool deep) const BDirectWindow::Archive(BMessage* data, bool deep) const
{ {
return inherited::Archive(data, deep); return inherited::Archive(data, deep);
} }
@@ -213,14 +213,14 @@ BDirectWindow::Quit()
void void
BDirectWindow::DispatchMessage(BMessage *message, BHandler *handler) BDirectWindow::DispatchMessage(BMessage* message, BHandler* handler)
{ {
inherited::DispatchMessage(message, handler); inherited::DispatchMessage(message, handler);
} }
void void
BDirectWindow::MessageReceived(BMessage *message) BDirectWindow::MessageReceived(BMessage* message)
{ {
inherited::MessageReceived(message); inherited::MessageReceived(message);
} }
@@ -310,23 +310,24 @@ BDirectWindow::Hide()
} }
BHandler * BHandler*
BDirectWindow::ResolveSpecifier(BMessage *msg, int32 index, BDirectWindow::ResolveSpecifier(BMessage* message, int32 index,
BMessage *specifier, int32 form, const char *property) BMessage* specifier, int32 what, const char* property)
{ {
return inherited::ResolveSpecifier(msg, index, specifier, form, property); return inherited::ResolveSpecifier(message, index, specifier, what,
property);
} }
status_t status_t
BDirectWindow::GetSupportedSuites(BMessage *data) BDirectWindow::GetSupportedSuites(BMessage* data)
{ {
return inherited::GetSupportedSuites(data); return inherited::GetSupportedSuites(data);
} }
status_t status_t
BDirectWindow::Perform(perform_code d, void *arg) BDirectWindow::Perform(perform_code d, void* arg)
{ {
return inherited::Perform(d, arg); return inherited::Perform(d, arg);
} }
@@ -339,8 +340,8 @@ BDirectWindow::task_looper()
} }
BMessage * BMessage*
BDirectWindow::ConvertToMessage(void *raw, int32 code) BDirectWindow::ConvertToMessage(void* raw, int32 code)
{ {
return inherited::ConvertToMessage(raw, code); return inherited::ConvertToMessage(raw, code);
} }
@@ -350,14 +351,14 @@ BDirectWindow::ConvertToMessage(void *raw, int32 code)
void void
BDirectWindow::DirectConnected(direct_buffer_info *info) BDirectWindow::DirectConnected(direct_buffer_info* info)
{ {
// implemented in subclasses // implemented in subclasses
} }
status_t status_t
BDirectWindow::GetClippingRegion(BRegion *region, BPoint *origin) const BDirectWindow::GetClippingRegion(BRegion* region, BPoint* origin) const
{ {
if (region == NULL) if (region == NULL)
return B_BAD_VALUE; return B_BAD_VALUE;
@@ -452,9 +453,9 @@ BDirectWindow::SupportsWindowMode(screen_id id)
/*static*/ int32 /*static*/ int32
BDirectWindow::_daemon_thread(void *arg) BDirectWindow::_daemon_thread(void* arg)
{ {
return static_cast<BDirectWindow *>(arg)->_DirectDaemon(); return static_cast<BDirectWindow*>(arg)->_DirectDaemon();
} }
@@ -521,7 +522,7 @@ BDirectWindow::_LockDirect() const
status_t status = B_OK; status_t status = B_OK;
#if DW_NEEDS_LOCKING #if DW_NEEDS_LOCKING
BDirectWindow *casted = const_cast<BDirectWindow *>(this); BDirectWindow* casted = const_cast<BDirectWindow*>(this);
if (atomic_add(&casted->fDirectLock, 1) > 0) { if (atomic_add(&casted->fDirectLock, 1) > 0) {
do { do {
@@ -543,7 +544,7 @@ void
BDirectWindow::_UnlockDirect() const BDirectWindow::_UnlockDirect() const
{ {
#if DW_NEEDS_LOCKING #if DW_NEEDS_LOCKING
BDirectWindow *casted = const_cast<BDirectWindow *>(this); BDirectWindow* casted = const_cast<BDirectWindow*>(this);
if (atomic_add(&casted->fDirectLock, -1) > 1) if (atomic_add(&casted->fDirectLock, -1) > 1)
release_sem(casted->fDirectSem); release_sem(casted->fDirectSem);
+16 -17
View File
@@ -25,8 +25,8 @@
const int32 kPages = 20; const int32 kPages = 20;
struct _gs_media_tracker struct _gs_media_tracker
{ {
BMediaFile * file; BMediaFile* file;
BMediaTrack * stream; BMediaTrack* stream;
int64 frames; int64 frames;
size_t position; size_t position;
}; };
@@ -34,7 +34,7 @@ struct _gs_media_tracker
// Local utility functions ----------------------------------------------- // Local utility functions -----------------------------------------------
bool bool
FillBuffer(_gs_ramp * ramp, uint8 * data, uint8 * buffer, size_t * bytes) FillBuffer(_gs_ramp* ramp, uint8* data, uint8* buffer, size_t* bytes)
{ {
int32 samples = *bytes / sizeof(uint8); int32 samples = *bytes / sizeof(uint8);
@@ -53,7 +53,7 @@ FillBuffer(_gs_ramp * ramp, uint8 * data, uint8 * buffer, size_t * bytes)
bool bool
FillBuffer(_gs_ramp * ramp, int16 * data, int16 * buffer, size_t * bytes) FillBuffer(_gs_ramp* ramp, int16* data, int16* buffer, size_t* bytes)
{ {
int32 samples = *bytes / sizeof(int16); int32 samples = *bytes / sizeof(int16);
@@ -72,7 +72,7 @@ FillBuffer(_gs_ramp * ramp, int16 * data, int16 * buffer, size_t * bytes)
bool bool
FillBuffer(_gs_ramp * ramp, int32 * data, int32 * buffer, size_t * bytes) FillBuffer(_gs_ramp* ramp, int32* data, int32* buffer, size_t* bytes)
{ {
size_t byte = 0; size_t byte = 0;
bool bytesAreReady = (*bytes > 0); bool bytesAreReady = (*bytes > 0);
@@ -95,7 +95,7 @@ FillBuffer(_gs_ramp * ramp, int32 * data, int32 * buffer, size_t * bytes)
bool bool
FillBuffer(_gs_ramp * ramp, float * data, float * buffer, size_t * bytes) FillBuffer(_gs_ramp* ramp, float* data, float* buffer, size_t* bytes)
{ {
size_t byte = 0; size_t byte = 0;
bool bytesAreReady = (*bytes > 0); bool bytesAreReady = (*bytes > 0);
@@ -118,8 +118,8 @@ FillBuffer(_gs_ramp * ramp, float * data, float * buffer, size_t * bytes)
// BFileGameSound ------------------------------------------------------- // BFileGameSound -------------------------------------------------------
BFileGameSound::BFileGameSound(const entry_ref *file, bool looping, BFileGameSound::BFileGameSound(const entry_ref* file, bool looping,
BGameSoundDevice *device) BGameSoundDevice* device)
: :
BStreamingGameSound(device), BStreamingGameSound(device),
fAudioStream(NULL), fAudioStream(NULL),
@@ -136,8 +136,8 @@ BFileGameSound::BFileGameSound(const entry_ref *file, bool looping,
} }
BFileGameSound::BFileGameSound(const char *file, bool looping, BFileGameSound::BFileGameSound(const char* file, bool looping,
BGameSoundDevice *device) BGameSoundDevice* device)
: :
BStreamingGameSound(device), BStreamingGameSound(device),
fAudioStream(NULL), fAudioStream(NULL),
@@ -182,7 +182,7 @@ BFileGameSound::~BFileGameSound()
} }
BGameSound * BGameSound*
BFileGameSound::Clone() const BFileGameSound::Clone() const
{ {
return NULL; return NULL;
@@ -232,7 +232,7 @@ BFileGameSound::Preload()
void void
BFileGameSound::FillBuffer(void *inBuffer, size_t inByteCount) BFileGameSound::FillBuffer(void* inBuffer, size_t inByteCount)
{ {
// Split or combine decoder buffers into mixer buffers // Split or combine decoder buffers into mixer buffers
// fPlayPosition is where we got up to in the input buffer after last call // fPlayPosition is where we got up to in the input buffer after last call
@@ -258,7 +258,7 @@ BFileGameSound::FillBuffer(void *inBuffer, size_t inByteCount)
} }
// Fill the requested buffer, stopping if the paused flag is set // Fill the requested buffer, stopping if the paused flag is set
char * buffer = (char*)inBuffer; char* buffer = (char*)inBuffer;
switch(Format().format) { switch(Format().format) {
case gs_audio_format::B_GS_U8: case gs_audio_format::B_GS_U8:
@@ -306,7 +306,7 @@ BFileGameSound::FillBuffer(void *inBuffer, size_t inByteCount)
Unlock(); Unlock();
} else { } else {
char * buffer = (char*)inBuffer; char* buffer = (char*)inBuffer;
// Need to be able to stop asap when the pause flag is flipped. // Need to be able to stop asap when the pause flag is flipped.
while (fPlayPosition < fBufferSize && (!fPaused || fPausing) while (fPlayPosition < fBufferSize && (!fPaused || fPausing)
@@ -321,8 +321,7 @@ BFileGameSound::FillBuffer(void *inBuffer, size_t inByteCount)
status_t status_t
BFileGameSound::Perform(int32 selector, BFileGameSound::Perform(int32 selector, void* data)
void *data)
{ {
return B_ERROR; return B_ERROR;
} }
@@ -472,7 +471,7 @@ BFileGameSound::Load()
bool bool
BFileGameSound::Read(void * buffer, size_t bytes) BFileGameSound::Read(void* buffer, size_t bytes)
{ {
return false; return false;
} }
+19 -19
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 Haiku, Inc. All rights reserved. * Copyright 2002-2014 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -7,7 +7,7 @@
*/ */
/*! A MediaKit producer node which mixes sound from the GameKit /* A MediaKit producer node which mixes sound from the GameKit
and sends them to the audio mixer and sends them to the audio mixer
*/ */
@@ -81,8 +81,8 @@ GameProducer::~GameProducer()
// BMediaNode methods // BMediaNode methods
BMediaAddOn * BMediaAddOn*
GameProducer::AddOn(int32 *internal_id) const GameProducer::AddOn(int32* internal_id) const
{ {
return NULL; return NULL;
} }
@@ -90,13 +90,13 @@ GameProducer::AddOn(int32 *internal_id) const
// BBufferProducer methods // BBufferProducer methods
status_t status_t
GameProducer::GetNextOutput(int32* cookie, media_output* out_output) GameProducer::GetNextOutput(int32* cookie, media_output* _output)
{ {
// we currently support only one output // we currently support only one output
if (0 != *cookie) if (0 != *cookie)
return B_BAD_INDEX; return B_BAD_INDEX;
*out_output = fOutput; *_output = fOutput;
*cookie += 1; *cookie += 1;
return B_OK; return B_OK;
} }
@@ -169,7 +169,7 @@ GameProducer::FormatProposal(const media_source& output, media_format* format)
status_t status_t
GameProducer::PrepareToConnect(const media_source& what, GameProducer::PrepareToConnect(const media_source& what,
const media_destination& where, media_format* format, const media_destination& where, media_format* format,
media_source* out_source, char* out_name) media_source* _source, char* out_name)
{ {
// The format has been processed by the consumer at this point. We need // The format has been processed by the consumer at this point. We need
// to insure the format is still acceptable and any wild care are filled in. // to insure the format is still acceptable and any wild care are filled in.
@@ -201,7 +201,7 @@ GameProducer::PrepareToConnect(const media_source& what,
// Now reserve the connection, and return information about it // Now reserve the connection, and return information about it
fOutput.destination = where; fOutput.destination = where;
fOutput.format = *format; fOutput.format = *format;
*out_source = fOutput.source; *_source = fOutput.source;
strlcpy(out_name, fOutput.name, B_MEDIA_NAME_LENGTH); strlcpy(out_name, fOutput.name, B_MEDIA_NAME_LENGTH);
return B_OK; return B_OK;
} }
@@ -210,7 +210,7 @@ GameProducer::PrepareToConnect(const media_source& what,
void void
GameProducer::Connect(status_t error, const media_source& source, GameProducer::Connect(status_t error, const media_source& source,
const media_destination& destination, const media_format& format, const media_destination& destination, const media_format& format,
char* io_name) char* ioName)
{ {
// If something earlier failed, Connect() might still be called, but with a // If something earlier failed, Connect() might still be called, but with a
// non-zero error code. When that happens we simply unreserve the // non-zero error code. When that happens we simply unreserve the
@@ -225,7 +225,7 @@ GameProducer::Connect(status_t error, const media_source& source,
// format that we agreed on, and report our connection name again. // format that we agreed on, and report our connection name again.
fOutput.destination = destination; fOutput.destination = destination;
fOutput.format = format; fOutput.format = format;
strlcpy(io_name, fOutput.name, B_MEDIA_NAME_LENGTH); strlcpy(ioName, fOutput.name, B_MEDIA_NAME_LENGTH);
// Now that we're connected, we can determine our downstream latency. // Now that we're connected, we can determine our downstream latency.
// Do so, then make sure we get our events early enough. // Do so, then make sure we get our events early enough.
@@ -297,11 +297,11 @@ GameProducer::FormatChangeRequested(const media_source& source,
status_t status_t
GameProducer::SetBufferGroup(const media_source& for_source, GameProducer::SetBufferGroup(const media_source& forSource,
BBufferGroup* newGroup) BBufferGroup* newGroup)
{ {
// verify that we didn't get bogus arguments before we proceed // verify that we didn't get bogus arguments before we proceed
if (for_source != fOutput.source) if (forSource != fOutput.source)
return B_MEDIA_BAD_SOURCE; return B_MEDIA_BAD_SOURCE;
// Are we being passed the buffer group we're already using? // Are we being passed the buffer group we're already using?
@@ -320,7 +320,7 @@ GameProducer::SetBufferGroup(const media_source& for_source,
fBufferGroup = newGroup; fBufferGroup = newGroup;
// get buffer length from the first buffer // get buffer length from the first buffer
BBuffer *buffers[1]; BBuffer* buffers[1];
if (newGroup->GetBufferList(1, buffers) != B_OK) if (newGroup->GetBufferList(1, buffers) != B_OK)
return B_BAD_VALUE; return B_BAD_VALUE;
fBufferSize = buffers[0]->SizeAvailable(); fBufferSize = buffers[0]->SizeAvailable();
@@ -337,17 +337,17 @@ GameProducer::SetBufferGroup(const media_source& for_source,
status_t status_t
GameProducer::GetLatency(bigtime_t* out_latency) GameProducer::GetLatency(bigtime_t* _latency)
{ {
// report our *total* latency: internal plus downstream plus scheduling // report our *total* latency: internal plus downstream plus scheduling
*out_latency = EventLatency() + SchedulingLatency(); *_latency = EventLatency() + SchedulingLatency();
return B_OK; return B_OK;
} }
void void
GameProducer::LateNoticeReceived(const media_source& what, bigtime_t how_much, GameProducer::LateNoticeReceived(const media_source& what, bigtime_t howMuch,
bigtime_t performance_time) bigtime_t performanceDuration)
{ {
// If we're late, we need to catch up. Respond in a manner appropriate to // If we're late, we need to catch up. Respond in a manner appropriate to
// our current run mode. // our current run mode.
@@ -363,7 +363,7 @@ GameProducer::LateNoticeReceived(const media_source& what, bigtime_t how_much,
// downstream nodes are not properly reporting their latency, but // downstream nodes are not properly reporting their latency, but
// there's not much we can do about that at the moment, so we try // there's not much we can do about that at the moment, so we try
// to start producing buffers earlier to compensate. // to start producing buffers earlier to compensate.
fInternalLatency += how_much; fInternalLatency += howMuch;
SetEventLatency(fLatency + fInternalLatency); SetEventLatency(fLatency + fInternalLatency);
} else { } else {
// The other run modes dictate various strategies for sacrificing // The other run modes dictate various strategies for sacrificing
@@ -393,7 +393,7 @@ GameProducer::LatencyChanged(const media_source& source,
status_t status_t
GameProducer::SetPlayRate(int32 numer, int32 denom) GameProducer::SetPlayRate(int32 numerator, int32 denominator)
{ {
// Play rates are weird. We don't support them // Play rates are weird. We don't support them
return B_ERROR; return B_ERROR;
+84 -96
View File
@@ -24,129 +24,117 @@
// Description: A MediaKit producer node which mixes sound from the GameKit // Description: A MediaKit producer node which mixes sound from the GameKit
// and sends them to the audio mixer // and sends them to the audio mixer
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#ifndef _GAME_PRODUCER_H
#define _GAME_PRODUCER_H
#ifndef _GAMEPRODUCER_H
#define _GAMEPRODUCER_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <media/BufferProducer.h> #include <media/BufferProducer.h>
#include <media/MediaEventLooper.h> #include <media/MediaEventLooper.h>
#include <GameSoundDefs.h> #include <GameSoundDefs.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class GameSoundBuffer; class GameSoundBuffer;
// GameProducer class -------------------------------------------------------------
class GameProducer : public BBufferProducer, public BMediaEventLooper class GameProducer : public BBufferProducer, public BMediaEventLooper {
{
public: public:
GameProducer(GameSoundBuffer * object, GameProducer(GameSoundBuffer* object,
const gs_audio_format * format); const gs_audio_format * format);
~GameProducer(); ~GameProducer();
// BMediaNode methods // BMediaNode methods
BMediaAddOn* AddOn(int32* internal_id) const; BMediaAddOn* AddOn(int32* internal_id) const;
// BBufferProducer methods // BBufferProducer methods
status_t FormatSuggestionRequested(media_type type, status_t FormatSuggestionRequested(media_type type,
int32 quality, int32 quality, media_format* format);
media_format* format);
status_t FormatProposal(const media_source& output, status_t FormatProposal(const media_source& output,
media_format* format); media_format* format);
status_t FormatChangeRequested(const media_source& source, status_t FormatChangeRequested(const media_source& source,
const media_destination& destination, const media_destination& destination,
media_format* io_format, media_format* io_format,
int32* _deprecated_);
status_t GetNextOutput(int32* cookie,
media_output* out_output);
status_t DisposeOutputCookie(int32 cookie);
status_t SetBufferGroup(const media_source& for_source,
BBufferGroup* group);
status_t GetLatency(bigtime_t* out_latency);
status_t PrepareToConnect(const media_source& what,
const media_destination& where,
media_format* format,
media_source* out_source,
char* out_name);
void Connect(status_t error,
const media_source& source,
const media_destination& destination,
const media_format& format,
char* io_name);
void Disconnect(const media_source& what,
const media_destination& where);
void LateNoticeReceived(const media_source& what,
bigtime_t how_much,
bigtime_t performance_time);
void EnableOutput(const media_source & what,
bool enabled,
int32* _deprecated_); int32* _deprecated_);
status_t SetPlayRate(int32 numer, status_t GetNextOutput(int32* cookie,
int32 denom); media_output* _output);
status_t HandleMessage(int32 message, status_t DisposeOutputCookie(int32 cookie);
const void* data,
status_t SetBufferGroup(const media_source& forSource,
BBufferGroup* group);
status_t GetLatency(bigtime_t* _latency);
status_t PrepareToConnect(const media_source& what,
const media_destination& where,
media_format* format,
media_source* _source,
char* out_name);
void Connect(status_t error,
const media_source& source,
const media_destination& destination,
const media_format& format,
char* ioName);
void Disconnect(const media_source& what,
const media_destination& where);
void LateNoticeReceived(const media_source& what,
bigtime_t howMuch,
bigtime_t performanceDuration);
void EnableOutput(const media_source & what,
bool enabled, int32* _deprecated_);
status_t SetPlayRate(int32 numerator, int32 denominator);
status_t HandleMessage(int32 message, const void* data,
size_t size); size_t size);
void AdditionalBufferRequested(const media_source& source, void AdditionalBufferRequested(const media_source& source,
media_buffer_id prev_buffer, media_buffer_id prev_buffer,
bigtime_t prev_time, bigtime_t prev_time,
const media_seek_tag* prev_tag); const media_seek_tag* prev_tag);
void LatencyChanged(const media_source& source, void LatencyChanged(const media_source& source,
const media_destination& destination, const media_destination& destination,
bigtime_t new_latency, bigtime_t new_latency,
uint32 flags); uint32 flags);
// BMediaEventLooper methods // BMediaEventLooper methods
void NodeRegistered(); void NodeRegistered();
void SetRunMode(run_mode mode); void SetRunMode(run_mode mode);
void HandleEvent(const media_timed_event* event, void HandleEvent(const media_timed_event* event,
bigtime_t lateness, bigtime_t lateness,
bool realTimeEvent = false); bool realTimeEvent = false);
// GameProducer // GameProducer
status_t StartPlaying(GameSoundBuffer* sound); status_t StartPlaying(GameSoundBuffer* sound);
status_t StopPlaying(GameSoundBuffer* sound); status_t StopPlaying(GameSoundBuffer* sound);
bool IsPlaying(GameSoundBuffer* sound) const; bool IsPlaying(GameSoundBuffer* sound) const;
int32 SoundCount() const; int32 SoundCount() const;
private: private:
BBuffer* FillNextBuffer(bigtime_t event_time); BBuffer* FillNextBuffer(bigtime_t event_time);
BBufferGroup * fBufferGroup; BBufferGroup* fBufferGroup;
bigtime_t fLatency, fInternalLatency; bigtime_t fLatency;
media_output fOutput; bigtime_t fInternalLatency;
bool fOutputEnabled; media_output fOutput;
media_format fPreferredFormat; bool fOutputEnabled;
media_format fPreferredFormat;
bigtime_t fStartTime;
size_t fFrameSize; bigtime_t fStartTime;
int64 fFramesSent; size_t fFrameSize;
GameSoundBuffer * fObject; int64 fFramesSent;
size_t fBufferSize; GameSoundBuffer* fObject;
size_t fBufferSize;
}; };
#endif
#endif // _GAME_PRODUCER_H