GNAP: rename SoundItem members

This commit is contained in:
Strangerke 2016-03-19 01:25:07 +01:00 committed by Eugene Sandulenko
parent d546847b5a
commit 6b1a2f3649
2 changed files with 13 additions and 12 deletions

View file

@ -35,13 +35,13 @@ SoundMan::~SoundMan() {
void SoundMan::playSound(int resourceId, bool looping) { void SoundMan::playSound(int resourceId, bool looping) {
SoundItem soundItem; SoundItem soundItem;
soundItem.resourceId = resourceId; soundItem._resourceId = resourceId;
SoundResource *soundResource = _vm->_soundCache->get(resourceId); SoundResource *soundResource = _vm->_soundCache->get(resourceId);
Common::MemoryReadStream *stream = new Common::MemoryReadStream(soundResource->_data, soundResource->_size, DisposeAfterUse::NO); Common::MemoryReadStream *stream = new Common::MemoryReadStream(soundResource->_data, soundResource->_size, DisposeAfterUse::NO);
Audio::AudioStream *audioStream = Audio::makeLoopingAudioStream(Audio::makeWAVStream(stream, DisposeAfterUse::YES), looping ? 0 : 1); Audio::AudioStream *audioStream = Audio::makeLoopingAudioStream(Audio::makeWAVStream(stream, DisposeAfterUse::YES), looping ? 0 : 1);
_vm->_mixer->playStream(Audio::Mixer::kPlainSoundType, &soundItem.handle, audioStream); _vm->_mixer->playStream(Audio::Mixer::kPlainSoundType, &soundItem._handle, audioStream);
_items.push_back(soundItem); _items.push_back(soundItem);
@ -50,8 +50,8 @@ void SoundMan::playSound(int resourceId, bool looping) {
void SoundMan::stopSound(int resourceId) { void SoundMan::stopSound(int resourceId) {
const int index = find(resourceId); const int index = find(resourceId);
if (index >= 0) { if (index >= 0) {
_vm->_soundCache->release(_items[index].resourceId); _vm->_soundCache->release(_items[index]._resourceId);
_vm->_mixer->stopHandle(_items[index].handle); _vm->_mixer->stopHandle(_items[index]._handle);
_items.remove_at(index); _items.remove_at(index);
} }
} }
@ -62,20 +62,20 @@ void SoundMan::setSoundVolume(int resourceId, int volume) {
bool SoundMan::isSoundPlaying(int resourceId) { bool SoundMan::isSoundPlaying(int resourceId) {
const int index = find(resourceId); const int index = find(resourceId);
return index >= 0 && _vm->_mixer->isSoundHandleActive(_items[index].handle); return index >= 0 && _vm->_mixer->isSoundHandleActive(_items[index]._handle);
} }
void SoundMan::stopAll() { void SoundMan::stopAll() {
for (int index = 0; index < (int)_items.size(); ++index) { for (int index = 0; index < (int)_items.size(); ++index) {
_vm->_soundCache->release(_items[index].resourceId); _vm->_soundCache->release(_items[index]._resourceId);
_vm->_mixer->stopHandle(_items[index].handle); _vm->_mixer->stopHandle(_items[index]._handle);
} }
} }
void SoundMan::update() { void SoundMan::update() {
for (int index = 0; index < (int)_items.size(); ++index) for (int index = 0; index < (int)_items.size(); ++index)
if (!_vm->_mixer->isSoundHandleActive(_items[index].handle)) { if (!_vm->_mixer->isSoundHandleActive(_items[index]._handle)) {
_vm->_soundCache->release(_items[index].resourceId); _vm->_soundCache->release(_items[index]._resourceId);
_items.remove_at(index); _items.remove_at(index);
--index; --index;
} }
@ -83,7 +83,7 @@ void SoundMan::update() {
int SoundMan::find(int resourceId) { int SoundMan::find(int resourceId) {
for (int index = 0; index < (int)_items.size(); ++index) for (int index = 0; index < (int)_items.size(); ++index)
if (_items[index].resourceId == resourceId) if (_items[index]._resourceId == resourceId)
return index; return index;
return -1; return -1;
} }

View file

@ -31,8 +31,8 @@
namespace Gnap { namespace Gnap {
struct SoundItem { struct SoundItem {
int resourceId; int _resourceId;
Audio::SoundHandle handle; Audio::SoundHandle _handle;
}; };
class SoundMan { class SoundMan {
@ -48,6 +48,7 @@ public:
protected: protected:
GnapEngine *_vm; GnapEngine *_vm;
Common::Array<SoundItem> _items; Common::Array<SoundItem> _items;
int find(int resourceId); int find(int resourceId);
}; };