00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00024
00026
00028 #include <SFML/Audio/SoundImpl.hpp>
00029 #include <SFML/Audio/SoundBuffer.hpp>
00030 #include <SFML/Audio/OpenAL.hpp>
00031
00032
00033 namespace sf_private
00034 {
00038 sfSoundImpl::sfSoundImpl(bool Loop, float Pitch, float Volume, float Position[3])
00039 {
00040 sfALCheck(alGenSources(1, &Source));
00041
00042 sfALCheck(alSourcei (Source, AL_LOOPING, Loop));
00043 sfALCheck(alSourcef (Source, AL_PITCH, Pitch));
00044 sfALCheck(alSourcef (Source, AL_GAIN, Volume * 0.01f));
00045 sfALCheck(alSourcefv(Source, AL_POSITION, Position));
00046 }
00047
00048
00052 sfSoundImpl::~sfSoundImpl()
00053 {
00054 DestroyAudioResources();
00055 }
00056
00057
00061 void sfSoundImpl::DestroyAudioResources()
00062 {
00063 if (Source)
00064 {
00065 sfALCheck(alSourcei(Source, AL_BUFFER, 0));
00066 sfALCheck(alDeleteSources(1, &Source));
00067 Source = 0;
00068 }
00069 }
00070
00071 }