These files have been contributed by Christopher ML Zumwalt May
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1401 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,95 +1,105 @@
|
||||
/*******************************************************************************
|
||||
/
|
||||
/ File: FileGameSound.h
|
||||
/
|
||||
/ Description: BFileGameSound is a class that streams data out of a file.
|
||||
/
|
||||
/ Copyright 1999, Be Incorporated, All Rights Reserved
|
||||
/
|
||||
*******************************************************************************/
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2002, OpenBeOS
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// File Name: FileGameSound.h
|
||||
// Author: Christopher ML Zumwalt May ([email protected])
|
||||
// Description: BFileGameSound is a class that streams data out of a file.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#if !defined(_FILE_GAME_SOUND_H)
|
||||
#define _FILE_GAME_SOUND_H
|
||||
#ifndef _FILEGAMESOUND_H
|
||||
#define _FILEGAMESOUND_H
|
||||
|
||||
// Standard Includes -----------------------------------------------------------
|
||||
|
||||
// System Includes -------------------------------------------------------------
|
||||
#include <StreamingGameSound.h>
|
||||
|
||||
class BMediaFile;
|
||||
namespace BPrivate {
|
||||
class BTrackReader;
|
||||
}
|
||||
// Project Includes ------------------------------------------------------------
|
||||
|
||||
// Local Includes --------------------------------------------------------------
|
||||
|
||||
// Local Defines ---------------------------------------------------------------
|
||||
|
||||
// Globals ---------------------------------------------------------------------
|
||||
struct _gs_media_tracker;
|
||||
struct _gs_ramp;
|
||||
|
||||
// FileGameSound -------------------------------------------------------------
|
||||
class BFileGameSound : public BStreamingGameSound
|
||||
{
|
||||
public:
|
||||
BFileGameSound(
|
||||
const entry_ref * file,
|
||||
bool looping = true,
|
||||
BGameSoundDevice * device = NULL);
|
||||
BFileGameSound(
|
||||
const char * file,
|
||||
bool looping = true,
|
||||
BGameSoundDevice * device = NULL);
|
||||
BFileGameSound(const entry_ref * file,
|
||||
bool looping = true,
|
||||
BGameSoundDevice * device = NULL);
|
||||
BFileGameSound(const char * file,
|
||||
bool looping = true,
|
||||
BGameSoundDevice * device = NULL);
|
||||
|
||||
virtual ~BFileGameSound();
|
||||
virtual ~BFileGameSound();
|
||||
|
||||
virtual BGameSound * Clone() const;
|
||||
virtual BGameSound * Clone() const;
|
||||
|
||||
virtual status_t StartPlaying();
|
||||
virtual status_t StopPlaying();
|
||||
status_t Preload(); // if you have stopped and want to start quickly again
|
||||
virtual status_t StartPlaying();
|
||||
virtual status_t StopPlaying();
|
||||
status_t Preload(); // if you have stopped and want to start quickly again
|
||||
|
||||
virtual void FillBuffer(
|
||||
void * inBuffer,
|
||||
size_t inByteCount);
|
||||
|
||||
virtual status_t Perform(int32 selector, void * data);
|
||||
|
||||
virtual status_t SetPaused(
|
||||
bool isPaused,
|
||||
bigtime_t rampTime);
|
||||
enum {
|
||||
B_NOT_PAUSED,
|
||||
B_PAUSE_IN_PROGRESS,
|
||||
B_PAUSED
|
||||
};
|
||||
int32 IsPaused();
|
||||
virtual void FillBuffer(void * inBuffer,
|
||||
size_t inByteCount);
|
||||
virtual status_t Perform(int32 selector, void * data);
|
||||
virtual status_t SetPaused(bool isPaused,
|
||||
bigtime_t rampTime);
|
||||
enum {
|
||||
B_NOT_PAUSED,
|
||||
B_PAUSE_IN_PROGRESS,
|
||||
B_PAUSED
|
||||
};
|
||||
int32 IsPaused();
|
||||
|
||||
private:
|
||||
|
||||
BMediaFile * _m_soundFile;
|
||||
BPrivate::BTrackReader * _m_trackReader;
|
||||
bool _m_looping;
|
||||
bool _m_stopping;
|
||||
uchar _m_zero;
|
||||
uchar _m_reserved_u;
|
||||
|
||||
// cruft for read-ahead goes here
|
||||
thread_id _m_streamThread;
|
||||
port_id _m_streamPort;
|
||||
enum {
|
||||
cmdStartPlaying = 1,
|
||||
cmdStopPlaying,
|
||||
cmdUsedBytes,
|
||||
cmdPreload
|
||||
};
|
||||
int32 _m_loopCount;
|
||||
char * _m_buffer;
|
||||
size_t _m_bufferSize;
|
||||
int32 _m_stopCount;
|
||||
int32 _m_pauseState;
|
||||
float _m_pauseGain;
|
||||
float _m_pausePan;
|
||||
|
||||
static status_t stream_thread(
|
||||
void * that);
|
||||
void LoadFunc();
|
||||
size_t Load(
|
||||
size_t & offset,
|
||||
size_t bytes);
|
||||
void read_data(
|
||||
char * dest,
|
||||
size_t bytes);
|
||||
|
||||
_gs_media_tracker * fAudioStream;
|
||||
|
||||
bool fStopping;
|
||||
bool fLooping;
|
||||
char fReserved;
|
||||
char * fBuffer;
|
||||
|
||||
size_t fFrameSize;
|
||||
size_t fBufferSize;
|
||||
size_t fPlayPosition;
|
||||
|
||||
thread_id fReadThread;
|
||||
port_id fPort;
|
||||
|
||||
_gs_ramp * fPausing;
|
||||
bool fPaused;
|
||||
float fPauseGain;
|
||||
|
||||
status_t Init(const entry_ref* file);
|
||||
|
||||
static int32 ReadThread(void* arg);
|
||||
|
||||
bool Load();
|
||||
bool Read(void * buffer, size_t bytes);
|
||||
|
||||
/* leave these declarations private unless you plan on actually implementing and using them. */
|
||||
BFileGameSound();
|
||||
BFileGameSound(const BFileGameSound&);
|
||||
@@ -97,7 +107,7 @@ static status_t stream_thread(
|
||||
|
||||
/* fbc data and virtuals */
|
||||
|
||||
uint32 _reserved_BFileGameSound_[8];
|
||||
uint32 _reserved_BFileGameSound_[9];
|
||||
|
||||
status_t _Reserved_BFileGameSound_0(int32 arg, ...); /* SetPaused(bool paused, bigtime_t ramp); */
|
||||
virtual status_t _Reserved_BFileGameSound_1(int32 arg, ...);
|
||||
|
||||
+86
-87
@@ -1,110 +1,109 @@
|
||||
/*******************************************************************************
|
||||
/
|
||||
/ File: GameGameSound.h
|
||||
/
|
||||
/ Description: BGameSound is an abstract base class for all sounds being
|
||||
/ played using the gamesound kit. Use one of the concrete
|
||||
/ subclasses for actually playing sound.
|
||||
/
|
||||
/ Copyright 1999, Be Incorporated, All Rights Reserved
|
||||
/
|
||||
*******************************************************************************/
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2002, OpenBeOS
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// File Name: GameSound.h
|
||||
// Author: Christopher ML Zumwalt May ([email protected])
|
||||
// Description: Base class for play sounds using the game kit
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#ifndef _GAMESOUND_H
|
||||
#define _GAMESOUND_H
|
||||
|
||||
#if !defined(_GAME_SOUND_H)
|
||||
#define _GAME_SOUND_H
|
||||
|
||||
// Standard Includes -----------------------------------------------------------
|
||||
|
||||
// System Includes -------------------------------------------------------------
|
||||
#include <GameSoundDefs.h>
|
||||
#include <new>
|
||||
|
||||
struct gs_audio_format;
|
||||
// Project Includes ------------------------------------------------------------
|
||||
|
||||
// Local Includes --------------------------------------------------------------
|
||||
|
||||
// Local Defines ---------------------------------------------------------------
|
||||
|
||||
// Globals ---------------------------------------------------------------------
|
||||
class BGameSoundDevice;
|
||||
|
||||
namespace BPrivate {
|
||||
class PrivGameSound;
|
||||
}
|
||||
|
||||
// BGameSound class -------------------------------------------------------------
|
||||
class BGameSound
|
||||
{
|
||||
public:
|
||||
BGameSound(
|
||||
BGameSoundDevice * device = NULL);
|
||||
virtual ~BGameSound();
|
||||
BGameSound(BGameSoundDevice * device = NULL);
|
||||
virtual ~BGameSound();
|
||||
|
||||
virtual BGameSound * Clone() const = 0;
|
||||
status_t InitCheck() const;
|
||||
virtual BGameSound * Clone() const = 0;
|
||||
status_t InitCheck() const;
|
||||
|
||||
// BGameSound attributes
|
||||
BGameSoundDevice * Device() const;
|
||||
gs_id ID() const;
|
||||
const gs_audio_format & Format() const; // only valid after Init()
|
||||
|
||||
BGameSoundDevice * Device() const;
|
||||
gs_id ID() const;
|
||||
const gs_audio_format &
|
||||
Format() const; // only valid after Init()
|
||||
// Playing sounds
|
||||
virtual status_t StartPlaying();
|
||||
virtual bool IsPlaying();
|
||||
virtual status_t StopPlaying();
|
||||
|
||||
virtual status_t StartPlaying();
|
||||
virtual bool IsPlaying();
|
||||
virtual status_t StopPlaying();
|
||||
|
||||
// Modifing the playback
|
||||
status_t SetGain(float gain,
|
||||
bigtime_t duration = 0); // ramp duration in seconds
|
||||
status_t SetPan(float pan,
|
||||
bigtime_t duration = 0); // ramp duration in seconds
|
||||
float Gain();
|
||||
float Pan();
|
||||
|
||||
status_t SetGain(
|
||||
float gain,
|
||||
bigtime_t duration = 0); // ramp duration in seconds
|
||||
status_t SetPan(
|
||||
float pan,
|
||||
bigtime_t duration = 0); // ramp duration in seconds
|
||||
float Gain();
|
||||
float Pan();
|
||||
virtual status_t SetAttributes(gs_attribute * inAttributes,
|
||||
size_t inAttributeCount);
|
||||
virtual status_t GetAttributes(gs_attribute * outAttributes,
|
||||
size_t inAttributeCount);
|
||||
|
||||
virtual status_t SetAttributes(
|
||||
gs_attribute * inAttributes,
|
||||
size_t inAttributeCount);
|
||||
virtual status_t GetAttributes(
|
||||
gs_attribute * outAttributes,
|
||||
size_t inAttributeCount);
|
||||
|
||||
virtual status_t Perform(int32 selector, void * data);
|
||||
|
||||
void * operator new(
|
||||
size_t size);
|
||||
void * operator new(
|
||||
size_t size,
|
||||
const nothrow_t &) throw();
|
||||
void operator delete(
|
||||
void * ptr);
|
||||
#if !__MWERKS__
|
||||
// there's a bug in MWCC under R4.1 and earlier
|
||||
void operator delete(
|
||||
void * ptr,
|
||||
const nothrow_t &) throw();
|
||||
#endif
|
||||
|
||||
static status_t SetMemoryPoolSize( // implemented in PrivGameSound.cpp
|
||||
size_t in_poolSize);
|
||||
static status_t LockMemoryPool( // implemented in PrivGameSound.cpp
|
||||
bool in_lockInCore);
|
||||
static int32 SetMaxSoundCount( // implemented in PrivGameSound.cpp
|
||||
int32 in_maxCount);
|
||||
// void * operator new(size_t size);
|
||||
// void * operator new(size_t size, const nothrow_t &) throw();
|
||||
// void operator delete(void * ptr);
|
||||
//#if !__MWERKS__
|
||||
// there's a bug in MWCC under R4.1 and earlier
|
||||
// void operator delete(void * ptr,
|
||||
// const nothrow_t &) throw();
|
||||
//#endif
|
||||
|
||||
static status_t SetMemoryPoolSize(size_t in_poolSize);
|
||||
static status_t LockMemoryPool(bool in_lockInCore);
|
||||
static int32 SetMaxSoundCount(int32 in_maxCount);
|
||||
|
||||
virtual status_t Perform(int32 selector, void * data);
|
||||
protected:
|
||||
|
||||
status_t SetInitError(
|
||||
status_t in_initError);
|
||||
status_t Init(
|
||||
gs_id handle);
|
||||
|
||||
BGameSound(
|
||||
const BGameSound & other);
|
||||
BGameSound & operator=(
|
||||
const BGameSound & other);
|
||||
status_t SetInitError(status_t in_initError);
|
||||
status_t Init(gs_id handle);
|
||||
|
||||
BGameSound(const BGameSound & other);
|
||||
BGameSound & operator=(const BGameSound & other);
|
||||
|
||||
private:
|
||||
|
||||
friend class BPrivate::PrivGameSound;
|
||||
|
||||
gs_id _m_handle;
|
||||
BGameSoundDevice * _m_device;
|
||||
gs_audio_format
|
||||
_m_format;
|
||||
status_t _m_initError;
|
||||
|
||||
BGameSoundDevice* fDevice;
|
||||
status_t fInitError;
|
||||
|
||||
gs_audio_format fFormat;
|
||||
gs_id fSound;
|
||||
|
||||
/* leave these declarations private unless you plan on actually implementing and using them. */
|
||||
BGameSound();
|
||||
|
||||
|
||||
@@ -1,12 +1,28 @@
|
||||
/*******************************************************************************
|
||||
/
|
||||
/ File: GameSoundDefs.h
|
||||
/
|
||||
/ Description: Definitions of common types and constants for the gamesound kit.
|
||||
/
|
||||
/ Copyright 1999, Be Incorporated, All Rights Reserved
|
||||
/
|
||||
*******************************************************************************/
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2002, OpenBeOS
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// File Name: GameSound.cpp
|
||||
// Author: Christopher ML Zumwalt May ([email protected])
|
||||
// Description: Declerations for game sounds
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#if !defined(_GAME_SOUND_DEFS_H)
|
||||
#define _GAME_SOUND_DEFS_H
|
||||
|
||||
@@ -1,30 +1,54 @@
|
||||
/*******************************************************************************
|
||||
/
|
||||
/ File: PushGameSound.h
|
||||
/
|
||||
/ Description: BPushGameSound is a class for games that want to push data
|
||||
/ at the system, rather than have a callback get called.
|
||||
/
|
||||
/ Copyright 1999, Be Incorporated, All Rights Reserved
|
||||
/
|
||||
*******************************************************************************/
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2002, OpenBeOS
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// File Name: FileGameSound.h
|
||||
// Author: Christopher ML Zumwalt May ([email protected])
|
||||
// Description: BFileGameSound is a class that streams data out of a file.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#ifndef _PUSHGAMESOUND_H
|
||||
#define _PUSHGAMESOUND_H
|
||||
// Standard Includes -----------------------------------------------------------
|
||||
|
||||
#if !defined(_PUSH_GAME_SOUND_H)
|
||||
#define _PUSH_GAME_SOUND_H
|
||||
|
||||
// System Includes -------------------------------------------------------------
|
||||
#include <StreamingGameSound.h>
|
||||
|
||||
// Project Includes ------------------------------------------------------------
|
||||
|
||||
// Local Includes --------------------------------------------------------------
|
||||
|
||||
// Local Defines ---------------------------------------------------------------
|
||||
|
||||
// Globals ---------------------------------------------------------------------
|
||||
|
||||
// FileGameSound -------------------------------------------------------------
|
||||
class BPushGameSound : public BStreamingGameSound
|
||||
{
|
||||
public:
|
||||
BPushGameSound(
|
||||
size_t inBufferFrameCount,
|
||||
const gs_audio_format * format,
|
||||
size_t inBufferCount = 2,
|
||||
BGameSoundDevice * device = NULL);
|
||||
BPushGameSound(size_t inBufferFrameCount,
|
||||
const gs_audio_format * format,
|
||||
size_t inBufferCount = 2,
|
||||
BGameSoundDevice * device = NULL);
|
||||
|
||||
virtual ~BPushGameSound();
|
||||
virtual ~BPushGameSound();
|
||||
|
||||
enum lock_status {
|
||||
lock_failed = -1, // not yet time to do more
|
||||
@@ -32,56 +56,57 @@ virtual ~BPushGameSound();
|
||||
lock_ok_frames_dropped // you may have missed some buffers
|
||||
};
|
||||
|
||||
virtual lock_status LockNextPage(
|
||||
void ** out_pagePtr,
|
||||
size_t * out_pageSize);
|
||||
virtual status_t UnlockPage(
|
||||
void * in_pagePtr);
|
||||
virtual lock_status LockNextPage(void ** out_pagePtr,
|
||||
size_t * out_pageSize);
|
||||
virtual status_t UnlockPage(void * in_pagePtr);
|
||||
|
||||
virtual lock_status LockForCyclic(
|
||||
void ** out_basePtr,
|
||||
size_t * out_size);
|
||||
virtual status_t UnlockCyclic();
|
||||
virtual size_t CurrentPosition();
|
||||
virtual lock_status LockForCyclic(void ** out_basePtr,
|
||||
size_t * out_size);
|
||||
virtual status_t UnlockCyclic();
|
||||
virtual size_t CurrentPosition();
|
||||
|
||||
virtual BGameSound * Clone() const;
|
||||
virtual BGameSound * Clone() const;
|
||||
|
||||
virtual status_t Perform(int32 selector, void * data);
|
||||
virtual status_t Perform(int32 selector, void * data);
|
||||
|
||||
protected:
|
||||
|
||||
BPushGameSound(BGameSoundDevice * device);
|
||||
|
||||
virtual status_t SetParameters( // will allocate handle and call Init()
|
||||
size_t inBufferFrameCount,
|
||||
const gs_audio_format * format,
|
||||
size_t inBufferCount);
|
||||
virtual status_t SetParameters(size_t inBufferFrameCount,
|
||||
const gs_audio_format * format,
|
||||
size_t inBufferCount);
|
||||
|
||||
virtual status_t SetStreamHook(
|
||||
void (*hook)(void * inCookie, void * inBuffer, size_t inByteCount, BStreamingGameSound * me),
|
||||
void * cookie);
|
||||
virtual void FillBuffer( // default is to call stream hook, if any
|
||||
void * inBuffer,
|
||||
size_t inByteCount);
|
||||
virtual status_t SetStreamHook(void (*hook)(void * inCookie, void * inBuffer, size_t inByteCount, BStreamingGameSound * me),
|
||||
void * cookie);
|
||||
|
||||
virtual void FillBuffer(void * inBuffer,
|
||||
size_t inByteCount);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
/* leave these declarations private unless you plan on actually implementing and using them. */
|
||||
BPushGameSound();
|
||||
BPushGameSound(const BPushGameSound&);
|
||||
BPushGameSound& operator=(const BPushGameSound&);
|
||||
/* leave these declarations private unless you plan on actually implementing and using them. */
|
||||
BPushGameSound();
|
||||
BPushGameSound(const BPushGameSound&);
|
||||
BPushGameSound& operator=(const BPushGameSound&);
|
||||
|
||||
int32 _m_benCount;
|
||||
sem_id _m_benSem;
|
||||
char * _m_lockedPtr;
|
||||
char * _m_playedPtr;
|
||||
size_t _m_pageSize;
|
||||
int32 _m_pageCount;
|
||||
size_t _m_bufSize;
|
||||
char * _m_buffer;
|
||||
bool BytesReady(size_t * bytes);
|
||||
|
||||
sem_id fLock;
|
||||
BList * fPageLocked;
|
||||
|
||||
size_t fLockPos;
|
||||
size_t fPlayPos;
|
||||
|
||||
char * fBuffer;
|
||||
size_t fPageSize;
|
||||
int32 fPageCount;
|
||||
size_t fBufferSize;
|
||||
|
||||
/* fbc data and virtuals */
|
||||
/* fbc data and virtuals */
|
||||
|
||||
uint32 _reserved_BPushGameSound_[12];
|
||||
uint32 _reserved_BPushGameSound_[12];
|
||||
|
||||
virtual status_t _Reserved_BPushGameSound_0(int32 arg, ...);
|
||||
virtual status_t _Reserved_BPushGameSound_1(int32 arg, ...);
|
||||
|
||||
@@ -1,50 +1,78 @@
|
||||
/* SimpleGameSound.h */
|
||||
/*******************************************************************************
|
||||
/
|
||||
/ File: SimpleGameSound.h
|
||||
/
|
||||
/ Description: BSimpleGameSound is a class for sound effects that are
|
||||
/ short, and consists of non-changing samples in memory.
|
||||
/
|
||||
/ Copyright 1999, Be Incorporated, All Rights Reserved
|
||||
/
|
||||
*******************************************************************************/
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2002, OpenBeOS
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// File Name: SimpleGameSound.h
|
||||
// Author: Christopher ML Zumwalt May ([email protected])
|
||||
// Description: BSimpleGameSound is a class for sound effects that are
|
||||
// short, and consists of non-changing samples in memory.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#if !defined(_SIMPLE_GAME_SOUND_H)
|
||||
#define _SIMPLE_GAME_SOUND_H
|
||||
|
||||
#ifndef _SIMPLEGAMESOUND_H
|
||||
#define _SIMPLEGAMESOUND_H
|
||||
|
||||
// Standard Includes -----------------------------------------------------------
|
||||
|
||||
// System Includes -------------------------------------------------------------
|
||||
#include <GameSoundDefs.h>
|
||||
#include <GameSound.h>
|
||||
|
||||
// Project Includes ------------------------------------------------------------
|
||||
|
||||
// Local Includes --------------------------------------------------------------
|
||||
|
||||
// Local Defines ---------------------------------------------------------------
|
||||
|
||||
// Globals ---------------------------------------------------------------------
|
||||
|
||||
// BGameSound class -------------------------------------------------------------
|
||||
class BSimpleGameSound : public BGameSound
|
||||
{
|
||||
public:
|
||||
BSimpleGameSound(
|
||||
const entry_ref * inFile,
|
||||
BGameSoundDevice * device = NULL);
|
||||
BSimpleGameSound(
|
||||
const char * inFile,
|
||||
BGameSoundDevice * device = NULL);
|
||||
BSimpleGameSound(
|
||||
const void * inData,
|
||||
size_t inFrameCount,
|
||||
const gs_audio_format * format,
|
||||
BGameSoundDevice * device = NULL);
|
||||
BSimpleGameSound(const entry_ref * inFile,
|
||||
BGameSoundDevice * device = NULL);
|
||||
BSimpleGameSound(const char * inFile,
|
||||
BGameSoundDevice * device = NULL);
|
||||
BSimpleGameSound(const void * inData,
|
||||
size_t inFrameCount,
|
||||
const gs_audio_format * format,
|
||||
BGameSoundDevice * device = NULL);
|
||||
|
||||
BSimpleGameSound(
|
||||
const BSimpleGameSound & other);
|
||||
BSimpleGameSound(const BSimpleGameSound & other);
|
||||
|
||||
virtual ~BSimpleGameSound();
|
||||
virtual ~BSimpleGameSound();
|
||||
|
||||
virtual BGameSound * Clone() const;
|
||||
virtual BGameSound * Clone() const;
|
||||
|
||||
virtual status_t Perform(int32 selector, void * data);
|
||||
virtual status_t Perform(int32 selector, void * data);
|
||||
|
||||
status_t SetIsLooping(
|
||||
bool looping); // whether to go back to beginning
|
||||
bool IsLooping() const;
|
||||
status_t SetIsLooping(bool looping);
|
||||
bool IsLooping() const;
|
||||
|
||||
private:
|
||||
|
||||
status_t Init(const entry_ref * inFile);
|
||||
status_t Init(const void* inData,
|
||||
int64 inFrameCount,
|
||||
const gs_audio_format* format);
|
||||
|
||||
/* leave these declarations private unless you plan on actually implementing and using them. */
|
||||
BSimpleGameSound();
|
||||
BSimpleGameSound& operator=(const BSimpleGameSound&);
|
||||
|
||||
@@ -1,67 +1,87 @@
|
||||
/*******************************************************************************
|
||||
/
|
||||
/ File: StreamingGameSound.h
|
||||
/
|
||||
/ Description: BStreamingGameSound is a class for all kinds of streaming
|
||||
/ (data not known beforehand) game sounds.
|
||||
/
|
||||
/ Copyright 1999, Be Incorporated, All Rights Reserved
|
||||
/
|
||||
*******************************************************************************/
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2002, OpenBeOS
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// File Name: StreamingGameSound.h
|
||||
// Author: Christopher ML Zumwalt May ([email protected])
|
||||
// Description: BStreamingGameSound is a class for all kinds of streaming
|
||||
// (data not known beforehand) game sounds.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
#if !defined(_STREAMING_GAME_SOUND_H)
|
||||
#define _STREAMING_GAME_SOUND_H
|
||||
#ifndef _STREAMINGGAMESOUND_H
|
||||
#define _STREAMINGGAMESOUND_H
|
||||
|
||||
// Standard Includes -----------------------------------------------------------
|
||||
|
||||
// System Includes -------------------------------------------------------------
|
||||
#include <SupportDefs.h>
|
||||
#include <GameSound.h>
|
||||
#include <Locker.h>
|
||||
|
||||
// Project Includes ------------------------------------------------------------
|
||||
|
||||
// Local Includes --------------------------------------------------------------
|
||||
|
||||
// Local Defines ---------------------------------------------------------------
|
||||
|
||||
// Globals ---------------------------------------------------------------------
|
||||
|
||||
class BStreamingGameSound : public BGameSound
|
||||
{
|
||||
public:
|
||||
BStreamingGameSound(
|
||||
size_t inBufferFrameCount,
|
||||
const gs_audio_format * format,
|
||||
size_t inBufferCount = 2,
|
||||
BGameSoundDevice * device = NULL);
|
||||
BStreamingGameSound(size_t inBufferFrameCount,
|
||||
const gs_audio_format * format,
|
||||
size_t inBufferCount = 2,
|
||||
BGameSoundDevice * device = NULL);
|
||||
|
||||
virtual ~BStreamingGameSound();
|
||||
virtual ~BStreamingGameSound();
|
||||
|
||||
virtual BGameSound * Clone() const;
|
||||
virtual BGameSound * Clone() const;
|
||||
|
||||
virtual status_t SetStreamHook(
|
||||
void (*hook)(void * inCookie, void * inBuffer, size_t inByteCount, BStreamingGameSound * me),
|
||||
void * cookie);
|
||||
virtual void FillBuffer( // default is to call stream hook, if any
|
||||
void * inBuffer,
|
||||
size_t inByteCount);
|
||||
virtual status_t SetStreamHook(void (*hook)(void * inCookie, void * inBuffer, size_t inByteCount, BStreamingGameSound * me),
|
||||
void * cookie);
|
||||
virtual void FillBuffer(void * inBuffer,
|
||||
size_t inByteCount);
|
||||
|
||||
virtual status_t SetAttributes(
|
||||
gs_attribute * inAttributes,
|
||||
size_t inAttributeCount);
|
||||
virtual status_t SetAttributes(gs_attribute * inAttributes,
|
||||
size_t inAttributeCount);
|
||||
|
||||
virtual status_t Perform(int32 selector, void * data);
|
||||
virtual status_t Perform(int32 selector, void * data);
|
||||
|
||||
protected:
|
||||
|
||||
BStreamingGameSound(
|
||||
BGameSoundDevice * device);
|
||||
virtual status_t SetParameters( // will allocate handle and call Init()
|
||||
size_t inBufferFrameCount,
|
||||
const gs_audio_format * format,
|
||||
size_t inBufferCount);
|
||||
|
||||
bool Lock();
|
||||
void Unlock();
|
||||
BStreamingGameSound(BGameSoundDevice * device);
|
||||
|
||||
virtual status_t SetParameters(size_t inBufferFrameCount,
|
||||
const gs_audio_format * format,
|
||||
size_t inBufferCount);
|
||||
|
||||
bool Lock();
|
||||
void Unlock();
|
||||
|
||||
private:
|
||||
|
||||
void (*_m_streamHook)(void * cookie, void * buffer, size_t bytes, BStreamingGameSound * sound);
|
||||
void * _m_streamCookie;
|
||||
BLocker _m_lock;
|
||||
|
||||
static void stream_callback(void * cookie, gs_id handle, void * buffer, int32 offset, int32 size, size_t bufSize);
|
||||
void (*fStreamHook)(void * cookie, void * buffer, size_t bytes, BStreamingGameSound * sound);
|
||||
void * fStreamCookie;
|
||||
BLocker fLock;
|
||||
|
||||
/* leave these declarations private unless you plan on actually implementing and using them. */
|
||||
BStreamingGameSound();
|
||||
|
||||
Reference in New Issue
Block a user