• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
33         onAudioReady(oboe::AudioStream *audioStream,void *audioData, int numFrames) override;
34 //    virtual void onErrorAfterClose(oboe::AudioStream *oboeStream, oboe::Result error) override {}
35 //    virtual void onErrorBeforeClose(oboe::AudioStream * oboeStream, oboe::Result error) override {}
36 
37     //
38     // State
39     //
isRecording()40     virtual bool isRecording() override { return mStreamStarted; }
41 
42     Result buildStream(int32_t channelCount, int32_t sampleRate, int32_t performanceMode,
43                         int32_t sharingMode, int32_t routeDeviceId, int32_t inputPreset);
44 
45     Result openStream();
46 
47     Result startStream();
48 
49     int getStreamState();
50 
51     static const int DEFAULT_INPUT_NONE = -1;  // from Recorder.java
setInputPreset(int inputPreset)52     void setInputPreset(int inputPreset) { mInputPreset = inputPreset; }
53 
54 private:
55     int32_t mInputPreset;
56 };
57 
58 #endif // MEGA_RECORDER_OBOERECORDER_H
59