changed: Improve (fallback) logic for subtitle downloading
[vuplus_xbmc] / xbmc / cores / AudioEngine / Sinks / AESinkPULSE.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
24 #include "cores/AudioEngine/Interfaces/AESink.h"
25 #include "Utils/AEDeviceInfo.h"
26 #include "Utils/AEUtil.h"
27 #include <pulse/pulseaudio.h>
28
29 class CAESinkPULSE : public IAESink
30 {
31 public:
32   virtual const char *GetName() { return "PULSE"; }
33
34   CAESinkPULSE();
35   virtual ~CAESinkPULSE();
36
37   virtual bool Initialize(AEAudioFormat &format, std::string &device);
38   virtual void Deinitialize();
39
40   virtual double       GetDelay        ();
41   virtual double       GetCacheTotal   ();
42   virtual unsigned int AddPackets      (uint8_t *data, unsigned int frames, bool hasAudio, bool blocking = false);
43   virtual void         Drain           ();
44
45   virtual bool HasVolume() { return true; };
46   virtual void SetVolume(float volume);
47
48   static void EnumerateDevicesEx(AEDeviceInfoList &list, bool force = false);
49 private:
50   bool Pause(bool pause);
51   static inline bool WaitForOperation(pa_operation *op, pa_threaded_mainloop *mainloop, const char *LogEntry);
52   static bool SetupContext(const char *host, pa_context **context, pa_threaded_mainloop **mainloop);
53
54   bool m_IsAllocated;
55   bool m_passthrough;
56
57   AEAudioFormat m_format;
58   unsigned int m_BytesPerSecond;
59   unsigned int m_BufferSize;
60   unsigned int m_Channels;
61   
62   pa_stream *m_Stream;
63   pa_cvolume m_Volume;
64
65   pa_context *m_Context;
66   pa_threaded_mainloop *m_MainLoop;
67 };