2 * Copyright (C) 2005-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
21 #ifndef _OMX_PLAYERAUDIO_H_
22 #define _OMX_PLAYERAUDIO_H_
25 #include <sys/types.h>
27 #include "utils/StdString.h"
30 #include "DVDStreamInfo.h"
32 #include "OMXAudioCodecOMX.h"
33 #include "threads/Thread.h"
35 #include "DVDDemuxers/DVDDemux.h"
36 #include "DVDMessageQueue.h"
37 #include "utils/BitstreamStats.h"
38 #include "xbmc/linux/DllBCM.h"
42 class OMXPlayerAudio : public CThread
45 CDVDMessageQueue m_messageQueue;
46 CDVDMessageQueue &m_messageParent;
48 CDVDStreamInfo m_hints_current;
49 CDVDStreamInfo m_hints;
52 std::string m_codec_name;
53 bool m_use_passthrough;
57 AEAudioFormat m_format;
58 CAEChannelInfo m_channelLayout;
59 COMXAudioCodecOMX *m_pAudioCodec;
67 BitstreamStats m_audioStats;
69 struct timespec m_starttime, m_endtime;
75 DllBcmHost m_DllBcmHost;
78 virtual void OnStartup();
79 virtual void OnExit();
80 virtual void Process();
83 OMXPlayerAudio(OMXClock *av_clock, CDVDMessageQueue& parent);
85 bool OpenStream(CDVDStreamInfo &hints);
86 void OpenStream(CDVDStreamInfo &hints, COMXAudioCodecOMX *codec);
87 void SendMessage(CDVDMsg* pMsg, int priority = 0) { m_messageQueue.Put(pMsg, priority); }
88 bool AcceptsData() const { return !m_messageQueue.IsFull(); }
89 bool HasData() const { return m_messageQueue.GetDataSize() > 0; }
90 bool IsInited() const { return m_messageQueue.IsInited(); }
91 int GetLevel() const { return m_messageQueue.GetLevel(); }
92 bool IsStalled() { return m_stalled; }
94 void WaitForBuffers();
95 bool CloseStream(bool bWaitForBuffers);
97 bool Decode(DemuxPacket *pkt, bool bDropPacket);
99 bool AddPacket(DemuxPacket *pkt);
100 AEDataFormat GetDataFormat(CDVDStreamInfo hints);
101 bool Passthrough() const;
105 double GetCacheTime();
106 double GetCacheTotal();
107 double GetCurrentPts() { return m_audioClock; };
108 void WaitCompletion();
110 void RegisterAudioCallback(IAudioCallback* pCallback);
111 void UnRegisterAudioCallback();
112 bool SetCurrentVolume(float fVolume);
113 void SetSpeed(int iSpeed);
114 int GetAudioBitrate();
115 std::string GetPlayerInfo();
117 bool BadState() { return m_bad_state; }