Merge pull request #4314 from MartijnKaijser/beta1
[vuplus_xbmc] / xbmc / cores / AudioEngine / AEFactory.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 <vector>
23
24 #include "Interfaces/AE.h"
25 #include "threads/Thread.h"
26
27 class CSetting;
28
29 enum AEEngine
30 {
31   AE_ENGINE_NULL,
32   AE_ENGINE_COREAUDIO,
33   AE_ENGINE_ACTIVE,
34   AE_ENGINE_PIAUDIO
35 };
36
37 class CAEFactory
38 {
39 public:
40   static IAE *GetEngine();
41   static bool LoadEngine();
42   static void UnLoadEngine();
43   static bool StartEngine();
44   static bool Suspend(); /** Suspends output and de-initializes output sink - used for external players or power saving */
45   static bool Resume(); /** Resumes output after Suspend - re-initializes sink */
46   static bool IsSuspended(); /** Returns true if output has been suspended */
47   /* wrap engine interface */
48   static IAESound *MakeSound(const std::string &file);
49   static void FreeSound(IAESound *sound);
50   static void SetSoundMode(const int mode);
51   static void OnSettingsChange(std::string setting);
52   static void EnumerateOutputDevices(AEDeviceList &devices, bool passthrough);
53   static void VerifyOutputDevice(std::string &device, bool passthrough);
54   static std::string GetDefaultDevice(bool passthrough);
55   static bool SupportsRaw(AEDataFormat format);
56   static bool SupportsSilenceTimeout();
57
58   /**
59    * Returns true if current AudioEngine supports at lest two basic quality levels
60    * @return true if quality setting is supported, otherwise false
61    */
62   static bool SupportsQualitySetting(void);
63   static void SetMute(const bool enabled);
64   static bool IsMuted();
65   static float GetVolume();
66   static void SetVolume(const float volume);
67   static void Shutdown();
68   static IAEStream *MakeStream(enum AEDataFormat dataFormat, unsigned int sampleRate, 
69     unsigned int encodedSampleRate, CAEChannelInfo channelLayout, unsigned int options = 0);
70   static IAEStream *FreeStream(IAEStream *stream);
71   static void GarbageCollect();
72
73   static void SettingOptionsAudioDevicesFiller(const CSetting *setting, std::vector< std::pair<std::string, std::string> > &list, std::string &current);
74   static void SettingOptionsAudioDevicesPassthroughFiller(const CSetting *setting, std::vector< std::pair<std::string, std::string> > &list, std::string &current);
75   static void SettingOptionsAudioQualityLevelsFiller(const CSetting *setting, std::vector< std::pair<std::string, int> > &list, int &current);
76   static void SettingOptionsAudioStreamsilenceFiller(const CSetting *setting, std::vector< std::pair<std::string, int> > &list, int &current);
77   static bool IsSettingVisible(const std::string &condition, const std::string &value, const std::string &settingId);
78   static void KeepConfiguration(unsigned int millis);
79   static void DeviceChange();
80
81   static void RegisterAudioCallback(IAudioCallback* pCallback);
82   static void UnregisterAudioCallback();
83
84 private:
85   static bool LoadEngine(enum AEEngine engine);
86   static IAE *AE;
87
88   static void SettingOptionsAudioDevicesFillerGeneral(const CSetting *setting, std::vector< std::pair<std::string, std::string> > &list, std::string &current, bool passthrough);
89 };
90