+}
+
+void SGSampleGroup::start_playing_sample(SGSoundSample *sample)
+{
+#ifdef ENABLE_SOUND
+ //
+ // a request to start playing a sound has been filed.
+ //
+ ALuint source = _smgr->request_source();
+ if (alIsSource(source) == AL_FALSE ) {
+ return;
+ }
+
+ sample->set_source( source );
+ update_sample_config( sample );
+ ALboolean looping = sample->is_looping() ? AL_TRUE : AL_FALSE;
+
+ if ( !sample->is_queue() )
+ {
+ ALuint buffer = _smgr->request_buffer(sample);
+ if (buffer == SGSoundMgr::FAILED_BUFFER ||
+ buffer == SGSoundMgr::NO_BUFFER)
+ {
+ _smgr->release_source(source);
+ return;
+ }
+
+ // start playing the sample
+ buffer = sample->get_buffer();
+ if ( alIsBuffer(buffer) == AL_TRUE )
+ {
+ alSourcei( source, AL_BUFFER, buffer );
+ testForALError("assign buffer to source");
+ } else
+ SG_LOG( SG_SOUND, SG_ALERT, "No such buffer!");
+ }
+
+ alSourcef( source, AL_ROLLOFF_FACTOR, 0.3 );
+ alSourcei( source, AL_LOOPING, looping );
+ alSourcei( source, AL_SOURCE_RELATIVE, AL_FALSE );
+ alSourcePlay( source );
+ testForALError("sample play");
+#endif
+}
+
+void SGSampleGroup::check_playing_sample(SGSoundSample *sample)
+{
+ // check if the sound has stopped by itself
+
+ if (is_sample_stopped(sample)) {
+ // sample is stopped because it wasn't looping
+ sample->stop();
+ sample->no_valid_source();
+ _smgr->release_source( sample->get_source() );
+ _smgr->release_buffer( sample );
+ remove( sample->get_sample_name() );
+ } else if ( sample->has_changed() ) {
+ if ( !sample->is_playing() ) {
+ // a request to stop playing the sound has been filed.
+ sample->stop();
+ sample->no_valid_source();
+ _smgr->release_source( sample->get_source() );
+ } else if ( _smgr->has_changed() ) {
+ update_sample_config( sample );
+ }
+ }
+}
+
+void SGSampleGroup::update( double dt ) {
+
+ if ( !_active || _pause ) return;
+
+ testForALError("start of update!!\n");