OSDN Git Service

Merge commit 'f9e3022c474619c69a46ae7dbe11b5b531dbad57' into am-0d58d39a-0539-474e...
[android-x86/system-media.git] / brillo / audio / audioservice / brillo_audio_service.h
1 // Copyright 2016 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 //
15
16 #ifndef BRILLO_AUDIO_AUDIOSERVICE_BRILLO_AUDIO_SERVICE_H_
17 #define BRILLO_AUDIO_AUDIOSERVICE_BRILLO_AUDIO_SERVICE_H_
18
19 #include "android/brillo/brilloaudioservice/BnBrilloAudioService.h"
20
21 #include <memory>
22 #include <set>
23 #include <vector>
24
25 #include <binder/Status.h>
26
27 #include "android/brillo/brilloaudioservice/IAudioServiceCallback.h"
28 #include "audio_device_handler.h"
29 #include "audio_volume_handler.h"
30
31 using android::binder::Status;
32 using android::brillo::brilloaudioservice::BnBrilloAudioService;
33 using android::brillo::brilloaudioservice::IAudioServiceCallback;
34
35 namespace brillo {
36
37 class BrilloAudioService : public BnBrilloAudioService {
38  public:
39   virtual ~BrilloAudioService() {}
40
41   // From AIDL.
42   virtual Status GetDevices(int flag, std::vector<int>* _aidl_return) = 0;
43   virtual Status SetDevice(int usage, int config) = 0;
44   virtual Status GetMaxVolumeSteps(int stream, int* _aidl_return) = 0;
45   virtual Status SetMaxVolumeSteps(int stream, int max_steps) = 0;
46   virtual Status SetVolumeIndex(int stream, int device, int index) = 0;
47   virtual Status GetVolumeIndex(int stream, int device, int* _aidl_return) = 0;
48   virtual Status GetVolumeControlStream(int* _aidl_return) = 0;
49   virtual Status SetVolumeControlStream(int stream) = 0;
50   virtual Status IncrementVolume() = 0;
51   virtual Status DecrementVolume() = 0;
52   virtual Status RegisterServiceCallback(
53       const android::sp<IAudioServiceCallback>& callback) = 0;
54   virtual Status UnregisterServiceCallback(
55       const android::sp<IAudioServiceCallback>& callback) = 0;
56
57   // Register daemon handlers.
58   //
59   // |audio_device_handler| is a weak pointer to an audio device handler object.
60   // |audio_volume_handler| is a weak pointer to an audio volume handler object.
61   virtual void RegisterHandlers(
62       std::weak_ptr<AudioDeviceHandler> audio_device_handler,
63       std::weak_ptr<AudioVolumeHandler> audio_volume_handler) = 0;
64
65   // Callback to be called when a device is connected.
66   //
67   // |devices| is a vector of ints representing the audio_devices_t.
68   virtual void OnDevicesConnected(const std::vector<int>& device) = 0;
69
70   // Callback to be called when a device is disconnected.
71   //
72   // |devices| is a vector of ints representing the audio_devices_t.
73   virtual void OnDevicesDisconnected(const std::vector<int>& device) = 0;
74
75   // Callback to be called when the volume is changed.
76   //
77   // |stream| is an audio_stream_type_t representing the stream.
78   // |previous_index| is the volume index before the key press.
79   // |current_index| is the volume index after the key press.
80   virtual void OnVolumeChanged(audio_stream_type_t stream,
81                                int previous_index,
82                                int current_index) = 0;
83 };
84
85 }  // namespace brillo
86
87 #endif  // BRILLO_AUDIO_AUDIOSERVICE_BRILLO_AUDIO_SERVICE_H_