00001 /* 00002 $Id: soundcard_clan.cpp,v 1.1 2001/03/06 15:09:26 mbn Exp $ 00003 00004 ------------------------------------------------------------------------ 00005 ClanLib, the platform independent game SDK. 00006 00007 This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE 00008 version 2. See COPYING for details. 00009 00010 For a total list of contributers see CREDITS. 00011 00012 ------------------------------------------------------------------------ 00013 */ 00014 00015 #ifdef WIN32 00016 #pragma warning (disable:4786) 00017 #endif 00018 00019 #ifdef USE_CLANSOUND 00020 00021 #include <API/Core/System/mutex.h> 00022 #include <API/Sound/static_soundprovider.h> 00023 #include <API/Sound/stream_soundprovider.h> 00024 #include <API/Core/System/thread.h> 00025 #include "API/Core/System/cl_assert.h" 00026 #include <Sound/Sound/Generic/cardsoundbuffer_playback.h> 00027 #include <Sound/Sound/Generic/cardsoundbuffer_static.h> 00028 #include <Sound/Sound/Generic/soundbuffer_stream.h> 00029 #include <Sound/Sound/Generic/soundbuffer_generic.h> 00030 #include <Sound/Sound/ClanSound/soundcard_clan.h> 00031 #include <Sound/Sound/ClanSound/soundbuffer_static_clan.h> 00032 #include <Sound/Sound/ClanSound/cardplayback_clan.h> 00033 #include <Sound/Sound/ClanSound/playback_stream.h> 00034 00035 CL_SoundCard_ClanSound::CL_SoundCard_ClanSound() 00036 { 00037 name = "Unix sound card"; 00038 card_no = 0; 00039 00040 mutex = CL_Mutex::create(); 00041 00042 exit_thread = false; 00043 thread = CL_Thread::create(this); 00044 thread->start(); 00045 } 00046 00047 CL_SoundCard_ClanSound::~CL_SoundCard_ClanSound() 00048 { 00049 mutex->enter(); 00050 exit_thread = true; 00051 mutex->leave(); 00052 thread->wait(); 00053 delete thread; 00054 00055 delete mutex; 00056 mutex = NULL; 00057 } 00058 00059 // Functions inherited from API: 00060 // ----------------------------- 00061 00062 CL_StreamSoundProvider *CL_SoundCard_ClanSound::get_microphone() 00063 { 00064 return NULL; 00065 } 00066 00067 CL_StreamSoundProvider *CL_SoundCard_ClanSound::get_line_in() 00068 { 00069 return NULL; 00070 } 00071 00072 void CL_SoundCard_ClanSound::stop_all() 00073 { 00074 // we need a generic strategy for this 00075 } 00076 00077 void CL_SoundCard_ClanSound::set_global_volume(int /*volume*/) 00078 { 00079 // and this one... 00080 } 00081 00082 void CL_SoundCard_ClanSound::set_global_pan(int /*pan*/) 00083 { 00084 // and this... 00085 } 00086 00087 // Functions inherited from Generic: 00088 // --------------------------------- 00089 00090 CL_CardSoundBuffer_Static *CL_SoundCard_ClanSound::create_soundbuffer_static( 00091 CL_SoundBuffer_Generic *owner, 00092 CL_StaticSoundProvider *provider) 00093 { 00094 return new CL_CardBuffer_Static_ClanSound(this, provider, owner); 00095 } 00096 00097 CL_CardSoundBuffer_Playback *CL_SoundCard_ClanSound::create_cardsoundbuffer_playback_streamed( 00098 CL_SoundBuffer_Generic_Stream *provider) 00099 { 00100 return new CL_Playback_Stream( 00101 this, 00102 provider->get_stream_provider(), 00103 provider); 00104 } 00105 00106 // Functions exported to CL_CardSoundBuffer_Playback: 00107 // -------------------------------------------------- 00108 00109 void CL_SoundCard_ClanSound::add(CL_CardPlayback_ClanSound *playback) 00110 { 00111 if (mutex == NULL) return; 00112 00113 mutex->enter(); 00114 mixer.add(playback); 00115 mutex->leave(); 00116 } 00117 00118 void CL_SoundCard_ClanSound::remove(CL_CardPlayback_ClanSound *playback) 00119 { 00120 if (mutex == NULL) return; 00121 00122 mutex->enter(); 00123 mixer.remove(playback); 00124 mutex->leave(); 00125 } 00126 00127 CL_Mutex *CL_SoundCard_ClanSound::get_mutex() 00128 { 00129 cl_assert(mutex != NULL); 00130 return mutex; 00131 } 00132 00133 // Private functions: 00134 // ------------------ 00135 00136 void CL_SoundCard_ClanSound::run() 00137 { 00138 while (true) 00139 { 00140 mixer.wait(); 00141 00142 if (exit_thread) break; 00143 mixer.mix(mutex); 00144 } 00145 } 00146 00147 #endif
1.2.6 written by Dimitri van Heesch,
© 1997-2001