• 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_PLAYER_OBOEPLAYER_H
18 #define MEGA_PLAYER_OBOEPLAYER_H
19 
20 #include <jni.h>
21 
22 #include <oboe/Oboe.h>
23 
24 #include "Player.h"
25 
26 class OboePlayer : public Player, oboe::AudioStreamCallback {
27 public:
28     OboePlayer(JNIEnv *env, AudioSource* source, int playerSubtype);
~OboePlayer()29     virtual ~OboePlayer() {}
30 
31     // Inherited from oboe::AudioStreamCallback
32     virtual oboe::DataCallbackResult onAudioReady(oboe::AudioStream *oboeStream, void *audioData,
33                                                     int32_t 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     Result buildStream(int32_t channelCount, int32_t channelMask, int32_t sampleRate,
38         int32_t performanceMode, int32_t sharingMode, int32_t routeDeviceId);
39 
40     Result openStream();
41 
42     Result startStream();
43 
44     bool getJavaTimestamp(jobject timestampObj);
45 
46     int getLastErrorCallbackResult();
47 
48     static oboe::ChannelMask javaChannelMaskToOboeChannelMask(int32_t javaMask);
49     static int32_t javaChannelMaskToChannelCount(int32_t javaMask);
50 
51 private:
52     // AudioTimestamp Field IDs
53     JavaVM* mJvm;
54 
55     jfieldID    mFidFramePosition;
56     jfieldID    mFidNanoTime;
57 };
58 
59 #endif // MEGA_PLAYER_OBOEPLAYER_H
60