3 * Copyright (C) 2010-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/>.
25 #include "Interfaces/AE.h"
26 #include "PulseAEStream.h"
27 #include "PulseAESound.h"
28 #include "threads/CriticalSection.h"
32 struct pa_threaded_mainloop;
37 class CPulseAE : public IAE
40 friend class CAEFactory;
45 virtual bool CanInit();
46 virtual bool Initialize ();
47 virtual void OnSettingsChange(const std::string& setting);
49 virtual bool Suspend(); /* Suspend output and de-initialize exclusive sink for external players and power savings */
51 virtual bool IsSuspended();
52 virtual bool Resume(); /* Resume ouput and re-initialize sink after Suspend() above */
54 virtual float GetVolume();
55 virtual void SetVolume(float volume);
57 /* returns a new stream for data in the specified format */
58 virtual IAEStream *MakeStream(enum AEDataFormat dataFormat, unsigned int sampleRate, unsigned int encodedSampleRate, CAEChannelInfo channelLayout, unsigned int options = 0);
59 virtual IAEStream *FreeStream(IAEStream *stream);
60 void RemoveStream(IAEStream *stream);
62 /* returns a new sound object */
63 virtual IAESound *MakeSound(const std::string& file);
64 virtual void FreeSound(IAESound *sound);
66 /* free's sounds that have expired */
67 virtual void GarbageCollect();
69 virtual void SetMute(const bool enabled);
70 virtual bool IsMuted() { return m_muted; }
71 virtual void SetSoundMode(const int mode) {}
72 #if PA_CHECK_VERSION(1,0,0)
73 virtual bool SupportsRaw() { return true; }
76 virtual void EnumerateOutputDevices(AEDeviceList &devices, bool passthrough);
78 CCriticalSection m_lock;
79 std::list<CPulseAEStream*> m_streams;
80 std::list<CPulseAESound* > m_sounds;
82 static void ContextStateCallback(pa_context *c, void *userdata);
84 pa_context *m_Context;
85 pa_threaded_mainloop *m_MainLoop;