2 * Copyright (C) 2010 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, write to
17 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 * http://www.gnu.org/copyleft/gpl.html
22 #ifndef __IOSAUDIO_RENDERER_H__
23 #define __IOSAUDIO_RENDERER_H__
25 #include "IOSCoreAudio.h"
26 #include "PlatformDefs.h"
27 #include "IAudioRenderer.h"
28 #include "threads/Event.h"
30 class IOSAudioRingBuffer;
31 class CIOSAudioRenderer : public IAudioRenderer
35 virtual ~CIOSAudioRenderer();
36 virtual unsigned int GetChunkLen();
37 virtual float GetDelay();
38 virtual bool Initialize(IAudioCallback* pCallback, const CStdString& device, int iChannels, enum PCMChannels *channelMap, unsigned int uiSamplesPerSec, unsigned int uiBitsPerSample, bool bResample, bool bIsMusic=false, bool bPassthrough = false);
39 virtual bool Deinitialize();
41 virtual unsigned int AddPackets(const void* data, unsigned int len);
42 virtual unsigned int GetSpace();
43 virtual float GetCacheTime();
44 virtual float GetCacheTotal();
47 virtual bool Resume();
49 virtual long GetCurrentVolume() const;
50 virtual void Mute(bool bMute);
51 virtual bool SetCurrentVolume(long nVolume);
52 virtual void SetDynamicRangeCompression(long drc) { m_drc = drc; }
53 virtual void WaitCompletion();
55 // Unimplemented IAudioRenderer methods
56 virtual int SetPlaySpeed(int iSpeed) {return 0;};
57 virtual void SwitchChannels(int iAudioStream, bool bAudioOnAllSpeakers) {};
58 virtual void UnRegisterAudioCallback() {};
59 virtual void RegisterAudioCallback(IAudioCallback* pCallback) {};
61 static void EnumerateAudioSinks(AudioSinkList& vAudioSinks, bool passthrough) {};
63 OSStatus OnRender(AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData);
64 static OSStatus RenderCallback(void *inRefCon, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData);
65 static void PropertyChanged(AudioSessionPropertyID inID, UInt32 inDataSize, const void* inPropertyValue);
66 static void PropertyChangeCallback(void* inClientData, AudioSessionPropertyID inID, UInt32 inDataSize, const void* inPropertyValue);
67 bool InitializePCM(UInt32 channels, UInt32 samplesPerSecond, UInt32 bitsPerSample, enum PCMChannels *channelMap);
70 bool m_Initialized; // Prevent multiple init/deinit
72 long m_CurrentVolume; // Courtesy of the jerk that made GetCurrentVolume a const...
73 bool m_EnableVolumeControl;
75 CIOSCoreAudioDevice m_AudioDevice;
76 UInt32 m_OutputBufferIndex;
80 int m_ChannelsPerFrame;
82 IOSAudioRingBuffer *m_Buffer;
83 unsigned int m_BytesPerSec;
84 unsigned int m_BufferLen; ///< must always be num_chunks * chunk_size
85 unsigned int m_NumChunks;
86 unsigned int m_PacketSize;
87 unsigned int m_BytesPerFrame;
88 unsigned int m_BufferFrames;
89 unsigned int m_SamplesPerSec;
93 unsigned int m_DataChannels;
94 unsigned int m_Channels;