Mikhail Naganov | 40be06c | 2016-09-27 17:01:34 -0700 | [diff] [blame] | 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 | package android.hardware.audio.effect@2.0; |
| 18 | |
| 19 | import android.hardware.audio.common@2.0; |
| 20 | import IEffect; |
| 21 | |
| 22 | interface IVisualizerEffect extends IEffect { |
Steven Moreland | d26dc50 | 2016-11-29 14:07:27 -0800 | [diff] [blame^] | 23 | enum CaptureSizeRange : int32_t { |
Mikhail Naganov | 40be06c | 2016-09-27 17:01:34 -0700 | [diff] [blame] | 24 | MAX = 1024, // maximum capture size in samples |
| 25 | MIN = 128 // minimum capture size in samples |
| 26 | }; |
| 27 | |
| 28 | /* |
| 29 | * Sets the number PCM samples in the capture. |
| 30 | */ |
| 31 | setCaptureSize(uint16_t captureSize) generates (Result retval); |
| 32 | |
| 33 | /* |
| 34 | * Gets the number PCM samples in the capture. |
| 35 | */ |
| 36 | getCaptureSize() generates (Result retval, uint16_t captureSize); |
| 37 | |
Steven Moreland | d26dc50 | 2016-11-29 14:07:27 -0800 | [diff] [blame^] | 38 | enum ScalingMode : int32_t { |
Mikhail Naganov | 7cbf2f1 | 2016-10-27 20:05:35 -0700 | [diff] [blame] | 39 | // Keep in sync with SCALING_MODE_... in |
Mikhail Naganov | 40be06c | 2016-09-27 17:01:34 -0700 | [diff] [blame] | 40 | // frameworks/base/media/java/android/media/audiofx/Visualizer.java |
Mikhail Naganov | 7cbf2f1 | 2016-10-27 20:05:35 -0700 | [diff] [blame] | 41 | NORMALIZED = 0, |
| 42 | AS_PLAYED = 1 |
Mikhail Naganov | 40be06c | 2016-09-27 17:01:34 -0700 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | /* |
| 46 | * Specifies the way the captured data is scaled. |
| 47 | */ |
| 48 | setScalingMode(ScalingMode scalingMode) generates (Result retval); |
| 49 | |
| 50 | /* |
| 51 | * Retrieves the way the captured data is scaled. |
| 52 | */ |
| 53 | getScalingMode() generates (Result retval, ScalingMode scalingMode); |
| 54 | |
| 55 | /* |
| 56 | * Informs the visualizer about the downstream latency. |
| 57 | */ |
| 58 | setLatency(uint32_t latencyMs) generates (Result retval); |
| 59 | |
| 60 | /* |
| 61 | * Gets the downstream latency. |
| 62 | */ |
| 63 | getLatency() generates (Result retval, uint32_t latencyMs); |
| 64 | |
Steven Moreland | d26dc50 | 2016-11-29 14:07:27 -0800 | [diff] [blame^] | 65 | enum MeasurementMode : int32_t { |
Mikhail Naganov | 7cbf2f1 | 2016-10-27 20:05:35 -0700 | [diff] [blame] | 66 | // Keep in sync with MEASUREMENT_MODE_... in |
Mikhail Naganov | 40be06c | 2016-09-27 17:01:34 -0700 | [diff] [blame] | 67 | // frameworks/base/media/java/android/media/audiofx/Visualizer.java |
Mikhail Naganov | 7cbf2f1 | 2016-10-27 20:05:35 -0700 | [diff] [blame] | 68 | NONE = 0x0, |
| 69 | PEAK_RMS = 0x1 |
Mikhail Naganov | 40be06c | 2016-09-27 17:01:34 -0700 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | /* |
| 73 | * Specifies which measurements are to be made. |
| 74 | */ |
| 75 | setMeasurementMode(MeasurementMode measurementMode) |
| 76 | generates (Result retval); |
| 77 | |
| 78 | /* |
| 79 | * Retrieves which measurements are to be made. |
| 80 | */ |
| 81 | getMeasurementMode() generates ( |
| 82 | Result retval, MeasurementMode measurementMode); |
| 83 | |
| 84 | /* |
| 85 | * Retrieves the latest PCM snapshot captured by the visualizer engine. The |
| 86 | * number of samples to capture is specified by 'setCaptureSize' parameter. |
| 87 | * |
| 88 | * @return retval operation completion status. |
| 89 | * @return samples samples in 8 bit unsigned format (0 = 0x80) |
| 90 | */ |
| 91 | capture() generates (Result retval, vec<uint8_t> samples); |
| 92 | |
| 93 | struct Measurement { |
| 94 | MeasurementMode mode; // discriminator |
| 95 | union Values { |
| 96 | struct PeakAndRms { |
| 97 | int32_t peakMb; // millibels |
| 98 | int32_t rmsMb; // millibels |
| 99 | } peakAndRms; |
Mikhail Naganov | 7cbf2f1 | 2016-10-27 20:05:35 -0700 | [diff] [blame] | 100 | } value; |
Mikhail Naganov | 40be06c | 2016-09-27 17:01:34 -0700 | [diff] [blame] | 101 | }; |
| 102 | /* |
| 103 | * Retrieves the lastest measurements. The measurements to be made |
| 104 | * are specified by 'setMeasurementMode' parameter. |
| 105 | * |
| 106 | * @return retval operation completion status. |
| 107 | * @return result measurement. |
| 108 | */ |
| 109 | measure() generates (Result retval, Measurement result); |
| 110 | }; |