Changed: Provide a fake sound name for fake CSound created by music channel
This commit is contained in:
parent
444becf71d
commit
beae63c1a0
2 changed files with 19 additions and 1 deletions
|
@ -54,6 +54,8 @@ CSourceMusicChannel::~CSourceMusicChannel()
|
||||||
|
|
||||||
bool CSourceMusicChannel::play(const std::string &filepath, bool async, bool loop)
|
bool CSourceMusicChannel::play(const std::string &filepath, bool async, bool loop)
|
||||||
{
|
{
|
||||||
|
// delete previous source if any
|
||||||
|
// note that this waits for the source's thread to finish if the source was still playing
|
||||||
if (m_Source)
|
if (m_Source)
|
||||||
delete m_Source;
|
delete m_Source;
|
||||||
|
|
||||||
|
@ -71,12 +73,14 @@ bool CSourceMusicChannel::play(const std::string &filepath, bool async, bool loo
|
||||||
|
|
||||||
void CSourceMusicChannel::stop()
|
void CSourceMusicChannel::stop()
|
||||||
{
|
{
|
||||||
|
// stop but don't delete the source, deleting source may cause waiting for thread
|
||||||
if (m_Source)
|
if (m_Source)
|
||||||
m_Source->stop();
|
m_Source->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSourceMusicChannel::reset()
|
void CSourceMusicChannel::reset()
|
||||||
{
|
{
|
||||||
|
// forces the source to be deleted, happens when audio mixer is reset
|
||||||
delete m_Source;
|
delete m_Source;
|
||||||
m_Source = NULL;
|
m_Source = NULL;
|
||||||
}
|
}
|
||||||
|
@ -96,7 +100,16 @@ void CSourceMusicChannel::resume()
|
||||||
bool CSourceMusicChannel::isEnded()
|
bool CSourceMusicChannel::isEnded()
|
||||||
{
|
{
|
||||||
if (m_Source)
|
if (m_Source)
|
||||||
return m_Source->isEnded();
|
{
|
||||||
|
if (m_Source->isEnded())
|
||||||
|
{
|
||||||
|
// we can delete the source now without worrying about thread wait
|
||||||
|
delete m_Source;
|
||||||
|
m_Source = NULL;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,11 @@ void CStreamFileSound::serial(NLMISC::IStream &s)
|
||||||
|
|
||||||
void CStreamFileSound::setMusicFilePath(const std::string &filePath, bool async, bool loop)
|
void CStreamFileSound::setMusicFilePath(const std::string &filePath, bool async, bool loop)
|
||||||
{
|
{
|
||||||
|
#if !FINAL_VERSION
|
||||||
|
_Name = NLMISC::CStringMapper::map(std::string("<MusicChannel:") + NLMISC::CFile::getFilenameWithoutExtension(filePath) + ">");
|
||||||
|
#else
|
||||||
|
_Name = NLMISC::CStringMapper::map("<MusicChannel>");
|
||||||
|
#endif
|
||||||
_ConeInnerAngle = NLMISC::Pi * 2;
|
_ConeInnerAngle = NLMISC::Pi * 2;
|
||||||
_ConeOuterAngle = NLMISC::Pi * 2;
|
_ConeOuterAngle = NLMISC::Pi * 2;
|
||||||
_Looping = loop;
|
_Looping = loop;
|
||||||
|
|
Loading…
Reference in a new issue