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
+20 -20
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.
*
* Authors:
@@ -54,24 +54,24 @@ typedef struct {
class BDirectWindow : public BWindow {
public:
BDirectWindow(BRect frame, const char *title,
public:
BDirectWindow(BRect frame, const char* title,
window_type type, uint32 flags,
uint32 workspace = B_CURRENT_WORKSPACE);
BDirectWindow(BRect frame, const char *title,
BDirectWindow(BRect frame, const char* title,
window_look look, window_feel feel,
uint32 flags,
uint32 workspace = B_CURRENT_WORKSPACE);
virtual ~BDirectWindow();
static BArchivable* Instantiate(BMessage *data);
virtual status_t Archive(BMessage *data,
static BArchivable* Instantiate(BMessage* data);
virtual status_t Archive(BMessage* data,
bool deep = true) const;
virtual void Quit();
virtual void DispatchMessage(BMessage *message,
BHandler *handler);
virtual void MessageReceived(BMessage *message);
virtual void DispatchMessage(BMessage* message,
BHandler* handler);
virtual void MessageReceived(BMessage* message);
virtual void FrameMoved(BPoint newPosition);
virtual void WorkspacesChanged(uint32 oldWorkspaces,
uint32 newWorkspaces);
@@ -88,27 +88,27 @@ class BDirectWindow : public BWindow {
virtual void WindowActivated(bool state);
virtual void Show();
virtual void Hide();
virtual BHandler* ResolveSpecifier(BMessage *message,
int32 index, BMessage *specifier,
int32 form, const char *property);
virtual status_t GetSupportedSuites(BMessage *data);
virtual status_t Perform(perform_code code, void *arg);
virtual BHandler* ResolveSpecifier(BMessage* message,
int32 index, BMessage* specifier,
int32 what, const char* property);
virtual status_t GetSupportedSuites(BMessage* data);
virtual status_t Perform(perform_code code, void* arg);
private:
private:
virtual void task_looper();
virtual BMessage* ConvertToMessage(void *raw, int32 code);
virtual BMessage* ConvertToMessage(void* raw, int32 code);
public:
virtual void DirectConnected(direct_buffer_info *info);
status_t GetClippingRegion(BRegion *region,
BPoint *origin = NULL) const;
virtual void DirectConnected(direct_buffer_info* info);
status_t GetClippingRegion(BRegion* region,
BPoint* origin = NULL) const;
status_t SetFullScreen(bool enable);
bool IsFullScreen() const;
static bool SupportsWindowMode(
screen_id id = B_MAIN_SCREEN_ID);
private:
private:
typedef BWindow inherited;
virtual void _ReservedDirectWindow1();
-1
View File
@@ -102,7 +102,6 @@ private:
bool fPaused;
float fPauseGain;
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:
* Stefano Ceccherini <[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 -
BDirectWindow::BDirectWindow(BRect frame, const char *title, window_type type,
BDirectWindow::BDirectWindow(BRect frame, const char* title, window_type type,
uint32 flags, uint32 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)
:
BWindow(frame, title, look, feel, flags, workspace)
@@ -191,15 +191,15 @@ BDirectWindow::~BDirectWindow()
// #pragma mark - BWindow API implementation
BArchivable *
BDirectWindow::Instantiate(BMessage *data)
BArchivable*
BDirectWindow::Instantiate(BMessage* data)
{
return NULL;
}
status_t
BDirectWindow::Archive(BMessage *data, bool deep) const
BDirectWindow::Archive(BMessage* data, bool deep) const
{
return inherited::Archive(data, deep);
}
@@ -213,14 +213,14 @@ BDirectWindow::Quit()
void
BDirectWindow::DispatchMessage(BMessage *message, BHandler *handler)
BDirectWindow::DispatchMessage(BMessage* message, BHandler* handler)
{
inherited::DispatchMessage(message, handler);
}
void
BDirectWindow::MessageReceived(BMessage *message)
BDirectWindow::MessageReceived(BMessage* message)
{
inherited::MessageReceived(message);
}
@@ -310,23 +310,24 @@ BDirectWindow::Hide()
}
BHandler *
BDirectWindow::ResolveSpecifier(BMessage *msg, int32 index,
BMessage *specifier, int32 form, const char *property)
BHandler*
BDirectWindow::ResolveSpecifier(BMessage* message, int32 index,
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
BDirectWindow::GetSupportedSuites(BMessage *data)
BDirectWindow::GetSupportedSuites(BMessage* data)
{
return inherited::GetSupportedSuites(data);
}
status_t
BDirectWindow::Perform(perform_code d, void *arg)
BDirectWindow::Perform(perform_code d, void* arg)
{
return inherited::Perform(d, arg);
}
@@ -339,8 +340,8 @@ BDirectWindow::task_looper()
}
BMessage *
BDirectWindow::ConvertToMessage(void *raw, int32 code)
BMessage*
BDirectWindow::ConvertToMessage(void* raw, int32 code)
{
return inherited::ConvertToMessage(raw, code);
}
@@ -350,14 +351,14 @@ BDirectWindow::ConvertToMessage(void *raw, int32 code)
void
BDirectWindow::DirectConnected(direct_buffer_info *info)
BDirectWindow::DirectConnected(direct_buffer_info* info)
{
// implemented in subclasses
}
status_t
BDirectWindow::GetClippingRegion(BRegion *region, BPoint *origin) const
BDirectWindow::GetClippingRegion(BRegion* region, BPoint* origin) const
{
if (region == NULL)
return B_BAD_VALUE;
@@ -452,9 +453,9 @@ BDirectWindow::SupportsWindowMode(screen_id id)
/*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;
#if DW_NEEDS_LOCKING
BDirectWindow *casted = const_cast<BDirectWindow *>(this);
BDirectWindow* casted = const_cast<BDirectWindow*>(this);
if (atomic_add(&casted->fDirectLock, 1) > 0) {
do {
@@ -543,7 +544,7 @@ void
BDirectWindow::_UnlockDirect() const
{
#if DW_NEEDS_LOCKING
BDirectWindow *casted = const_cast<BDirectWindow *>(this);
BDirectWindow* casted = const_cast<BDirectWindow*>(this);
if (atomic_add(&casted->fDirectLock, -1) > 1)
release_sem(casted->fDirectSem);
+16 -17
View File
@@ -25,8 +25,8 @@
const int32 kPages = 20;
struct _gs_media_tracker
{
BMediaFile * file;
BMediaTrack * stream;
BMediaFile* file;
BMediaTrack* stream;
int64 frames;
size_t position;
};
@@ -34,7 +34,7 @@ struct _gs_media_tracker
// Local utility functions -----------------------------------------------
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);
@@ -53,7 +53,7 @@ FillBuffer(_gs_ramp * ramp, uint8 * data, uint8 * buffer, size_t * bytes)
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);
@@ -72,7 +72,7 @@ FillBuffer(_gs_ramp * ramp, int16 * data, int16 * buffer, size_t * bytes)
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;
bool bytesAreReady = (*bytes > 0);
@@ -95,7 +95,7 @@ FillBuffer(_gs_ramp * ramp, int32 * data, int32 * buffer, size_t * bytes)
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;
bool bytesAreReady = (*bytes > 0);
@@ -118,8 +118,8 @@ FillBuffer(_gs_ramp * ramp, float * data, float * buffer, size_t * bytes)
// BFileGameSound -------------------------------------------------------
BFileGameSound::BFileGameSound(const entry_ref *file, bool looping,
BGameSoundDevice *device)
BFileGameSound::BFileGameSound(const entry_ref* file, bool looping,
BGameSoundDevice* device)
:
BStreamingGameSound(device),
fAudioStream(NULL),
@@ -136,8 +136,8 @@ BFileGameSound::BFileGameSound(const entry_ref *file, bool looping,
}
BFileGameSound::BFileGameSound(const char *file, bool looping,
BGameSoundDevice *device)
BFileGameSound::BFileGameSound(const char* file, bool looping,
BGameSoundDevice* device)
:
BStreamingGameSound(device),
fAudioStream(NULL),
@@ -182,7 +182,7 @@ BFileGameSound::~BFileGameSound()
}
BGameSound *
BGameSound*
BFileGameSound::Clone() const
{
return NULL;
@@ -232,7 +232,7 @@ BFileGameSound::Preload()
void
BFileGameSound::FillBuffer(void *inBuffer, size_t inByteCount)
BFileGameSound::FillBuffer(void* inBuffer, size_t inByteCount)
{
// Split or combine decoder buffers into mixer buffers
// 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
char * buffer = (char*)inBuffer;
char* buffer = (char*)inBuffer;
switch(Format().format) {
case gs_audio_format::B_GS_U8:
@@ -306,7 +306,7 @@ BFileGameSound::FillBuffer(void *inBuffer, size_t inByteCount)
Unlock();
} else {
char * buffer = (char*)inBuffer;
char* buffer = (char*)inBuffer;
// Need to be able to stop asap when the pause flag is flipped.
while (fPlayPosition < fBufferSize && (!fPaused || fPausing)
@@ -321,8 +321,7 @@ BFileGameSound::FillBuffer(void *inBuffer, size_t inByteCount)
status_t
BFileGameSound::Perform(int32 selector,
void *data)
BFileGameSound::Perform(int32 selector, void* data)
{
return B_ERROR;
}
@@ -472,7 +471,7 @@ BFileGameSound::Load()
bool
BFileGameSound::Read(void * buffer, size_t bytes)
BFileGameSound::Read(void* buffer, size_t bytes)
{
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.
*
* 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
*/
@@ -81,8 +81,8 @@ GameProducer::~GameProducer()
// BMediaNode methods
BMediaAddOn *
GameProducer::AddOn(int32 *internal_id) const
BMediaAddOn*
GameProducer::AddOn(int32* internal_id) const
{
return NULL;
}
@@ -90,13 +90,13 @@ GameProducer::AddOn(int32 *internal_id) const
// BBufferProducer methods
status_t
GameProducer::GetNextOutput(int32* cookie, media_output* out_output)
GameProducer::GetNextOutput(int32* cookie, media_output* _output)
{
// we currently support only one output
if (0 != *cookie)
return B_BAD_INDEX;
*out_output = fOutput;
*_output = fOutput;
*cookie += 1;
return B_OK;
}
@@ -169,7 +169,7 @@ GameProducer::FormatProposal(const media_source& output, media_format* format)
status_t
GameProducer::PrepareToConnect(const media_source& what,
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
// 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
fOutput.destination = where;
fOutput.format = *format;
*out_source = fOutput.source;
*_source = fOutput.source;
strlcpy(out_name, fOutput.name, B_MEDIA_NAME_LENGTH);
return B_OK;
}
@@ -210,7 +210,7 @@ GameProducer::PrepareToConnect(const media_source& what,
void
GameProducer::Connect(status_t error, const media_source& source,
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
// 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.
fOutput.destination = destination;
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.
// Do so, then make sure we get our events early enough.
@@ -297,11 +297,11 @@ GameProducer::FormatChangeRequested(const media_source& source,
status_t
GameProducer::SetBufferGroup(const media_source& for_source,
GameProducer::SetBufferGroup(const media_source& forSource,
BBufferGroup* newGroup)
{
// 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;
// Are we being passed the buffer group we're already using?
@@ -320,7 +320,7 @@ GameProducer::SetBufferGroup(const media_source& for_source,
fBufferGroup = newGroup;
// get buffer length from the first buffer
BBuffer *buffers[1];
BBuffer* buffers[1];
if (newGroup->GetBufferList(1, buffers) != B_OK)
return B_BAD_VALUE;
fBufferSize = buffers[0]->SizeAvailable();
@@ -337,17 +337,17 @@ GameProducer::SetBufferGroup(const media_source& for_source,
status_t
GameProducer::GetLatency(bigtime_t* out_latency)
GameProducer::GetLatency(bigtime_t* _latency)
{
// report our *total* latency: internal plus downstream plus scheduling
*out_latency = EventLatency() + SchedulingLatency();
*_latency = EventLatency() + SchedulingLatency();
return B_OK;
}
void
GameProducer::LateNoticeReceived(const media_source& what, bigtime_t how_much,
bigtime_t performance_time)
GameProducer::LateNoticeReceived(const media_source& what, bigtime_t howMuch,
bigtime_t performanceDuration)
{
// If we're late, we need to catch up. Respond in a manner appropriate to
// 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
// there's not much we can do about that at the moment, so we try
// to start producing buffers earlier to compensate.
fInternalLatency += how_much;
fInternalLatency += howMuch;
SetEventLatency(fLatency + fInternalLatency);
} else {
// The other run modes dictate various strategies for sacrificing
@@ -393,7 +393,7 @@ GameProducer::LatencyChanged(const media_source& source,
status_t
GameProducer::SetPlayRate(int32 numer, int32 denom)
GameProducer::SetPlayRate(int32 numerator, int32 denominator)
{
// Play rates are weird. We don't support them
return B_ERROR;
+22 -34
View File
@@ -24,31 +24,21 @@
// Description: A MediaKit producer node which mixes sound from the GameKit
// 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/MediaEventLooper.h>
#include <GameSoundDefs.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class GameSoundBuffer;
// GameProducer class -------------------------------------------------------------
class GameProducer : public BBufferProducer, public BMediaEventLooper
{
class GameProducer : public BBufferProducer, public BMediaEventLooper {
public:
GameProducer(GameSoundBuffer * object,
GameProducer(GameSoundBuffer* object,
const gs_audio_format * format);
~GameProducer();
@@ -57,8 +47,7 @@ public:
// BBufferProducer methods
status_t FormatSuggestionRequested(media_type type,
int32 quality,
media_format* format);
int32 quality, media_format* format);
status_t FormatProposal(const media_source& output,
media_format* format);
@@ -69,44 +58,41 @@ public:
int32* _deprecated_);
status_t GetNextOutput(int32* cookie,
media_output* out_output);
media_output* _output);
status_t DisposeOutputCookie(int32 cookie);
status_t SetBufferGroup(const media_source& for_source,
status_t SetBufferGroup(const media_source& forSource,
BBufferGroup* group);
status_t GetLatency(bigtime_t* out_latency);
status_t GetLatency(bigtime_t* _latency);
status_t PrepareToConnect(const media_source& what,
const media_destination& where,
media_format* format,
media_source* out_source,
media_source* _source,
char* out_name);
void Connect(status_t error,
const media_source& source,
const media_destination& destination,
const media_format& format,
char* io_name);
char* ioName);
void Disconnect(const media_source& what,
const media_destination& where);
void LateNoticeReceived(const media_source& what,
bigtime_t how_much,
bigtime_t performance_time);
bigtime_t howMuch,
bigtime_t performanceDuration);
void EnableOutput(const media_source & what,
bool enabled,
int32* _deprecated_);
bool enabled, int32* _deprecated_);
status_t SetPlayRate(int32 numer,
int32 denom);
status_t SetPlayRate(int32 numerator, int32 denominator);
status_t HandleMessage(int32 message,
const void* data,
status_t HandleMessage(int32 message, const void* data,
size_t size);
void AdditionalBufferRequested(const media_source& source,
@@ -136,8 +122,9 @@ public:
private:
BBuffer* FillNextBuffer(bigtime_t event_time);
BBufferGroup * fBufferGroup;
bigtime_t fLatency, fInternalLatency;
BBufferGroup* fBufferGroup;
bigtime_t fLatency;
bigtime_t fInternalLatency;
media_output fOutput;
bool fOutputEnabled;
media_format fPreferredFormat;
@@ -145,8 +132,9 @@ private:
bigtime_t fStartTime;
size_t fFrameSize;
int64 fFramesSent;
GameSoundBuffer * fObject;
GameSoundBuffer* fObject;
size_t fBufferSize;
};
#endif
#endif // _GAME_PRODUCER_H