00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifdef WIN32
00016 #pragma warning (disable:4786)
00017 #endif
00018
00019 #include <API/Sound/soundbuffer_session.h>
00020 #include <API/Sound/sound.h>
00021 #include <Sound/Sound/Generic/cardsoundbuffer_playback.h>
00022 #include <Sound/Sound/Generic/soundcard_generic.h>
00023
00024 #include "cardsession_manager.h"
00025
00026 CL_CardSoundBuffer_Playback *cl_find_playback(CL_SoundCard *card, void *handle)
00027 {
00028 return ((CL_SoundCard_Generic *) card)->manager->get_playback(handle);
00029 }
00030
00031 CL_SoundBuffer_Session::CL_SoundBuffer_Session(void *handle, CL_SoundCard *card)
00032 {
00033 this->handle = handle;
00034 this->card = card;
00035 }
00036
00037 CL_SoundBuffer_Session::CL_SoundBuffer_Session(const CL_SoundBuffer_Session ©)
00038 {
00039 handle = copy.handle;
00040 card = copy.card;
00041
00042 ((CL_SoundCard_Generic *) card)->manager->add_reference(handle);
00043 }
00044
00045 CL_SoundBuffer_Session::~CL_SoundBuffer_Session()
00046 {
00047 if (handle != NULL)
00048 ((CL_SoundCard_Generic *) card)->manager->remove_reference(handle);
00049 }
00050
00051 CL_SoundBuffer_Session& CL_SoundBuffer_Session::operator =(const CL_SoundBuffer_Session &session)
00052 {
00053 if (handle != NULL)
00054 ((CL_SoundCard_Generic *) card)->manager->remove_reference(handle);
00055
00056 handle = session.handle;
00057 card = session.card;
00058
00059 ((CL_SoundCard_Generic *) card)->manager->add_reference(handle);
00060 return *this;
00061 }
00062
00063
00064
00065
00066
00067
00068 int CL_SoundBuffer_Session::get_position() const
00069 {
00070 return cl_find_playback(card, handle)->get_position();
00071 }
00072
00073 float CL_SoundBuffer_Session::get_position_relative() const
00074 {
00075 return cl_find_playback(card, handle)->get_position_relative();
00076 }
00077
00078 bool CL_SoundBuffer_Session::set_position(int new_pos)
00079 {
00080 return cl_find_playback(card, handle)->set_position(new_pos);
00081 }
00082
00083 bool CL_SoundBuffer_Session::set_position_relative(float new_pos)
00084 {
00085 return cl_find_playback(card, handle)->set_position_relative(new_pos);
00086 }
00087
00088 int CL_SoundBuffer_Session::get_length() const
00089 {
00090 return cl_find_playback(card, handle)->get_length();
00091 }
00092
00093 int CL_SoundBuffer_Session::get_frequency() const
00094 {
00095 return cl_find_playback(card, handle)->get_frequency();
00096 }
00097
00098 bool CL_SoundBuffer_Session::set_frequency(int new_freq)
00099 {
00100 return cl_find_playback(card, handle)->set_frequency(new_freq);
00101 }
00102
00103 float CL_SoundBuffer_Session::get_volume() const
00104 {
00105 return cl_find_playback(card, handle)->get_volume();
00106 }
00107
00108 bool CL_SoundBuffer_Session::set_volume(float new_volume)
00109 {
00110 return cl_find_playback(card, handle)->set_volume(new_volume);
00111 }
00112
00113 float CL_SoundBuffer_Session::get_pan() const
00114 {
00115 return cl_find_playback(card, handle)->get_pan();
00116 }
00117
00118 bool CL_SoundBuffer_Session::set_pan(float new_pan)
00119 {
00120 return cl_find_playback(card, handle)->set_pan(new_pan);
00121 }
00122
00123 void CL_SoundBuffer_Session::play()
00124 {
00125 cl_find_playback(card, handle)->play();
00126 }
00127
00128 void CL_SoundBuffer_Session::stop()
00129 {
00130 cl_find_playback(card, handle)->stop();
00131 }
00132
00133 bool CL_SoundBuffer_Session::is_playing()
00134 {
00135 return cl_find_playback(card, handle)->is_playing();
00136 }
00137
00138 void CL_SoundBuffer_Session::set_looping(bool loop)
00139 {
00140 cl_find_playback(card, handle)->set_looping(loop);
00141 }
00142
00143 void CL_SoundBuffer_Session::add_filter(class CL_SoundFilter *filter, bool delete_filter)
00144 {
00145 cl_find_playback(card, handle)->add_filter(filter, delete_filter);
00146 }
00147
00148 void CL_SoundBuffer_Session::remove_filter(class CL_SoundFilter *filter)
00149 {
00150 cl_find_playback(card, handle)->remove_filter(filter);
00151 }