Modify for replacing wearable version 2.4 with 3.0
[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         virtual void onInterrupt(CAudioSessionHandler* pHandler, int id, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e state, const char *reason_for_change, const char *additional_info);
44         virtual void onSignal(CAudioSessionHandler* pHandler, mm_sound_signal_name_t signal, int value);
45
46         /* Implemented Methods */
47         virtual void initialize() throw(CAudioError);
48         virtual void finalize();
49
50         virtual void prepare() throw(CAudioError);
51         virtual void unprepare() throw(CAudioError);
52
53         virtual void pause() throw(CAudioError);
54         virtual void resume() throw(CAudioError);
55
56         virtual void drain() throw(CAudioError);
57         virtual void flush() throw(CAudioError);
58
59         virtual int  getBufferSize() throw(CAudioError);
60
61         /* Overridden Methods */
62         virtual void setStreamCallback(SStreamCallback callback) throw(CAudioError);
63
64         /* Methods */
65         size_t read(void* buffer, size_t length) throw(CAudioError);
66         int peek(const void** buffer, size_t* length) throw(CAudioError);
67         int drop() throw(CAudioError);
68
69     private:
70         /* Private Methods */
71         void __setInit(bool flag);
72         bool __IsInit();
73         bool __IsReady();
74
75         bool __mIsUsedSyncRead;
76         bool __mIsInit;
77     };
78
79
80 } /* namespace tizen_media_audio */
81
82 #endif
83 #endif /* __TIZEN_MEDIA_AUDIO_IO_CAUDIO_INPUT_H__ */