1 // Copyright 2016 The Android Open Source Project
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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.
16 #ifndef BRILLO_AUDIO_AUDIOSERVICE_BRILLO_AUDIO_SERVICE_H_
17 #define BRILLO_AUDIO_AUDIOSERVICE_BRILLO_AUDIO_SERVICE_H_
19 #include "android/brillo/brilloaudioservice/BnBrilloAudioService.h"
25 #include <binder/Status.h>
27 #include "android/brillo/brilloaudioservice/IAudioServiceCallback.h"
28 #include "audio_device_handler.h"
29 #include "audio_volume_handler.h"
31 using android::binder::Status;
32 using android::brillo::brilloaudioservice::BnBrilloAudioService;
33 using android::brillo::brilloaudioservice::IAudioServiceCallback;
37 class BrilloAudioService : public BnBrilloAudioService {
39 virtual ~BrilloAudioService() {}
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;
57 // Register daemon handlers.
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;
65 // Callback to be called when a device is connected.
67 // |devices| is a vector of ints representing the audio_devices_t.
68 virtual void OnDevicesConnected(const std::vector<int>& device) = 0;
70 // Callback to be called when a device is disconnected.
72 // |devices| is a vector of ints representing the audio_devices_t.
73 virtual void OnDevicesDisconnected(const std::vector<int>& device) = 0;
75 // Callback to be called when the volume is changed.
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,
82 int current_index) = 0;
87 #endif // BRILLO_AUDIO_AUDIOSERVICE_BRILLO_AUDIO_SERVICE_H_