blob: 9a96f71df4419add997c3911a445ef658749aee2 [file] [log] [blame]
Mikhail Naganov96b30be2016-10-05 11:21:12 -07001/*
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
17package android.hardware.audio@2.0;
18
19import android.hardware.audio.common@2.0;
20import IStream;
21
22interface IStreamIn extends IStream {
23 typedef android.hardware.audio@2.0::Result Result;
24
25 /*
26 * Returns the source descriptor of the input stream. Calling this method is
27 * equivalent to getting AUDIO_PARAMETER_STREAM_INPUT_SOURCE on the legacy
28 * HAL.
29 *
30 * @return retval operation completion status.
31 * @return source audio source.
32 */
33 getAudioSource() generates (Result retval, AudioSource source);
34
35 /*
36 * Set the input gain for the audio driver.
37 *
38 * @param gain 1.0f is unity, 0.0f is zero.
39 * @result retval operation completion status.
40 */
41 setGain(float gain) generates (Result retval);
42
43 /*
Mikhail Naganovb29438e2016-12-22 09:21:34 -080044 * Data structure passed back to the client via status message queue
45 * of 'read' operation.
Mikhail Naganov96b30be2016-10-05 11:21:12 -070046 *
Mikhail Naganovb29438e2016-12-22 09:21:34 -080047 * Possible values of 'retval' field:
48 * - OK, read operation was successful;
49 * - INVALID_ARGUMENTS, stream was not configured properly;
50 * - INVALID_STATE, stream is in a state that doesn't allow reads.
Mikhail Naganov96b30be2016-10-05 11:21:12 -070051 */
Mikhail Naganovb29438e2016-12-22 09:21:34 -080052 struct ReadStatus {
53 Result retval;
54 uint64_t read;
55 };
56
57 /*
58 * Set up required transports for receiving audio buffers from the driver.
59 *
60 * The transport consists of two message queues: one is used for passing
61 * audio data from the driver to the client, another is used for reporting
62 * read operation status (amount of bytes actually read or error code),
63 * see ReadStatus structure definition.
64 *
65 * @param frameSize the size of a single frame, in bytes.
66 * @param framesCount the number of frames in a buffer.
67 * @param threadPriority priority of the thread that performs reads.
68 * @return retval OK if both message queues were created successfully.
69 * INVALID_STATE if the method was already called.
70 * INVALID_ARGUMENTS if there was a problem setting up
71 * the queues.
72 * @return dataMQ a message queue used for passing audio data in the format
73 * specified at the stream opening.
74 * @return statusMQ a message queue used for passing status from the driver
75 * using ReadStatus structures.
76 */
77 prepareForReading(
78 uint32_t frameSize, uint32_t framesCount,
79 ThreadPriority threadPriority)
80 generates (
81 Result retval,
82 fmq_sync<uint8_t> dataMQ, fmq_sync<ReadStatus> statusMQ);
Mikhail Naganov96b30be2016-10-05 11:21:12 -070083
84 /*
85 * Return the amount of input frames lost in the audio driver since the last
86 * call of this function.
87 *
88 * Audio driver is expected to reset the value to 0 and restart counting
89 * upon returning the current value by this function call. Such loss
90 * typically occurs when the user space process is blocked longer than the
91 * capacity of audio driver buffers.
92 *
Mikhail Naganov96b30be2016-10-05 11:21:12 -070093 * @return framesLost the number of input audio frames lost.
94 */
Mikhail Naganov10548292016-10-31 10:39:47 -070095 getInputFramesLost() generates (uint32_t framesLost);
Mikhail Naganov96b30be2016-10-05 11:21:12 -070096
97 /**
98 * Return a recent count of the number of audio frames received and the
99 * clock time associated with that frame count.
100 *
101 * @return retval INVALID_STATE if the device is not ready/available,
102 * NOT_SUPPORTED if the command is not supported,
103 * OK otherwise.
104 * @return frames the total frame count received. This must be as early in
105 * the capture pipeline as possible. In general, frames
106 * must be non-negative and must not go "backwards".
107 * @return time is the clock monotonic time when frames was measured. In
108 * general, time must be a positive quantity and must not
109 * go "backwards".
110 */
111 getCapturePosition()
112 generates (Result retval, uint64_t frames, uint64_t time);
113};