Remove including statement that is unused (ext-policy.h)
[platform/core/api/audio-io.git] / include / CPulseAudioClient.h
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __TIZEN_MEDIA_AUDIO_IO_CPULSEAUDIO_CLIENT_H__
18 #define __TIZEN_MEDIA_AUDIO_IO_CPULSEAUDIO_CLIENT_H__
19
20
21 #ifdef __cplusplus
22
23
24 #include <pulse/pulseaudio.h>
25
26
27 namespace tizen_media_audio {
28
29
30     /**
31      * PULSE Thread
32      */
33     class CPulseAudioVolume;
34     class CPulseAudioPolicy;
35     class CPulseStreamSpec;
36     class CPulseAudioClient {
37     public:
38         enum class EStreamDirection : unsigned int {
39             STREAM_DIRECTION_RECORD,        /**< Record stream */
40             STREAM_DIRECTION_PLAYBACK       /**< Playback stream */
41         };
42
43         /* Constants */
44         static const char* CLIENT_NAME;
45
46         /* Constructor & Destructor */
47         CPulseAudioClient(EStreamDirection      direction,
48                           CPulseStreamSpec&     spec,
49                           IPulseStreamListener* listener);
50         ~CPulseAudioClient();
51
52         /* Implemented Methods */
53         void initialize() throw (CAudioError);
54         void finalize();
55
56         /* Methods */
57         int  peek(const void** data, size_t* length) throw (CAudioError);
58         int  drop() throw (CAudioError);
59         int  write(const void* data, size_t length) throw (CAudioError);
60
61         void cork(bool cork) throw (CAudioError);
62         bool isCorked() throw (CAudioError);
63
64         bool drain() throw (CAudioError);
65         bool flush() throw (CAudioError);
66
67         void checkRunningState() throw (CAudioError);
68         bool isInThread() throw (CAudioError);
69
70         size_t getWritableSize() throw (CAudioError);
71         size_t getReadableSize() throw (CAudioError);
72
73         size_t getBufferSize() throw (CAudioError);
74
75         pa_usec_t getLatency() throw (CAudioError);
76         pa_usec_t getFinalLatency() throw (CAudioError);
77
78         /* Setter & Getter */
79         EStreamDirection getStreamDirection();
80         CPulseStreamSpec getStreamSpec();
81
82     private:
83         /* Members */
84         EStreamDirection      __mDirection;
85         CPulseStreamSpec      __mSpec;
86         IPulseStreamListener* __mpListener;
87
88         pa_threaded_mainloop* __mpMainloop;
89         pa_context*           __mpContext;
90         pa_stream*            __mpStream;
91         pa_proplist*          __mpPropList;
92
93         bool                  __mIsInit;
94         bool                  __mIsOperationSuccess;
95
96         /* Static Methods */
97
98         /* Private Method */
99
100         /* Private Calblack Method */
101         static void __contextStateChangeCb(pa_context* c, void* user_data);
102         static void __successContextCb(pa_context* c, int success, void* user_data);
103
104         static void __streamStateChangeCb(pa_stream* s, void* user_data);
105         static void __streamCaptureCb(pa_stream* s, size_t length, void* user_data);
106         static void __streamPlaybackCb(pa_stream* s, size_t length, void* user_data);
107         static void __streamLatencyUpdateCb(pa_stream* s, void* user_data);
108         static void __successStreamCb(pa_stream* s, int success, void* user_data);
109     };
110
111
112 } /* namespace tizen_media_audio */
113
114 #endif
115 #endif /* __TIZEN_MEDIA_AUDIO_IO_CPULSEAUDIO_CLIENT_H__ */