fixup! Reset dump values when pause function is called
[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         explicit CAudioOutput(CAudioInfo& info);
36         ~CAudioOutput() = default;
37
38         /* Overridden Handler */
39         void onStream(CPulseAudioClient* pClient, size_t length) override;
40         void onCorked(CPulseAudioClient* pClient, bool corked) override;
41
42         /* Implemented Methods */
43         void initialize() override;
44         void finalize() override;
45
46         void prepare() override;
47         void unprepare() override;
48
49         void pause() override;
50         void resume() override;
51
52         void drain();
53         void flush() override;
54
55         int getBufferSize() override;
56
57         /* Methods */
58         size_t write(const void* buffer, size_t length);
59
60     private:
61         /* Private Methods */
62         void __setInit(bool flag) noexcept;
63         bool __IsInit() noexcept;
64         bool __IsReady() noexcept;
65         void __dumpStat() noexcept;
66         void __dumpStat(size_t length) noexcept;
67
68         bool __mIsUsedSyncWrite {};
69         bool __mIsInit {};
70
71         std::atomic<uint64_t> __mTotalWrittenCount {};
72         std::atomic<uint64_t> __mTotalWrittenBytes {};
73     };
74
75
76 } /* namespace tizen_media_audio */
77
78 #endif
79 #endif /* __TIZEN_MEDIA_AUDIO_IO_CAUDIO_OUTPUT_H__ */