[release] version bump to 13.0 beta1
[vuplus_xbmc] / xbmc / cores / AudioEngine / Engines / PulseAE / PulseAE.h
1 #pragma once
2 /*
3  *      Copyright (C) 2010-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 "system.h"
23 #ifdef HAS_PULSEAUDIO
24
25 #include "Interfaces/AE.h"
26 #include "PulseAEStream.h"
27 #include "PulseAESound.h"
28 #include "threads/CriticalSection.h"
29 #include <list>
30
31 struct pa_context;
32 struct pa_threaded_mainloop;
33 struct pa_stream;
34
35 class CPulseAEStream;
36 class CPulseAESound;
37 class CPulseAE : public IAE
38 {
39 protected:
40   friend class CAEFactory;
41   CPulseAE();
42   virtual ~CPulseAE();
43
44 public:
45   virtual bool  CanInit();
46   virtual bool  Initialize      ();
47   virtual void  OnSettingsChange(const std::string& setting);
48
49   virtual bool  Suspend(); /* Suspend output and de-initialize exclusive sink for external players and power savings */
50
51   virtual bool  IsSuspended();
52   virtual bool  Resume();  /* Resume ouput and re-initialize sink after Suspend() above */
53
54   virtual float GetVolume();
55   virtual void  SetVolume(float volume);
56
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);
61
62   /* returns a new sound object */
63   virtual IAESound *MakeSound(const std::string& file);
64   virtual void      FreeSound(IAESound *sound);
65
66   /* free's sounds that have expired */
67   virtual void GarbageCollect();
68
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; }
74 #endif
75
76   virtual void EnumerateOutputDevices(AEDeviceList &devices, bool passthrough);
77 private:
78   CCriticalSection m_lock;
79   std::list<CPulseAEStream*> m_streams;
80   std::list<CPulseAESound* > m_sounds;
81
82   static void ContextStateCallback(pa_context *c, void *userdata);
83
84   pa_context *m_Context;
85   pa_threaded_mainloop *m_MainLoop;
86   float m_Volume;
87   bool m_muted;
88 };
89
90 #endif