mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-22 02:19:44 +00:00
fix audio streams cleanup
This commit is contained in:
parent
cb5bebf3ae
commit
1bb66ebf1f
1 changed files with 7 additions and 4 deletions
|
|
@ -349,7 +349,8 @@ void remove_lower_priority_speaker(int priority) {
|
||||||
for (auto it = speakers.begin(); it != speakers.end();) {
|
for (auto it = speakers.begin(); it != speakers.end();) {
|
||||||
if (it->second->getPriority() < priority && it->second->isPaused()) {
|
if (it->second->getPriority() < priority && it->second->isPaused()) {
|
||||||
it->second->stop();
|
it->second->stop();
|
||||||
it = speakers.erase(it);
|
streams.erase(it->first);
|
||||||
|
speakers.erase(it);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
it++;
|
it++;
|
||||||
|
|
@ -357,7 +358,8 @@ void remove_lower_priority_speaker(int priority) {
|
||||||
for (auto it = speakers.begin(); it != speakers.end();) {
|
for (auto it = speakers.begin(); it != speakers.end();) {
|
||||||
if (it->second->getPriority() < priority) {
|
if (it->second->getPriority() < priority) {
|
||||||
it->second->stop();
|
it->second->stop();
|
||||||
it = speakers.erase(it);
|
streams.erase(it->first);
|
||||||
|
speakers.erase(it);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
it++;
|
it++;
|
||||||
|
|
@ -445,6 +447,7 @@ speakerid_t audio::play_stream(
|
||||||
int channel
|
int channel
|
||||||
) {
|
) {
|
||||||
std::shared_ptr<Stream> stream(open_stream(file, false));
|
std::shared_ptr<Stream> stream(open_stream(file, false));
|
||||||
|
stream->setStopOnEnd(true);
|
||||||
return play(stream, position, relative, volume, pitch, loop, channel);
|
return play(stream, position, relative, volume, pitch, loop, channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -520,8 +523,8 @@ void audio::update(double delta) {
|
||||||
if (speaker->isStopped()) {
|
if (speaker->isStopped()) {
|
||||||
auto foundStream = streams.find(it->first);
|
auto foundStream = streams.find(it->first);
|
||||||
if (foundStream == streams.end() ||
|
if (foundStream == streams.end() ||
|
||||||
(!speaker->isManuallyStopped() &&
|
speaker->isManuallyStopped() ||
|
||||||
foundStream->second->isStopOnEnd())) {
|
foundStream->second->isStopOnEnd()) {
|
||||||
streams.erase(it->first);
|
streams.erase(it->first);
|
||||||
it = speakers.erase(it);
|
it = speakers.erase(it);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue