• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 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 __ANDROID_TRACK_PLAYER_BASE_H__
18 #define __ANDROID_TRACK_PLAYER_BASE_H__
19 
20 #include <media/AudioTrack.h>
21 #include <media/PlayerBase.h>
22 
23 namespace android {
24 
25 class TrackPlayerBase : public PlayerBase
26 {
27 public:
28     explicit TrackPlayerBase();
29     virtual ~TrackPlayerBase();
30 
31     void init(const sp<AudioTrack>& pat, const sp<AudioTrack::IAudioTrackCallback>& callback,
32               player_type_t playerType, audio_usage_t usage, audio_session_t sessionId);
33     virtual void destroy();
34 
35     //IPlayer implementation
36     virtual binder::Status applyVolumeShaper(
37             const media::VolumeShaperConfiguration& configuration,
38             const media::VolumeShaperOperation& operation);
39 
40     //FIXME move to protected field, so far made public to minimize changes to AudioTrack logic
41     sp<AudioTrack> mAudioTrack;
42 
43             void setPlayerVolume(float vl, float vr);
44 
45 protected:
46 
47     //PlayerBase virtuals
48     virtual status_t playerStart();
49     virtual status_t playerPause();
50     virtual status_t playerStop();
51     virtual status_t playerSetVolume();
52 
53 private:
54             void doDestroy();
55             status_t doSetVolume();
56 
57             class SelfAudioDeviceCallback : public AudioSystem::AudioDeviceCallback {
58             public:
59                 SelfAudioDeviceCallback(PlayerBase& self);
60                 virtual void onAudioDeviceUpdate(audio_io_handle_t audioIo,
61                                                          audio_port_handle_t deviceId);
62             private:
63                 virtual ~SelfAudioDeviceCallback();
64                 PlayerBase& mSelf;
65             };
66 
67     // volume coming from the player volume API
68     float mPlayerVolumeL, mPlayerVolumeR;
69     sp<AudioTrack::IAudioTrackCallback> mCallbackHandle;
70     sp<SelfAudioDeviceCallback> mSelfAudioDeviceCallback;
71 };
72 
73 } // namespace android
74 
75 #endif /* __ANDROID_TRACK_PLAYER_BASE_H__ */
76