1 /*
2  * Copyright 2020 The Android Open Source Project
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 MEGA_RECORDER_OBOERECORDER_H
18 #define MEGA_RECORDER_OBOERECORDER_H
19 
20 #include <mutex>
21 
22 #include <oboe/Oboe.h>
23 
24 #include "Recorder.h"
25 
26 class OboeRecorder: public oboe::AudioStreamCallback, public Recorder {
27 public:
28     OboeRecorder(AudioSink* sink, int32_t recorderSubtype);
~OboeRecorder()29     virtual ~OboeRecorder() {}
30 
31     // Inherited from oboe::AudioStreamCallback
32     virtual oboe::DataCallbackResult onAudioReady(oboe::AudioStream *audioStream, void *audioData, int numFrames) override;
33 //    virtual void onErrorAfterClose(oboe::AudioStream *oboeStream, oboe::Result error) override {}
34 //    virtual void onErrorBeforeClose(oboe::AudioStream * oboeStream, oboe::Result error) override {}
35 
36     // Inherited from Recorder
37     //
38     // State
39     //
isRecording()40     virtual bool isRecording() override { return mStreamStarted; }
41 
42     virtual Result setupStream(int32_t channelCount, int32_t sampleRate, int32_t routeDeviceId) override;
43 
44     virtual Result startStream() override;
45 
46     static const int DEFAULT_INPUT_NONE = -1;  // from Recorder.java
setInputPreset(int inputPreset)47     void setInputPreset(int inputPreset) { mInputPreset = inputPreset; }
48 
49 private:
50     int32_t mInputPreset;
51 };
52 
53 #endif // MEGA_RECORDER_OBOERECORDER_H
54