00001
#ifndef RAGE_SOUND_MANAGER_H
00002
#define RAGE_SOUND_MANAGER_H
00003
00004
#include <set>
00005
#include <map>
00006
#include "RageUtil_CircularBuffer.h"
00007
00008
class RageSound;
00009
class RageSoundBase;
00010
class RageSoundDriver;
00011
struct RageSoundParams;
00012
00013 class RageSoundManager
00014 {
00015
00016
00017 set<RageSound *>
owned_sounds;
00018
00019
00020 map<int,RageSound *>
all_sounds;
00021
00022 RageSoundDriver *
driver;
00023
00024
00025 float MixVolume;
00026 struct queued_pos_map_t
00027 {
00028 int ID,
pos,
got_frames;
00029 int64_t
frameno;
00030 };
00031
00032 CircBuf<queued_pos_map_t> pos_map_queue;
00033
00034
public:
00035
RageSoundManager();
00036
~RageSoundManager();
00037
00038
00039
00040
00041
00042
void Shutdown();
00043
00044
void Init( CString drivers );
00045
00046 float GetMixVolume()
const {
return MixVolume; }
00047
void SetPrefs(
float MixVol);
00048
00049
void Update(
float delta);
00050
void StartMixing(
RageSoundBase *snd );
00051
void StopMixing(
RageSoundBase *snd );
00052 int64_t GetPosition(
const RageSoundBase *snd )
const;
00053
void RegisterSound(
RageSound *p );
00054
void UnregisterSound(
RageSound *p );
00055
int GetUniqueID();
00056
void CommitPlayingPosition(
int ID, int64_t frameno,
int pos,
int got_bytes );
00057
float GetPlayLatency() const;
00058
int GetDriverSampleRate(
int rate ) const;
00059
00060
00061
00062
void DeleteSound(
RageSound *p );
00063
void DeleteSoundWhenFinished(
RageSound *pSound );
00064
00065
void PlayOnce( CString sPath );
00066
00067
RageSound *PlaySound(
RageSound &snd, const
RageSoundParams *params = NULL );
00068
RageSound *PlayCopyOfSound(
RageSound &snd, const
RageSoundParams *params = NULL );
00069
00070 static
void AttenuateBuf( int16_t *buf,
int samples,
float vol );
00071
00072 private:
00073
void FlushPosMapQueue();
00074
RageSound *GetSoundByID(
int ID );
00075 };
00076
00077 extern
RageSoundManager *SOUNDMAN;
00078
00079 #endif
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104