add SOUND->PlayOnceFromAnnouncer(); this is now the preferred
way to play an announcer. Announcer files are in many separate directories; scanning a directory can cause a skip, so we don't want to do that in the main thread during gameplay.
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
#include "NotesLoaderSM.h"
|
#include "NotesLoaderSM.h"
|
||||||
#include "PrefsManager.h"
|
#include "PrefsManager.h"
|
||||||
#include "RageDisplay.h"
|
#include "RageDisplay.h"
|
||||||
|
#include "AnnouncerManager.h"
|
||||||
|
|
||||||
RageSounds *SOUND = NULL;
|
RageSounds *SOUND = NULL;
|
||||||
|
|
||||||
@@ -64,6 +65,7 @@ static RageThread MusicThread;
|
|||||||
#include "RageUtil_CircularBuffer.h"
|
#include "RageUtil_CircularBuffer.h"
|
||||||
CircBuf<CString *> g_SoundsToPlayOnce;
|
CircBuf<CString *> g_SoundsToPlayOnce;
|
||||||
CircBuf<CString *> g_SoundsToPlayOnceFromDir;
|
CircBuf<CString *> g_SoundsToPlayOnceFromDir;
|
||||||
|
CircBuf<CString *> g_SoundsToPlayOnceFromAnnouncer;
|
||||||
|
|
||||||
struct MusicToPlay
|
struct MusicToPlay
|
||||||
{
|
{
|
||||||
@@ -199,21 +201,11 @@ static void StartMusic( MusicToPlay &ToPlay )
|
|||||||
g_Playing = NewMusic;
|
g_Playing = NewMusic;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void StartQueuedSounds()
|
static void DoPlayOnceFromDir( CString sPath )
|
||||||
{
|
{
|
||||||
CString *p;
|
if( sPath == "" )
|
||||||
while( g_SoundsToPlayOnce.read( &p, 1 ) )
|
return;
|
||||||
{
|
|
||||||
if( *p != "" )
|
|
||||||
SOUNDMAN->PlayOnce( *p );
|
|
||||||
delete p;
|
|
||||||
}
|
|
||||||
|
|
||||||
while( g_SoundsToPlayOnceFromDir.read( &p, 1 ) )
|
|
||||||
{
|
|
||||||
CString sPath( *p );
|
|
||||||
if( sPath != "" )
|
|
||||||
{
|
|
||||||
// make sure there's a slash at the end of this path
|
// make sure there's a slash at the end of this path
|
||||||
if( sPath.Right(1) != "/" )
|
if( sPath.Right(1) != "/" )
|
||||||
sPath += "/";
|
sPath += "/";
|
||||||
@@ -230,6 +222,29 @@ static void StartQueuedSounds()
|
|||||||
SOUNDMAN->PlayOnce( sPath + arraySoundFiles[index] );
|
SOUNDMAN->PlayOnce( sPath + arraySoundFiles[index] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void StartQueuedSounds()
|
||||||
|
{
|
||||||
|
CString *p;
|
||||||
|
while( g_SoundsToPlayOnce.read( &p, 1 ) )
|
||||||
|
{
|
||||||
|
if( *p != "" )
|
||||||
|
SOUNDMAN->PlayOnce( *p );
|
||||||
|
delete p;
|
||||||
|
}
|
||||||
|
|
||||||
|
while( g_SoundsToPlayOnceFromDir.read( &p, 1 ) )
|
||||||
|
{
|
||||||
|
CString sPath( *p );
|
||||||
|
DoPlayOnceFromDir( sPath );
|
||||||
|
delete p;
|
||||||
|
}
|
||||||
|
|
||||||
|
while( g_SoundsToPlayOnceFromAnnouncer.read( &p, 1 ) )
|
||||||
|
{
|
||||||
|
CString sPath( *p );
|
||||||
|
if( sPath != "" )
|
||||||
|
sPath = ANNOUNCER->GetPathTo( sPath );
|
||||||
|
DoPlayOnceFromDir( sPath );
|
||||||
delete p;
|
delete p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,6 +279,7 @@ RageSounds::RageSounds()
|
|||||||
|
|
||||||
g_SoundsToPlayOnce.reserve( 16 );
|
g_SoundsToPlayOnce.reserve( 16 );
|
||||||
g_SoundsToPlayOnceFromDir.reserve( 16 );
|
g_SoundsToPlayOnceFromDir.reserve( 16 );
|
||||||
|
g_SoundsToPlayOnceFromAnnouncer.reserve( 16 );
|
||||||
g_MusicsToPlay.reserve( 16 );
|
g_MusicsToPlay.reserve( 16 );
|
||||||
|
|
||||||
g_Mutex = new RageMutex("RageSounds");
|
g_Mutex = new RageMutex("RageSounds");
|
||||||
@@ -300,6 +316,9 @@ RageSounds::~RageSounds()
|
|||||||
while( g_SoundsToPlayOnceFromDir.read( &p, 1 ) )
|
while( g_SoundsToPlayOnceFromDir.read( &p, 1 ) )
|
||||||
delete p;
|
delete p;
|
||||||
|
|
||||||
|
while( g_SoundsToPlayOnceFromAnnouncer.read( &p, 1 ) )
|
||||||
|
delete p;
|
||||||
|
|
||||||
MusicToPlay *pMusic;
|
MusicToPlay *pMusic;
|
||||||
while( g_MusicsToPlay.read( &pMusic, 1 ) )
|
while( g_MusicsToPlay.read( &pMusic, 1 ) )
|
||||||
delete pMusic;
|
delete pMusic;
|
||||||
@@ -465,6 +484,17 @@ void RageSounds::PlayOnceFromDir( CString PlayOnceFromDir )
|
|||||||
StartQueuedSounds();
|
StartQueuedSounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RageSounds::PlayOnceFromAnnouncer( CString sFolderName )
|
||||||
|
{
|
||||||
|
/* Add the path to the g_SoundsToPlayOnceFromDir queue. */
|
||||||
|
CString *p = new CString( sFolderName );
|
||||||
|
if( !g_SoundsToPlayOnceFromAnnouncer.write( &p, 1 ) )
|
||||||
|
delete p;
|
||||||
|
|
||||||
|
if( !g_ThreadedMusicStart )
|
||||||
|
StartQueuedSounds();
|
||||||
|
}
|
||||||
|
|
||||||
float RageSounds::GetPlayLatency() const
|
float RageSounds::GetPlayLatency() const
|
||||||
{
|
{
|
||||||
return SOUNDMAN->GetPlayLatency();
|
return SOUNDMAN->GetPlayLatency();
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ public:
|
|||||||
|
|
||||||
void PlayOnce( CString sPath );
|
void PlayOnce( CString sPath );
|
||||||
void PlayOnceFromDir( CString sDir );
|
void PlayOnceFromDir( CString sDir );
|
||||||
|
void PlayOnceFromAnnouncer( CString sFolderName );
|
||||||
|
|
||||||
float GetPlayLatency() const;
|
float GetPlayLatency() const;
|
||||||
void HandleSongTimer( bool on=true );
|
void HandleSongTimer( bool on=true );
|
||||||
|
|||||||
Reference in New Issue
Block a user