| 1 |
#ifndef AVIFILE_IAUDIORENDERER_H |
| 2 |
#define AVIFILE_IAUDIORENDERER_H |
| 3 |
|
| 4 |
#include "avifile.h" |
| 5 |
#include "formats.h" |
| 6 |
#include "avm_locker.h" |
| 7 |
|
| 8 |
AVM_BEGIN_NAMESPACE; |
| 9 |
|
| 10 |
class AudioQueue; |
| 11 |
|
| 12 |
// call with started audio stream! |
| 13 |
class IAudioRenderer |
| 14 |
{ |
| 15 |
public: |
| 16 |
static const int VOL_MAX = 1000; |
| 17 |
static const int BAL_MAX = 1000; |
| 18 |
|
| 19 |
IAudioRenderer(IReadStream* astream, WAVEFORMATEX& m_Owf); |
| 20 |
virtual ~IAudioRenderer(); |
| 21 |
virtual int Init() { return 0; } |
| 22 |
// -1: error range 0-1000 |
| 23 |
virtual int GetVolume(); |
| 24 |
// -1: error range 0-500-1000 500 middle |
| 25 |
virtual int GetBalance(); |
| 26 |
virtual int SetVolume(int volume); |
| 27 |
virtual int SetBalance(int balance); |
| 28 |
|
| 29 |
// no overloadable at this moment |
| 30 |
bool Eof() const; |
| 31 |
int Extract(); |
| 32 |
const char* GetAudioFormat() const; |
| 33 |
double GetCacheSize() const; |
| 34 |
double GetLengthTime() const; |
| 35 |
double GetStreamTime() const { return m_dStreamTime; } |
| 36 |
double GetTime(); |
| 37 |
double GetBufferTime() const;//for how long we can play without Extract()'s? |
| 38 |
int Pause(bool state); // 0 - Ok -1 - ignored |
| 39 |
int SeekTime(double pos); |
| 40 |
void SetAsync(float async) { m_fAsync = async; } |
| 41 |
|
| 42 |
int SetPlayingRate(int rate) { return -1; } |
| 43 |
int SetResamplingRate(int rate) { return -1; } |
| 44 |
|
| 45 |
void Start(); |
| 46 |
void Stop(); |
| 47 |
|
| 48 |
protected: |
| 49 |
// overloaded |
| 50 |
virtual void pause(int) {} |
| 51 |
virtual int reset() { return 0; } |
| 52 |
virtual double getRendererBufferTime() const { return 0.; } |
| 53 |
void updateTimer(); |
| 54 |
|
| 55 |
IReadStream* m_pAudiostream; |
| 56 |
AudioQueue* m_pQueue; ///< using pointer - faster gcc3.0 compilation |
| 57 |
int64_t m_llTimeStart; ///< Timestamp of start |
| 58 |
/// updated after each reseek or pause |
| 59 |
size_t m_uiSamples; ///< Decoded samples from last seek |
| 60 |
double m_dStreamTime; ///< Precise stream time |
| 61 |
double m_dSeekTime; ///< Precise position at seek |
| 62 |
double m_dAudioRealpos; ///< Position used for timing |
| 63 |
double m_dPauseTime; ///< Timestamp at pause |
| 64 |
|
| 65 |
WAVEFORMATEX m_Iwf; ///< Input format of data we get from the audiostream |
| 66 |
WAVEFORMATEX m_Owf; ///< Resulting Output format of data |
| 67 |
double m_dIwfBPS; |
| 68 |
double m_dOwfBPS; |
| 69 |
|
| 70 |
int m_iBalance; |
| 71 |
int m_iVolume; |
| 72 |
float m_fAsync; ///< by default 0, hardware-dependent |
| 73 |
|
| 74 |
bool m_bQuit; ///< true when terminating thread |
| 75 |
bool m_bPaused; ///< true if we are paused |
| 76 |
bool m_bInitialized; ///< true if we are playing OR paused |
| 77 |
}; |
| 78 |
|
| 79 |
AVM_END_NAMESPACE; |
| 80 |
|
| 81 |
#endif // AVIFILE_IAUDIORENDERER_H |