Merge pull request #2703 from ace20022/cores_revised
[vuplus_xbmc] / xbmc / cores / AudioEngine / Interfaces / AESink.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 "threads/Thread.h"
23 #include "AE.h"
24 #include "AEAudioFormat.h"
25 #include "utils/StdString.h"
26 #include <stdint.h>
27
28 class IAESink
29 {
30 public:
31   /* return the name of this sync for logging */
32   virtual const char *GetName() = 0;
33
34   IAESink() {};
35   virtual ~IAESink() {};
36
37   /*
38     The sink does NOT have to honour anything in the format struct or the device
39     if however it does not honour what is requested, it MUST update device/format
40     with what it does support.
41   */
42   virtual bool Initialize  (AEAudioFormat &format, std::string &device) = 0;
43
44   /*
45     Deinitialize the sink for destruction
46   */
47   virtual void Deinitialize() = 0;
48
49   /*
50     Return true if the supplied format and device are compatible with the current open sink
51   */
52   virtual bool IsCompatible(const AEAudioFormat &format, const std::string &device) = 0;
53
54   /*
55     This method returns the time in seconds that it will take
56     for the next added packet to be heard from the speakers.
57   */
58   virtual double GetDelay() = 0;
59
60   /*
61     This method returns the time in seconds that it will take
62     to underrun the cache if no sample is added.
63   */
64   virtual double GetCacheTime() = 0;
65
66   /*
67     This method returns the total time in seconds of the cache.
68   */
69   virtual double GetCacheTotal() = 0;
70
71   /*
72     Adds packets to be sent out, this routine MUST block or sleep.
73   */
74   virtual unsigned int AddPackets(uint8_t *data, unsigned int frames, bool hasAudio, bool blocking = false) = 0;
75
76   /*
77     Drain the sink
78    */
79   virtual void Drain() {};
80
81   /*
82     Indicates if sink can handle volume control.
83   */
84   virtual bool  HasVolume() {return false;};
85
86   /*
87     This method sets the volume control, volume ranges from 0.0 to 1.0.
88   */
89   virtual void  SetVolume(float volume) {};
90
91   /*
92     Requests sink to prepare itself for a suspend state
93     @return false if sink cannot be suspended
94   */
95   virtual bool SoftSuspend() {return false;};
96
97   /*
98     Notify sink to prepare to resume processing after suspend state
99     @return false if sink must be reinitialized
100   */
101   virtual bool SoftResume() {return false;};
102 };
103