@@ -33,7 +33,7 @@ SoundInstance::SoundInstance(Sound* sound):
3333 if (_audio->CheckErrors ().has_value ()) throw Logging::Exception (" Failed to assign buffer to source!" );
3434}
3535
36- const AudioSource& SoundInstance::GetSource ()
36+ const AudioSource& SoundInstance::GetSource () noexcept
3737{
3838 alGetSourcef (_sourceID, AL_PITCH , &_source.Pitch );
3939 alGetSourcef (_sourceID, AL_GAIN , &_source.Gain );
@@ -121,10 +121,10 @@ void SoundInstance::SetSource(const AudioSource& source)
121121 auto looping = _source.Looping ? AL_TRUE : AL_FALSE ;
122122 alSourcei (_sourceID, AL_LOOPING , looping);
123123
124- if (_audio->CheckErrors ().has_value ()) throw int ( 5 );
124+ if (_audio->CheckErrors ().has_value ()) throw Logging::Exception ( " Error setting source properties " );
125125}
126126
127- SoundState SoundInstance::GetState ()
127+ SoundState SoundInstance::GetState () const noexcept
128128{
129129 int sourceState;
130130 alGetSourcei (_sourceID, AL_SOURCE_STATE , &sourceState);
@@ -146,26 +146,21 @@ SoundState SoundInstance::GetState()
146146 }
147147}
148148
149- void SoundInstance::Play ()
149+ void SoundInstance::Play (bool dontOverlap) const noexcept
150150{
151- // if(GetState() == SoundState::Playing) return; //do not overlap the same sound instance
152- // alGetError();
151+ if (GetState () == SoundState::Playing && dontOverlap) return ;
153152
154153 alSourcePlay (_sourceID);
155-
156- if (_audio->CheckErrors ().has_value ()) throw int (5 );
157154}
158155
159- void Engine3DRadSpace::Audio::SoundInstance::Stop ()
156+ void Engine3DRadSpace::Audio::SoundInstance::Stop () const noexcept
160157{
161158 alSourceStop (_sourceID);
162- if (_audio->CheckErrors ().has_value ()) throw float (5 );
163159}
164160
165- void Engine3DRadSpace::Audio::SoundInstance::Pause ()
161+ void Engine3DRadSpace::Audio::SoundInstance::Pause () const noexcept
166162{
167163 alSourcePause (_sourceID);
168- if (_audio->CheckErrors ().has_value ()) throw float (6 );
169164}
170165
171166SoundInstance::~SoundInstance ()
0 commit comments