Merge pull request #4314 from MartijnKaijser/beta1
[vuplus_xbmc] / xbmc / cores / AudioEngine / Sinks / AESinkDARWINIOS.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
25 #define DO_440HZ_TONE_TEST 0
26
27 #if DO_440HZ_TONE_TEST
28 typedef struct {
29   float currentPhase;
30   float phaseIncrement;
31 } SineWaveGenerator;
32 #endif
33
34 class AERingBuffer;
35 class CAAudioUnitSink;
36
37 class CAESinkDARWINIOS : public IAESink
38 {
39 public:
40   virtual const char *GetName() { return "DARWINIOS"; }
41
42   CAESinkDARWINIOS();
43   virtual ~CAESinkDARWINIOS();
44
45   virtual bool Initialize(AEAudioFormat &format, std::string &device);
46   virtual void Deinitialize();
47   virtual bool IsCompatible(const AEAudioFormat &format, const std::string &device);
48
49   virtual double       GetDelay        ();
50   virtual double       GetCacheTotal   ();
51   virtual unsigned int AddPackets      (uint8_t *data, unsigned int frames, bool hasAudio, bool blocking = false);
52   virtual void         Drain           ();
53   virtual bool         HasVolume       ();
54   virtual void         SetVolume       (float scale);
55   static void          EnumerateDevicesEx(AEDeviceInfoList &list, bool force = false);
56
57 private:
58   static AEDeviceInfoList m_devices;
59   CAEDeviceInfo      m_info;
60   AEAudioFormat      m_format;
61   double             m_volume;
62   bool               m_volume_changed;
63
64   CAAudioUnitSink   *m_audioSink;
65 #if DO_440HZ_TONE_TEST
66   SineWaveGenerator  m_SineWaveGenerator;
67 #endif
68 };