Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

SpeakerServer Class Reference

#include <SpeakerServer.h>

Inheritance diagram for SpeakerServer:

List of all members.


Detailed Description

Plays streamed audio via the speaker.

Definition at line 9 of file SpeakerServer.h.


Public Member Functions

virtual ~SpeakerServer ()
 destructor
virtual void DoStart ()
 By default, merely adds to the reference counter (through AddReference()); Note you should still call this from your overriding methods.
virtual void DoStop ()
 By default, subtracts from the reference counter (RemoveReference()), and thus may deletex if zero; Don't forget to still call this when you override this; Warning: call this at the end of your DoStop(), not beginning (it might delete this ).

Static Public Member Functions

static SpeakerServergetInstance ()
 returns global instance
static int socket_callback (char *buf, int size)
 registered by DoStart() to be called by networking module with incoming data

Private Member Functions

 SpeakerServer ()
 constructor
 SpeakerServer (const SpeakerServer &rhs)
 don't call
SpeakerServeroperator= (const SpeakerServer &rhs)
 don't call
int GotSocketData (char *data, int dataSize)
 should be called with new sound data from the network
void AddPacket (const void *samples, int samplesSize, int sampleRate, byte sampleBits)
const void * ResampleForSpeaker (const void *samples, int samplesSize, int sampleRate, byte bitsPerSample, int &newSamplesSize)
void QueueFrame (const char *samples, int samplesSize)

Static Private Member Functions

static short GetShort (const void *buf)
 returns the next sizeof(short) bytes from buf as a short

Private Attributes

class Socketsocket
Packet packet
class Bufferframe
class Bufferresampled
SoundManager::Play_ID channel

Static Private Attributes

static SpeakerServerinstance = 0
 global instance of the server (only ever want to have one of these)
static const int MAX_PACKET_SIZE = 1024 * 1024
 maximum size of sound buffer to send to system
static const int RECEIVE_BUFFER_SIZE = 2048
 maximum network packet size to accept

Classes

class  Packet
 stores information about current sound buffer More...

Constructor & Destructor Documentation

SpeakerServer::~SpeakerServer (  )  [virtual]

destructor

Definition at line 25 of file SpeakerServer.cc.

SpeakerServer::SpeakerServer (  )  [private]

constructor

Definition at line 17 of file SpeakerServer.cc.

Referenced by getInstance().

SpeakerServer::SpeakerServer ( const SpeakerServer rhs  )  [private]

don't call


Member Function Documentation

SpeakerServer & SpeakerServer::getInstance (  )  [static]

returns global instance

Definition at line 10 of file SpeakerServer.cc.

void SpeakerServer::DoStart (  )  [virtual]

By default, merely adds to the reference counter (through AddReference()); Note you should still call this from your overriding methods.

Reimplemented from BehaviorBase.

Definition at line 35 of file SpeakerServer.cc.

void SpeakerServer::DoStop (  )  [virtual]

By default, subtracts from the reference counter (RemoveReference()), and thus may deletex if zero; Don't forget to still call this when you override this; Warning: call this at the end of your DoStop(), not beginning (it might delete this ).

Reimplemented from BehaviorBase.

Definition at line 54 of file SpeakerServer.cc.

int SpeakerServer::socket_callback ( char *  buf,
int  size 
) [static]

registered by DoStart() to be called by networking module with incoming data

Definition at line 72 of file SpeakerServer.cc.

Referenced by DoStart().

SpeakerServer& SpeakerServer::operator= ( const SpeakerServer rhs  )  [private]

don't call

int SpeakerServer::GotSocketData ( char *  data,
int  dataSize 
) [private]

should be called with new sound data from the network

Definition at line 91 of file SpeakerServer.cc.

Referenced by socket_callback().

static short SpeakerServer::GetShort ( const void *  buf  )  [inline, static, private]

returns the next sizeof(short) bytes from buf as a short

Definition at line 29 of file SpeakerServer.h.

Referenced by GotSocketData().

void SpeakerServer::AddPacket ( const void *  samples,
int  samplesSize,
int  sampleRate,
byte  sampleBits 
) [private]

Definition at line 165 of file SpeakerServer.cc.

Referenced by GotSocketData().

const void * SpeakerServer::ResampleForSpeaker ( const void *  samples,
int  samplesSize,
int  sampleRate,
byte  bitsPerSample,
int &  newSamplesSize 
) [private]

Definition at line 241 of file SpeakerServer.cc.

Referenced by AddPacket().

void SpeakerServer::QueueFrame ( const char *  samples,
int  samplesSize 
) [private]

Definition at line 217 of file SpeakerServer.cc.

Referenced by AddPacket().


Member Data Documentation

SpeakerServer * SpeakerServer::instance = 0 [static, private]

global instance of the server (only ever want to have one of these)

Definition at line 24 of file SpeakerServer.h.

Referenced by getInstance(), socket_callback(), and ~SpeakerServer().

class Socket* SpeakerServer::socket [private]

network communications socket for receiving sound data

Definition at line 27 of file SpeakerServer.h.

Referenced by DoStart(), and DoStop().

const int SpeakerServer::MAX_PACKET_SIZE = 1024 * 1024 [static, private]

maximum size of sound buffer to send to system

Definition at line 31 of file SpeakerServer.h.

Referenced by GotSocketData().

const int SpeakerServer::RECEIVE_BUFFER_SIZE = 2048 [static, private]

maximum network packet size to accept

Definition at line 32 of file SpeakerServer.h.

Referenced by DoStart().

Definition at line 56 of file SpeakerServer.h.

Referenced by DoStart(), DoStop(), and GotSocketData().

class Buffer* SpeakerServer::frame [private]

Definition at line 57 of file SpeakerServer.h.

Referenced by AddPacket(), DoStop(), and ~SpeakerServer().

class Buffer* SpeakerServer::resampled [private]

Definition at line 58 of file SpeakerServer.h.

Referenced by DoStop(), ResampleForSpeaker(), and ~SpeakerServer().

Definition at line 74 of file SpeakerServer.h.

Referenced by DoStart(), DoStop(), and QueueFrame().


The documentation for this class was generated from the following files:

Tekkotsu v4.0
Generated Thu Nov 22 00:58:42 2007 by Doxygen 1.5.4