3 * Copyright (C) 2005-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/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"
29 class CAESinkDARWINOSX : public IAESink
32 virtual const char *GetName() { return "DARWINOSX"; }
35 virtual ~CAESinkDARWINOSX();
37 virtual bool Initialize(AEAudioFormat &format, std::string &device);
38 virtual void Deinitialize();
39 virtual bool IsCompatible(const AEAudioFormat &format, const std::string &device);
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);
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);
52 AEAudioFormat m_format;
54 volatile bool m_draining;
56 CCoreAudioDevice m_device;
57 CCoreAudioStream m_outputStream;
58 unsigned int m_latentFrames;
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
63 float *m_planarBuffer; ///< buffer for planar conversion
65 AERingBuffer *m_buffer;
66 volatile bool m_started; // set once we get a callback from CoreAudio, which can take a little while.