Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

CSSample Class Reference

#include <CSSample.h>


Public Member Functions

 CSSample (const CSSample &Sample)
virtual ~CSSample ()
virtual std::string getType ()
void play ()
void stop ()
void pause ()
void resume ()

Static Public Member Functions

void pauseAll ()
void resumeAll ()
void channel_finished (int channel)
void addCallback (int channel, CSSample *sample)
void removeCallback (int channel)
void init ()
void deinit ()
bool isPlaying ()

Static Public Attributes

const char * CLASS = "CSSample"


Constructor & Destructor Documentation

CSSample::CSSample const CSSample Sample  ) 
 

Definition at line 59 of file CSSample.cpp.

References LOG_ENTER, LOG_EXIT, and mSample.

00060 {
00061     static char *functionName="~CSSample";
00062     LOG_ENTER 
00063     mSample = sample.mSample;
00064     LOG_EXIT
00065 }

CSSample::~CSSample  )  [virtual]
 

Definition at line 35 of file CSSample.cpp.

References deinit(), LOG_ENTER, LOG_EXIT, and stop().

00036 {
00037     static char *functionName="~CSSample";
00038     LOG_ENTER 
00039     stop();
00040     if (mSample)
00041     {
00042         Mix_FreeChunk(mSample);
00043     }
00044     mSample = 0;
00045     deinit();
00046     LOG_EXIT
00047 }

Here is the call graph for this function:


Member Function Documentation

virtual std::string CSSample::getType  )  [inline, virtual]
 

Definition at line 71 of file CSSample.h.

References CLASS.

00071 {return (std::string) CLASS;}

void CSSample::play  ) 
 

Definition at line 67 of file CSSample.cpp.

References LOG_ENTER, LOG_EXIT, and stop().

00068 {
00069     static char *functionName="play";
00070     LOG_ENTER 
00071     stop();
00072     // CSA TODO: Uncomment to play samples!
00073     // mChannel = Mix_PlayChannel(-1,mSample, 0);
00074     // addCallback(mChannel, this);
00075     LOG_EXIT
00076 }

Here is the call graph for this function:

void CSSample::stop  ) 
 

Definition at line 78 of file CSSample.cpp.

References LOG_ENTER, LOG_EXIT, and removeCallback().

Referenced by play(), and ~CSSample().

00079 {
00080     static char *functionName="stop";
00081     LOG_ENTER 
00082     int frequency;
00083     Uint16 format;
00084     int channels;
00085     removeCallback(mChannel);
00086     int state = Mix_QuerySpec(&frequency, &format, &channels);
00087     if (state)
00088     {
00089         if (mChannel != -1)
00090         {
00091             Mix_HaltChannel(mChannel);
00092             mChannel = -1;
00093         }
00094     }
00095     LOG_EXIT
00096 }

Here is the call graph for this function:

void CSSample::pause  ) 
 

Definition at line 106 of file CSSample.cpp.

References LOG_ENTER, and LOG_EXIT.

00107 {
00108     static char *functionName="pause";
00109     LOG_ENTER 
00110     Mix_Pause(mChannel);
00111     LOG_EXIT
00112 }

void CSSample::resume  ) 
 

Definition at line 114 of file CSSample.cpp.

References LOG_ENTER, and LOG_EXIT.

00115 {
00116     static char *functionName="resume";
00117     LOG_ENTER 
00118     Mix_Resume(mChannel);
00119     LOG_EXIT
00120 }

void CSSample::pauseAll  )  [static]
 

Definition at line 122 of file CSSample.cpp.

References LOG_ENTER, and LOG_EXIT.

Referenced by CSGame::doPause().

00123 {
00124     static char *functionName="pauseAll";
00125     LOG_ENTER 
00126     while (mLock)
00127     {
00128         SDL_Delay(50);
00129     }
00130 
00131     mLock = true;
00132     for (CSSampleMap::iterator iter = mAllPlayingSamples->begin(); iter != mAllPlayingSamples->end(); iter++)
00133     {
00134         iter->second->pause();
00135     }
00136     mLock = false;
00137     LOG_EXIT
00138 }

void CSSample::resumeAll  )  [static]
 

Definition at line 140 of file CSSample.cpp.

References LOG_ENTER, and LOG_EXIT.

Referenced by CSGame::doPause().

00141 {
00142     static char *functionName="resumeAll";
00143     LOG_ENTER 
00144     while (mLock)
00145     {
00146         SDL_Delay(50);
00147     }
00148 
00149     mLock = true;
00150     for (CSSampleMap::iterator iter = mAllPlayingSamples->begin(); iter != mAllPlayingSamples->end(); iter++)
00151     {
00152         iter->second->resume();
00153     }
00154     mLock = false;
00155     LOG_EXIT
00156 }

void CSSample::channel_finished int  channel  )  [static]
 

Definition at line 158 of file CSSample.cpp.

References LOG_ENTER, LOG_EXIT, and removeCallback().

Referenced by init().

00159 {
00160     static char *functionName="channel_finished";
00161     LOG_ENTER 
00162     removeCallback(channel);
00163     LOG_EXIT
00164 }

Here is the call graph for this function:

void CSSample::addCallback int  channel,
CSSample sample
[static]
 

Definition at line 166 of file CSSample.cpp.

References LOG_ENTER, and LOG_EXIT.

00167 {
00168     static char *functionName="addCallback";
00169     LOG_ENTER 
00170     if (channel < 0)
00171     {
00172         LOG_EXIT
00173         return;
00174     }
00175     while (mLock)
00176     {
00177         SDL_Delay(50);
00178     }
00179 
00180     mLock = true;
00181     mAllPlayingSamples->insert(CSSampleMap::value_type(channel, sample));
00182     mLock = false;
00183     LOG_EXIT
00184 }

void CSSample::removeCallback int  channel  )  [static]
 

Definition at line 186 of file CSSample.cpp.

References LOG_ENTER, and LOG_EXIT.

Referenced by channel_finished(), and stop().

00187 {
00188     static char *functionName="removeCallback";
00189     LOG_ENTER 
00190     if (channel < 0)
00191     {
00192         LOG_EXIT
00193         return;
00194     }
00195 
00196     while (mLock)
00197     {
00198         SDL_Delay(50);
00199     }
00200 
00201     mLock = true;
00202     CSSampleMap::iterator iter;
00203     for (iter = mAllPlayingSamples->begin(); iter!=mAllPlayingSamples->end(); iter++)
00204     {
00205         if (iter->first == channel)
00206         {
00207             mAllPlayingSamples->erase(iter);
00208             break;
00209         }
00210     }
00211     mLock = false;
00212     LOG_EXIT
00213 }

void CSSample::init  )  [static]
 

Definition at line 215 of file CSSample.cpp.

References channel_finished(), CSSampleMap, LOG_ENTER, and LOG_EXIT.

00216 {
00217     static char *functionName="init";
00218     LOG_ENTER 
00219     if (mIsInit == 0)
00220     {
00221         mAllPlayingSamples = new CSSampleMap();
00222         Mix_ChannelFinished(CSSample::channel_finished);
00223     }
00224     mIsInit++;
00225     LOG_EXIT
00226 }

Here is the call graph for this function:

void CSSample::deinit  )  [static]
 

Definition at line 228 of file CSSample.cpp.

References LOG_ENTER, and LOG_EXIT.

Referenced by ~CSSample().

00229 {
00230     static char *functionName="deinit";
00231     LOG_ENTER 
00232     mIsInit--;
00233     if (mIsInit == 0)
00234     {
00235         mAllPlayingSamples->clear();
00236         delete (mAllPlayingSamples);
00237         mAllPlayingSamples = 0;
00238         Mix_ChannelFinished(0);
00239     }
00240     LOG_EXIT
00241 }

bool CSSample::isPlaying  )  [static]
 

Definition at line 243 of file CSSample.cpp.

References LOG_ENTER, and LOG_EXIT.

Referenced by CSGame::isSamplePlaying().

00244 {
00245     static char *functionName="isPlaying";
00246     LOG_ENTER 
00247     bool b= mAllPlayingSamples->size() > 0;
00248     LOG_EXIT
00249     return b;
00250 }


Field Documentation

const char * CSSample::CLASS = "CSSample" [static]
 

Definition at line 19 of file CSSample.cpp.

Referenced by getType().


Generated on Wed Jul 14 00:45:01 2004 for CSLib by doxygen 1.3.6