Merge branch 'tizen' into tizen_line_coverage
[platform/core/api/audio-io.git] / include / CAudioInput.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_CAUDIO_INPUT_H__
18 #define __TIZEN_MEDIA_AUDIO_IO_CAUDIO_INPUT_H__
19
20
21 #ifdef __cplusplus
22
23
24 namespace tizen_media_audio {
25
26
27     /**
28      * A class CAudioInput that inherited from CAudioIO
29      */
30     class CAudioInput : public CAudioIO {
31     public:
32         /* Constructor & Destructor */
33         CAudioInput(CAudioInfo& info);
34         CAudioInput(
35                     unsigned int            sampleRate,
36                     CAudioInfo::EChannel    channel,
37                     CAudioInfo::ESampleType sampleType,
38                     CAudioInfo::EAudioType  audioType);
39         ~CAudioInput();
40
41         /* Overridden Handler */
42         virtual void onStream(CPulseAudioClient* pClient, size_t length);
43
44         /* Implemented Methods */
45         virtual void initialize();
46         virtual void finalize();
47
48         virtual void prepare();
49         virtual void unprepare();
50
51         virtual void pause();
52         virtual void resume();
53
54         virtual void flush();
55
56         virtual int  getBufferSize();
57
58         /* Overridden Methods */
59         virtual void setStreamCallback(SStreamCallback callback);
60
61         /* Methods */
62         size_t read(void* buffer, size_t length);
63         int peek(const void** buffer, size_t* length);
64         int drop();
65
66     private:
67         /* Private Methods */
68         void __setInit(bool flag);
69         bool __IsInit();
70         bool __IsReady();
71
72         bool __mIsUsedSyncRead;
73         bool __mIsInit;
74     };
75
76
77 } /* namespace tizen_media_audio */
78
79 #endif
80 #endif /* __TIZEN_MEDIA_AUDIO_IO_CAUDIO_INPUT_H__ */