Merge pull request #4875 from koying/fixdroidremotekeyboard
[vuplus_xbmc] / xbmc / cores / AudioEngine / Sinks / AESinkDARWINOSX.h
1 #pragma once
2 /*
3  *      Copyright (C) 2005-2013 Team XBMC
4  *      http://xbmc.org
5  *
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)
9  *  any later version.
10  *
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.
15  *
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/>.
19  *
20  */
21
22 #include "cores/AudioEngine/Interfaces/AESink.h"
23 #include "cores/AudioEngine/Utils/AEDeviceInfo.h"
24 #include "cores/AudioEngine/Sinks/osx/CoreAudioDevice.h"
25 #include "cores/AudioEngine/Sinks/osx/CoreAudioStream.h"
26
27 class AERingBuffer;
28
29 class CAESinkDARWINOSX : public IAESink
30 {
31 public:
32   virtual const char *GetName() { return "DARWINOSX"; }
33
34   CAESinkDARWINOSX();
35   virtual ~CAESinkDARWINOSX();
36
37   virtual bool Initialize(AEAudioFormat &format, std::string &device);
38   virtual void Deinitialize();
39   virtual bool IsCompatible(const AEAudioFormat &format, const std::string &device);
40
41   virtual double       GetDelay        ();
42   virtual double       GetCacheTotal   ();
43   virtual unsigned int AddPackets      (uint8_t *data, unsigned int frames, bool hasAudio, bool blocking = false);
44   virtual void         Drain           ();
45   static void          EnumerateDevicesEx(AEDeviceInfoList &list, bool force = false);
46
47 private:
48   static OSStatus renderCallback(AudioDeviceID inDevice, const AudioTimeStamp* inNow, const AudioBufferList* inInputData, const AudioTimeStamp* inInputTime, AudioBufferList* outOutputData, const AudioTimeStamp* inOutputTime, void* inClientData);
49   void SetHogMode(bool on);
50
51   CAEDeviceInfo      m_info;
52   AEAudioFormat      m_format;
53
54   volatile bool      m_draining;
55
56   CCoreAudioDevice   m_device;
57   CCoreAudioStream   m_outputStream;
58   unsigned int       m_latentFrames;
59
60   bool               m_outputBitstream;   ///< true if we're bistreaming into a LinearPCM stream rather than AC3 stream.
61   int16_t           *m_outputBuffer;      ///< buffer for bitstreaming
62   bool               m_planar;
63   float             *m_planarBuffer;      ///< buffer for planar conversion
64
65   AERingBuffer      *m_buffer;
66   volatile bool      m_started;     // set once we get a callback from CoreAudio, which can take a little while.
67 };