3 * Copyright (C) 2010-2013 Team XBMC
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with XBMC; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
22 #include "cores/AudioEngine/Interfaces/AEStream.h"
23 #include "cores/AudioEngine/Utils/AEAudioFormat.h"
24 #include "cores/AudioEngine/Utils/AELimiter.h"
25 #include "cores/AudioEngine/Utils/AEConvert.h"
30 class CActiveAEStream : public IAEStream
33 friend class CActiveAE;
34 friend class CEngineStats;
35 CActiveAEStream(AEAudioFormat *format);
36 virtual ~CActiveAEStream();
37 void FadingFinished();
38 void IncFreeBuffers();
39 void DecFreeBuffers();
40 void ResetFreeBuffers();
45 virtual unsigned int GetSpace();
46 virtual unsigned int AddData(void *data, unsigned int size);
47 virtual double GetDelay();
48 virtual bool IsBuffering();
49 virtual double GetCacheTime();
50 virtual double GetCacheTotal();
53 virtual void Resume();
54 virtual void Drain(bool wait);
55 virtual bool IsDraining();
56 virtual bool IsDrained();
59 virtual float GetVolume();
60 virtual float GetReplayGain();
61 virtual float GetAmplification();
62 virtual void SetVolume(float volume);
63 virtual void SetReplayGain(float factor);
64 virtual void SetAmplification(float amplify);
66 virtual const unsigned int GetFrameSize() const;
67 virtual const unsigned int GetChannelCount() const;
69 virtual const unsigned int GetSampleRate() const ;
70 virtual const unsigned int GetEncodedSampleRate() const;
71 virtual const enum AEDataFormat GetDataFormat() const;
73 virtual double GetResampleRatio();
74 virtual bool SetResampleRatio(double ratio);
75 virtual void RegisterAudioCallback(IAudioCallback* pCallback);
76 virtual void UnRegisterAudioCallback();
77 virtual void FadeVolume(float from, float to, unsigned int time);
78 virtual bool IsFading();
79 virtual void RegisterSlave(IAEStream *stream);
83 AEAudioFormat m_format;
86 float m_streamAmplify;
87 double m_streamResampleRatio;
88 unsigned int m_streamSpace;
89 bool m_streamDraining;
92 int m_streamFreeBuffers;
93 bool m_streamIsBuffering;
94 IAEStream *m_streamSlave;
95 CAEConvert::AEConvertToFn m_convertFn;
96 CCriticalSection m_streamLock;
97 uint8_t *m_leftoverBuffer;
99 CSampleBuffer *m_currentBuffer;
100 CSoundPacket *m_remapBuffer;
101 CActiveAEResample *m_remapper;
103 // only accessed by engine
104 CActiveAEBufferPool *m_inputBuffers;
105 CActiveAEBufferPoolResample *m_resampleBuffers;
106 std::deque<CSampleBuffer*> m_processingSamples;
107 CActiveAEDataProtocol *m_streamPort;
109 CCriticalSection *m_statsLock;
113 CAELimiter m_limiter;
117 float m_bufferedTime;
120 float m_fadingTarget;
122 bool m_forceResampler;