~aleteoryx/muditaos

ref: 7dee85f011b50783da4aff0e96b33893c1600e3a muditaos/module-bsp/board/linux/audio/LinuxCellularAudio.hpp -rwxr-xr-x 1.5 KiB
7dee85f0 — Tomas Rogala [EGD-4711] Change calendar events endpoints 5 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#ifndef PUREPHONE_LINUXCELLULARAUDIO_HPP
#define PUREPHONE_LINUXCELLULARAUDIO_HPP

#include "bsp/audio/bsp_audio.hpp"
#include "portaudio.h"

namespace bsp
{

    class LinuxCellularAudio : public AudioDevice
    {
      public:
        LinuxCellularAudio(AudioDevice::audioCallback_t callback);

        virtual ~LinuxCellularAudio();

        AudioDevice::RetCode Start(const Format &format) override final;

        AudioDevice::RetCode Stop() override final;

        AudioDevice::RetCode OutputVolumeCtrl(float vol) override final;

        AudioDevice::RetCode InputGainCtrl(float gain) override final;

        AudioDevice::RetCode OutputPathCtrl(OutputPath outputPath) override final;

        AudioDevice::RetCode InputPathCtrl(InputPath inputPath) override final;

        bool IsFormatSupported(const Format &format) override final;

      private:
        PaStream *stream;

        static int portAudioCallback(const void *inputBuffer,
                                     void *outputBuffer,
                                     unsigned long framesPerBuffer,
                                     const PaStreamCallbackTimeInfo *timeInfo,
                                     PaStreamCallbackFlags statusFlags,
                                     void *userData);

        bool TryOpenStream(const bsp::AudioDevice::Format &format);
    };

} // namespace bsp

#endif // PUREPHONE_LINUXCELLULARAUDIO_HPP