apply new version of audio-io for tizen 3.0
[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     private:
34         bool mIsUsedSyncWrite;
35         bool mIsInit;
36
37         /* Private Methods */
38         void setInit(bool flag);
39         bool IsInit();
40         bool IsReady();
41
42     public:
43         /* Constructor & Destructor */
44         CAudioOutput(CAudioInfo& info);
45         CAudioOutput(
46                     unsigned int            smapleRate,
47                     CAudioInfo::EChannel    channel,
48                     CAudioInfo::ESampleType sampleType,
49                     CAudioInfo::EAudioType  type);
50         ~CAudioOutput();
51
52         /* Overridden Handler */
53         virtual void onStream(CPulseAudioClient* pClient, size_t length);
54         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);
55         virtual void onSignal(CAudioSessionHandler* pHandler, mm_sound_signal_name_t signal, int value);
56
57         /* Implemented Methods */
58         virtual void initialize() throw (CAudioError);
59         virtual void finalize();
60
61         virtual void prepare() throw (CAudioError);
62         virtual void unprepare() throw (CAudioError);
63
64         virtual void pause() throw (CAudioError);
65         virtual void resume() throw (CAudioError);
66
67         virtual void drain() throw (CAudioError);
68         virtual void flush() throw (CAudioError);
69
70         virtual int  getBufferSize() throw (CAudioError);
71
72         /* Methods */
73         int write(const void* buffer, unsigned int length) throw (CAudioError);
74     };
75
76 } /* namespace tizen_media_audio */
77
78 #endif
79 #endif /* __TIZEN_MEDIA_AUDIO_IO_CAUDIO_OUTPUT_H__ */