1 /*
2  * Copyright (C) 2016 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 
18 package android.brillo.brilloaudioservice;
19 
20 import android.brillo.brilloaudioservice.IAudioServiceCallback;
21 
22 /*
23  * Interface for BrilloAudioService that clients can use to get the list of
24  * devices currently connected to the system as well as to control volume.
25  * Clients can also register callbacks to be notified about changes.
26  */
27 interface IBrilloAudioService {
28   // Constants for device enumeration.
29   const int GET_DEVICES_INPUTS = 1;
30   const int GET_DEVICES_OUTPUTS = 2;
31 
32   // Constants for volume control.
33   const int VOLUME_BUTTON_PRESS_DOWN = 1;
34   const int VOLUME_BUTTON_PRESS_UP = 2;
35 
36   // Get the list of devices connected. If flag is GET_DEVICES_INPUTS, then
37   // return input devices. Otherwise, return output devices.
GetDevices(int flag)38   int[] GetDevices(int flag);
39 
40   // Set device for a given usage.
41   // usage is an int of type audio_policy_force_use_t.
42   // config is an int of type audio_policy_forced_cfg_t.
SetDevice(int usage, int config)43   void SetDevice(int usage, int config);
44 
45   // Get the maximum number of steps used for a given stream.
GetMaxVolumeSteps(int stream)46   int GetMaxVolumeSteps(int stream);
47 
48   // Set the maximum number of steps to use for a given stream.
SetMaxVolumeSteps(int stream, int max_steps)49   void SetMaxVolumeSteps(int stream, int max_steps);
50 
51   // Set the volume for a given (stream, device) tuple.
SetVolumeIndex(int stream, int device, int index)52   void SetVolumeIndex(int stream, int device, int index);
53 
54   // Get the current volume for a given (stream, device) tuple.
GetVolumeIndex(int stream, int device)55   int GetVolumeIndex(int stream, int device);
56 
57   // Get stream used when volume buttons are pressed.
GetVolumeControlStream()58   int GetVolumeControlStream();
59 
60   // Set default stream to use when volume buttons are pressed.
SetVolumeControlStream(int stream)61   void SetVolumeControlStream(int stream);
62 
63   // Increment volume.
IncrementVolume()64   void IncrementVolume();
65 
66   // Decrement volume.
DecrementVolume()67   void DecrementVolume();
68 
69   // Register a callback object with the service.
RegisterServiceCallback(IAudioServiceCallback callback)70   void RegisterServiceCallback(IAudioServiceCallback callback);
71 
72   // Unregister a callback object.
UnregisterServiceCallback(IAudioServiceCallback callback)73   void UnregisterServiceCallback(IAudioServiceCallback callback);
74 }
75