Platform_Win32_Sound_WMM.cpp
Go to the documentation of this file.00001 //*** Platform_Win32_Sound_WMM.cpp *** 00002 00003 00004 #pragma warning( disable: 4201) 00005 #define WIN32_LEAN_AND_MEAN 00006 #define VC_EXTRALEAN 00007 #include <windows.h> 00008 #include <mmsystem.h> 00009 #include <malloc.h> 00010 00011 #include "Platform_Win32_Sound_WMM.h" 00012 #include "Platform_Win32_Sound_SoundStream_WMM.h" 00013 00014 00015 #pragma comment (lib, "winmm.lib") 00016 00017 00018 //*** Constructor *** 00019 00020 Platform_Win32_Sound_WMM::Platform_Win32_Sound_WMM(): 00021 soundStreamCount_(0), 00022 soundStreamMaxCount_(0), 00023 soundStreams_(0) 00024 { 00025 } 00026 00027 00028 //*** Setup *** 00029 00030 bool Platform_Win32_Sound_WMM::Setup() 00031 { 00032 return true; 00033 } 00034 00035 00036 //*** Destructor *** 00037 00038 Platform_Win32_Sound_WMM::~Platform_Win32_Sound_WMM() 00039 { 00040 if (soundStreams_) 00041 { 00042 for (int i=0; i<soundStreamCount_; i++) 00043 { 00044 delete soundStreams_[i]; 00045 } 00046 free(soundStreams_); 00047 } 00048 } 00049 00050 00051 //*** Update *** 00052 00053 void Platform_Win32_Sound_WMM::Update() 00054 { 00055 for (int i=0; i<soundStreamCount_; i++) 00056 { 00057 soundStreams_[i]->Update(); 00058 } 00059 } 00060 00061 00062 //*** CreateSoundStream *** 00063 00064 Platform_Sound_SoundStream* Platform_Win32_Sound_WMM::CreateSoundStream(int channels, int frequency, int bitsPerSample, int size) 00065 { 00066 Platform_Win32_Sound_SoundStream_WMM* soundStream=new Platform_Win32_Sound_SoundStream_WMM(this,channels,frequency,bitsPerSample,size); 00067 00068 if (!soundStreams_) 00069 { 00070 soundStreamMaxCount_=64; 00071 soundStreams_=static_cast<Platform_Win32_Sound_SoundStream_WMM**>(malloc(soundStreamMaxCount_*sizeof(Platform_Win32_Sound_SoundStream_WMM*))); 00072 } 00073 else if (soundStreamCount_>=soundStreamMaxCount_) 00074 { 00075 soundStreamMaxCount_*=2; 00076 soundStreams_=static_cast<Platform_Win32_Sound_SoundStream_WMM**>(realloc(soundStreams_,soundStreamMaxCount_*sizeof(Platform_Win32_Sound_SoundStream_WMM*))); 00077 } 00078 00079 soundStreams_[soundStreamCount_]=soundStream; 00080 soundStreamCount_++; 00081 00082 return soundStream; 00083 } 00084 00085 00086 00087 //*** SoundStreamDestroyed *** 00088 00089 void Platform_Win32_Sound_WMM::SoundStreamDestroyed(Platform_Win32_Sound_SoundStream_WMM* stream) 00090 { 00091 for (int i=0; i<soundStreamCount_; i++) 00092 { 00093 if (soundStreams_[i]==stream) 00094 { 00095 soundStreams_[i]=soundStreams_[soundStreamCount_-1]; 00096 soundStreamCount_--; 00097 return; 00098 } 00099 } 00100 }
Reproduction/republishing of any material on this site without permission is strictly prohibited.
