Updates to allow runtime chaning of the sound device
This commit is contained in:
@@ -261,6 +261,29 @@ SGSampleGroup::suspend ()
|
|||||||
testForALError("suspend");
|
testForALError("suspend");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SGSampleGroup::stop ()
|
||||||
|
{
|
||||||
|
_pause = true;
|
||||||
|
sample_map_iterator sample_current = _samples.begin();
|
||||||
|
sample_map_iterator sample_end = _samples.end();
|
||||||
|
for ( ; sample_current != sample_end; ++sample_current ) {
|
||||||
|
SGSoundSample *sample = sample_current->second;
|
||||||
|
|
||||||
|
if ( sample->is_valid_source() ) {
|
||||||
|
if ( sample->is_playing() ) {
|
||||||
|
alSourcePause( sample->get_source() );
|
||||||
|
}
|
||||||
|
_smgr->release_source( sample->get_source() );
|
||||||
|
sample->no_valid_source();
|
||||||
|
|
||||||
|
_smgr->release_buffer( sample );
|
||||||
|
sample->no_valid_buffer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
testForALError("suspend");
|
||||||
|
}
|
||||||
|
|
||||||
// resume playing all associated samples
|
// resume playing all associated samples
|
||||||
void
|
void
|
||||||
SGSampleGroup::resume ()
|
SGSampleGroup::resume ()
|
||||||
|
|||||||
@@ -128,6 +128,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
SGSoundSample *find( const string& refname );
|
SGSoundSample *find( const string& refname );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop all playing samples and set the source id to invalid.
|
||||||
|
*/
|
||||||
|
void stop();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request to stop playing all audio samples until further notice.
|
* Request to stop playing all audio samples until further notice.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -200,10 +200,18 @@ void SGSoundMgr::stop() {
|
|||||||
}
|
}
|
||||||
_buffers.clear();
|
_buffers.clear();
|
||||||
|
|
||||||
|
sample_group_map_iterator sample_grp_current = _sample_groups.begin();
|
||||||
|
sample_group_map_iterator sample_grp_end = _sample_groups.end();
|
||||||
|
for ( ; sample_grp_current != sample_grp_end; ++sample_grp_current ) {
|
||||||
|
SGSampleGroup *sgrp = sample_grp_current->second;
|
||||||
|
sgrp->stop();
|
||||||
|
}
|
||||||
|
|
||||||
_context = alcGetCurrentContext();
|
_context = alcGetCurrentContext();
|
||||||
_device = alcGetContextsDevice(_context);
|
_device = alcGetContextsDevice(_context);
|
||||||
alcDestroyContext(_context);
|
alcDestroyContext(_context);
|
||||||
alcCloseDevice(_device);
|
alcCloseDevice(_device);
|
||||||
|
_context = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,7 +221,7 @@ void SGSoundMgr::suspend() {
|
|||||||
sample_group_map_iterator sample_grp_end = _sample_groups.end();
|
sample_group_map_iterator sample_grp_end = _sample_groups.end();
|
||||||
for ( ; sample_grp_current != sample_grp_end; ++sample_grp_current ) {
|
for ( ; sample_grp_current != sample_grp_end; ++sample_grp_current ) {
|
||||||
SGSampleGroup *sgrp = sample_grp_current->second;
|
SGSampleGroup *sgrp = sample_grp_current->second;
|
||||||
sgrp->suspend();
|
sgrp->stop();
|
||||||
}
|
}
|
||||||
_active = false;
|
_active = false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user