• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef INTERRUPT_MULTI_RENDERER_TEST_H
17 #define INTERRUPT_MULTI_RENDERER_TEST_H
18 
19 #include <cstdint>
20 #include <cstdio>
21 #include <memory>
22 #include "audio_info.h"
23 #include "audio_renderer.h"
24 
25 namespace OHOS {
26 namespace AudioStandard {
27 class AudioRendererCallbackTestImpl : public AudioRendererCallback {
28 public:
29     void OnInterrupt(const InterruptEvent &interruptEvent) override;
30     void OnStateChange(const RendererState state, const StateChangeCmdType __attribute__((unused)) cmdType) override;
31     bool isRendererPaused_ = false;
32     bool isStopInProgress_ = false;
33     bool isRendererStopped_ = false;
34     bool isRendererResumed_ = false;
35 };
36 class InterruptMultiRendererTest {
37 public:
38     int32_t TestPlayback(int argc, char *argv[]) const;
39 private:
40     AudioSampleFormat GetSampleFormat(int32_t wavSampleFormat) const;
41     bool InitRender(const std::unique_ptr<AudioRenderer> &audioRenderer, FILE* &wavFile) const;
42     bool StartRender(const std::unique_ptr<AudioRenderer> &audioRenderer) const;
43     void WriteBuffer(AudioRenderer* audioRenderer, FILE* wavFile,
44                      const std::shared_ptr<AudioRendererCallbackTestImpl> &cb) const;
45     int32_t ValidateFile(char *filePath, char path[]) const;
46 };
47 } // namespace AudioStandard
48 } // namespace OHOS
49 #endif // INTERRUPT_MULTI_RENDERER_TEST_H
50