67050200171a6117f057899a5a21cec224467d60
[platform/core/api/audio-io.git] / include / CAudioOutput.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_OUTPUT_H__
18 #define __TIZEN_MEDIA_AUDIO_IO_CAUDIO_OUTPUT_H__
19
20
21 #ifdef __cplusplus
22
23 #include "CAudioIODef.h"
24
25
26 namespace tizen_media_audio {
27
28
29     /**
30      * A class CAudioOutput that inherited from CAudioIO
31      */
32     class CAudioOutput : public CAudioIO {
33     public:
34         /* Constructor & Destructor */
35         CAudioOutput(CAudioInfo& info);
36         CAudioOutput(
37                     unsigned int            smapleRate,
38                     CAudioInfo::EChannel    channel,
39                     CAudioInfo::ESampleType sampleType,
40                     CAudioInfo::EAudioType  type);
41         ~CAudioOutput();
42
43         /* Overridden Handler */
44         virtual void onStream(CPulseAudioClient* pClient, size_t length);
45         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);
46         virtual void onSignal(CAudioSessionHandler* pHandler, mm_sound_signal_name_t signal, int value);
47
48         /* Implemented Methods */
49         virtual void initialize();
50         virtual void finalize();
51
52         virtual void prepare();
53         virtual void unprepare();
54
55         virtual void pause();
56         virtual void resume();
57
58         virtual void drain();
59         virtual void flush();
60
61         virtual int  getBufferSize();
62
63         /* Methods */
64         size_t write(const void* buffer, size_t length);
65
66     private:
67         /* Private Methods */
68         void __setInit(bool flag);
69         bool __IsInit();
70         bool __IsReady();
71
72         bool __mIsUsedSyncWrite;
73         bool __mIsInit;
74     };
75
76
77 } /* namespace tizen_media_audio */
78
79 #endif
80 #endif /* __TIZEN_MEDIA_AUDIO_IO_CAUDIO_OUTPUT_H__ */