00001 #ifndef RAGE_SOUND_DRIVER 00002 #define RAGE_SOUND_DRIVER 00003 00004 class RageSoundBase; 00005 class RageSoundDriver 00006 { 00007 public: 00008 friend class RageSoundManager; 00009 00010 /* Initialize. On failure, an error message is returned. */ 00011 virtual CString Init() { return ""; } 00012 00013 /* A RageSound calls this to request to be played. 00014 * XXX: define what we should do when it can't be played (eg. out of 00015 * channels) */ 00016 virtual void StartMixing( RageSoundBase *snd ) = 0; 00017 00018 /* A RageSound calls this to request it not be played. When this function 00019 * returns, snd is no longer valid; ensure no running threads are still 00020 * accessing it before returning. This must handle gracefully the case where 00021 * snd was not actually being played, though it may print a warning. */ 00022 virtual void StopMixing( RageSoundBase *snd ) = 0; 00023 00024 /* Get the current position of a given buffer, in the same units and time base 00025 * as passed to RageSound::GetPCM. */ 00026 virtual int64_t GetPosition( const RageSoundBase *snd ) const = 0; 00027 00028 /* When a sound is finished playing (GetPCM returns less than requested) and 00029 * the sound has been completely flushed (so GetPosition is no longer meaningful), 00030 * call RageSoundBase::SoundIsFinishedPlaying(). */ 00031 00032 /* Optional, if needed: */ 00033 virtual void Update(float delta) { } 00034 00035 /* Sound startup latency--delay between Play() being called and actually 00036 * hearing it. (This isn't necessarily the same as the buffer latency.) */ 00037 virtual float GetPlayLatency() const { return 0.0f; } 00038 00039 virtual int GetSampleRate( int rate ) const { return 44100; } 00040 00041 virtual ~RageSoundDriver() { } 00042 }; 00043 00044 /* 00045 * (c) 2002-2004 Glenn Maynard 00046 * All rights reserved. 00047 * 00048 * Permission is hereby granted, free of charge, to any person obtaining a 00049 * copy of this software and associated documentation files (the 00050 * "Software"), to deal in the Software without restriction, including 00051 * without limitation the rights to use, copy, modify, merge, publish, 00052 * distribute, and/or sell copies of the Software, and to permit persons to 00053 * whom the Software is furnished to do so, provided that the above 00054 * copyright notice(s) and this permission notice appear in all copies of 00055 * the Software and that both the above copyright notice(s) and this 00056 * permission notice appear in supporting documentation. 00057 * 00058 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00059 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00060 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF 00061 * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS 00062 * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT 00063 * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 00064 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 00065 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 00066 * PERFORMANCE OF THIS SOFTWARE. 00067 */ 00068 00069 #endif