audio-io fixed build issue on 64-bit platform
[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     private:
32
33         const void* mpSyncReadDataPtr;
34         size_t      mSyncReadIndex;
35         size_t      mSyncReadLength;
36
37         bool mIsUsedSyncRead;
38         bool mIsInit;
39
40         /* Private Methods */
41         void setInit(bool flag);
42         bool IsInit();
43         bool IsReady();
44
45     public:
46         /* Constructor & Destructor */
47         CAudioInput(CAudioInfo& info);
48         CAudioInput(
49                     unsigned int            sampleRate,
50                     CAudioInfo::EChannel    channel,
51                     CAudioInfo::ESampleType sampleType,
52                     CAudioInfo::EAudioType  audioType);
53         ~CAudioInput();
54
55         /* Overridden Handler */
56         virtual void onStream(CPulseAudioClient* pClient, size_t length);
57         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);
58         virtual void onSignal(CAudioSessionHandler* pHandler, mm_sound_signal_name_t signal, int value);
59
60         /* Implemented Methods */
61         virtual void initialize() throw (CAudioError);
62         virtual void finalize();
63
64         virtual void prepare() throw (CAudioError);
65         virtual void unprepare() throw (CAudioError);
66
67         virtual void pause() throw (CAudioError);
68         virtual void resume() throw (CAudioError);
69
70         virtual void drain() throw (CAudioError);
71         virtual void flush() throw (CAudioError);
72
73         virtual int  getBufferSize() throw (CAudioError);
74
75         /* Overridden Methods */
76         virtual void setStreamCallback(SStreamCallback callback) throw (CAudioError);
77
78         /* Methods */
79         size_t read(void* buffer, size_t length) throw (CAudioError);
80         int peek(const void** buffer, size_t* length) throw (CAudioError);
81         int drop() throw (CAudioError);
82     };
83 } /* namespace tizen_media_audio */
84
85 #endif
86 #endif /* __TIZEN_MEDIA_AUDIO_IO_CAUDIO_INPUT_H__ */