mirror of
https://github.com/TES3MP/TES3MP.git
synced 2025-09-27 15:11:36 -04:00
Keep track of audio tracks
This commit is contained in:
parent
2883cdba5c
commit
3a39a92b93
@ -474,6 +474,8 @@ namespace MWSound
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
track = mOutput->streamSound(decoder, volumeFromType(type), 1.0f, Play_NoEnv|type);
|
track = mOutput->streamSound(decoder, volumeFromType(type), 1.0f, Play_NoEnv|type);
|
||||||
|
TrackList::iterator iter = std::lower_bound(mActiveTracks.begin(), mActiveTracks.end(), track);
|
||||||
|
mActiveTracks.insert(iter, track);
|
||||||
}
|
}
|
||||||
catch(std::exception &e)
|
catch(std::exception &e)
|
||||||
{
|
{
|
||||||
@ -485,6 +487,9 @@ namespace MWSound
|
|||||||
void SoundManager::stopTrack(MWBase::SoundStreamPtr stream)
|
void SoundManager::stopTrack(MWBase::SoundStreamPtr stream)
|
||||||
{
|
{
|
||||||
mOutput->stopStream(stream);
|
mOutput->stopStream(stream);
|
||||||
|
TrackList::iterator iter = std::lower_bound(mActiveTracks.begin(), mActiveTracks.end(), stream);
|
||||||
|
if(iter != mActiveTracks.end() && *iter == stream)
|
||||||
|
mActiveTracks.erase(iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
double SoundManager::getTrackTimeDelay(MWBase::SoundStreamPtr stream)
|
double SoundManager::getTrackTimeDelay(MWBase::SoundStreamPtr stream)
|
||||||
@ -923,6 +928,24 @@ namespace MWSound
|
|||||||
++sayiter;
|
++sayiter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TrackList::iterator trkiter = mActiveTracks.begin();
|
||||||
|
for(;trkiter != mActiveTracks.end();++trkiter)
|
||||||
|
{
|
||||||
|
MWBase::SoundStreamPtr sound = *trkiter;
|
||||||
|
if(!mOutput->isStreamPlaying(sound))
|
||||||
|
{
|
||||||
|
mOutput->stopStream(sound);
|
||||||
|
trkiter = mActiveTracks.erase(trkiter);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sound->updateFade(duration);
|
||||||
|
|
||||||
|
mOutput->updateStream(sound);
|
||||||
|
++trkiter;
|
||||||
|
}
|
||||||
|
}
|
||||||
mOutput->finishUpdate();
|
mOutput->finishUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -970,6 +993,13 @@ namespace MWSound
|
|||||||
sound->setBaseVolume(volumeFromType(sound->getPlayType()));
|
sound->setBaseVolume(volumeFromType(sound->getPlayType()));
|
||||||
mOutput->updateStream(sound);
|
mOutput->updateStream(sound);
|
||||||
}
|
}
|
||||||
|
TrackList::iterator trkiter = mActiveTracks.begin();
|
||||||
|
for(;trkiter != mActiveTracks.end();++trkiter)
|
||||||
|
{
|
||||||
|
MWBase::SoundStreamPtr sound = *trkiter;
|
||||||
|
sound->setBaseVolume(volumeFromType(sound->getPlayType()));
|
||||||
|
mOutput->updateStream(sound);
|
||||||
|
}
|
||||||
if(mMusic)
|
if(mMusic)
|
||||||
{
|
{
|
||||||
mMusic->setBaseVolume(volumeFromType(mMusic->getPlayType()));
|
mMusic->setBaseVolume(volumeFromType(mMusic->getPlayType()));
|
||||||
@ -1099,6 +1129,10 @@ namespace MWSound
|
|||||||
for(;sayiter != mActiveSaySounds.end();++sayiter)
|
for(;sayiter != mActiveSaySounds.end();++sayiter)
|
||||||
mOutput->stopStream(sayiter->second.first);
|
mOutput->stopStream(sayiter->second.first);
|
||||||
mActiveSaySounds.clear();
|
mActiveSaySounds.clear();
|
||||||
|
TrackList::iterator trkiter = mActiveTracks.begin();
|
||||||
|
for(;trkiter != mActiveTracks.end();++trkiter)
|
||||||
|
mOutput->stopStream(*trkiter);
|
||||||
|
mActiveTracks.clear();
|
||||||
mPendingSaySounds.clear();
|
mPendingSaySounds.clear();
|
||||||
mUnderwaterSound.reset();
|
mUnderwaterSound.reset();
|
||||||
stopMusic();
|
stopMusic();
|
||||||
|
@ -79,9 +79,6 @@ namespace MWSound
|
|||||||
typedef std::deque<Sound_Buffer*> SoundList;
|
typedef std::deque<Sound_Buffer*> SoundList;
|
||||||
SoundList mUnusedBuffers;
|
SoundList mUnusedBuffers;
|
||||||
|
|
||||||
MWBase::SoundStreamPtr mMusic;
|
|
||||||
std::string mCurrentPlaylist;
|
|
||||||
|
|
||||||
typedef std::pair<MWBase::SoundPtr,Sound_Buffer*> SoundBufferRefPair;
|
typedef std::pair<MWBase::SoundPtr,Sound_Buffer*> SoundBufferRefPair;
|
||||||
typedef std::vector<SoundBufferRefPair> SoundBufferRefPairList;
|
typedef std::vector<SoundBufferRefPair> SoundBufferRefPairList;
|
||||||
typedef std::map<MWWorld::Ptr,SoundBufferRefPairList> SoundMap;
|
typedef std::map<MWWorld::Ptr,SoundBufferRefPairList> SoundMap;
|
||||||
@ -95,7 +92,11 @@ namespace MWSound
|
|||||||
typedef std::map<MWWorld::Ptr,DecoderLoudnessPair> SayDecoderMap;
|
typedef std::map<MWWorld::Ptr,DecoderLoudnessPair> SayDecoderMap;
|
||||||
SayDecoderMap mPendingSaySounds;
|
SayDecoderMap mPendingSaySounds;
|
||||||
|
|
||||||
MWBase::SoundPtr mUnderwaterSound;
|
typedef std::vector<MWBase::SoundStreamPtr> TrackList;
|
||||||
|
TrackList mActiveTracks;
|
||||||
|
|
||||||
|
MWBase::SoundStreamPtr mMusic;
|
||||||
|
std::string mCurrentPlaylist;
|
||||||
|
|
||||||
bool mListenerUnderwater;
|
bool mListenerUnderwater;
|
||||||
osg::Vec3f mListenerPos;
|
osg::Vec3f mListenerPos;
|
||||||
@ -104,6 +105,8 @@ namespace MWSound
|
|||||||
|
|
||||||
int mPausedSoundTypes;
|
int mPausedSoundTypes;
|
||||||
|
|
||||||
|
MWBase::SoundPtr mUnderwaterSound;
|
||||||
|
|
||||||
Sound_Buffer *insertSound(const std::string &soundId, const ESM::Sound *sound);
|
Sound_Buffer *insertSound(const std::string &soundId, const ESM::Sound *sound);
|
||||||
|
|
||||||
Sound_Buffer *lookupSound(const std::string &soundId) const;
|
Sound_Buffer *lookupSound(const std::string &soundId) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user