1*4d7e907cSAndroid Build Coastguard Worker/* 2*4d7e907cSAndroid Build Coastguard Worker * Copyright (C) 2020 The Android Open Source Project 3*4d7e907cSAndroid Build Coastguard Worker * 4*4d7e907cSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*4d7e907cSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*4d7e907cSAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*4d7e907cSAndroid Build Coastguard Worker * 8*4d7e907cSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*4d7e907cSAndroid Build Coastguard Worker * 10*4d7e907cSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*4d7e907cSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*4d7e907cSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*4d7e907cSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*4d7e907cSAndroid Build Coastguard Worker * limitations under the License. 15*4d7e907cSAndroid Build Coastguard Worker */ 16*4d7e907cSAndroid Build Coastguard Worker 17*4d7e907cSAndroid Build Coastguard Workerpackage [email protected]; 18*4d7e907cSAndroid Build Coastguard Worker 19*4d7e907cSAndroid Build Coastguard Workerimport [email protected]; 20*4d7e907cSAndroid Build Coastguard Workerimport IStream; 21*4d7e907cSAndroid Build Coastguard Workerimport IStreamOutCallback; 22*4d7e907cSAndroid Build Coastguard Workerimport IStreamOutEventCallback; 23*4d7e907cSAndroid Build Coastguard Worker 24*4d7e907cSAndroid Build Coastguard Workerinterface IStreamOut extends IStream { 25*4d7e907cSAndroid Build Coastguard Worker /** 26*4d7e907cSAndroid Build Coastguard Worker * Return the audio hardware driver estimated latency in milliseconds. 27*4d7e907cSAndroid Build Coastguard Worker * 28*4d7e907cSAndroid Build Coastguard Worker * @return latencyMs latency in milliseconds. 29*4d7e907cSAndroid Build Coastguard Worker */ 30*4d7e907cSAndroid Build Coastguard Worker getLatency() generates (uint32_t latencyMs); 31*4d7e907cSAndroid Build Coastguard Worker 32*4d7e907cSAndroid Build Coastguard Worker /** 33*4d7e907cSAndroid Build Coastguard Worker * This method is used in situations where audio mixing is done in the 34*4d7e907cSAndroid Build Coastguard Worker * hardware. This method serves as a direct interface with hardware, 35*4d7e907cSAndroid Build Coastguard Worker * allowing to directly set the volume as apposed to via the framework. 36*4d7e907cSAndroid Build Coastguard Worker * This method might produce multiple PCM outputs or hardware accelerated 37*4d7e907cSAndroid Build Coastguard Worker * codecs, such as MP3 or AAC. 38*4d7e907cSAndroid Build Coastguard Worker * 39*4d7e907cSAndroid Build Coastguard Worker * Optional method 40*4d7e907cSAndroid Build Coastguard Worker * 41*4d7e907cSAndroid Build Coastguard Worker * @param left left channel attenuation, 1.0f is unity, 0.0f is zero. 42*4d7e907cSAndroid Build Coastguard Worker * @param right right channel attenuation, 1.0f is unity, 0.0f is zero. 43*4d7e907cSAndroid Build Coastguard Worker * @return retval operation completion status. 44*4d7e907cSAndroid Build Coastguard Worker * If a volume is outside [0,1], return INVALID_ARGUMENTS 45*4d7e907cSAndroid Build Coastguard Worker */ 46*4d7e907cSAndroid Build Coastguard Worker setVolume(float left, float right) generates (Result retval); 47*4d7e907cSAndroid Build Coastguard Worker 48*4d7e907cSAndroid Build Coastguard Worker /** 49*4d7e907cSAndroid Build Coastguard Worker * Called when the metadata of the stream's source has been changed. 50*4d7e907cSAndroid Build Coastguard Worker * 51*4d7e907cSAndroid Build Coastguard Worker * Optional method 52*4d7e907cSAndroid Build Coastguard Worker * 53*4d7e907cSAndroid Build Coastguard Worker * @param sourceMetadata Description of the audio that is played by the clients. 54*4d7e907cSAndroid Build Coastguard Worker * @return retval operation completion status. 55*4d7e907cSAndroid Build Coastguard Worker * If any of the metadata fields contains an invalid value, 56*4d7e907cSAndroid Build Coastguard Worker * returns INVALID_ARGUMENTS. 57*4d7e907cSAndroid Build Coastguard Worker * If method isn't supported by the HAL returns NOT_SUPPORTED. 58*4d7e907cSAndroid Build Coastguard Worker */ 59*4d7e907cSAndroid Build Coastguard Worker updateSourceMetadata(SourceMetadata sourceMetadata) generates (Result retval); 60*4d7e907cSAndroid Build Coastguard Worker 61*4d7e907cSAndroid Build Coastguard Worker /** 62*4d7e907cSAndroid Build Coastguard Worker * Commands that can be executed on the driver writer thread. 63*4d7e907cSAndroid Build Coastguard Worker */ 64*4d7e907cSAndroid Build Coastguard Worker enum WriteCommand : int32_t { 65*4d7e907cSAndroid Build Coastguard Worker WRITE, 66*4d7e907cSAndroid Build Coastguard Worker GET_PRESENTATION_POSITION, 67*4d7e907cSAndroid Build Coastguard Worker GET_LATENCY 68*4d7e907cSAndroid Build Coastguard Worker }; 69*4d7e907cSAndroid Build Coastguard Worker 70*4d7e907cSAndroid Build Coastguard Worker /** 71*4d7e907cSAndroid Build Coastguard Worker * Data structure passed back to the client via status message queue 72*4d7e907cSAndroid Build Coastguard Worker * of 'write' operation. 73*4d7e907cSAndroid Build Coastguard Worker * 74*4d7e907cSAndroid Build Coastguard Worker * Possible values of 'retval' field: 75*4d7e907cSAndroid Build Coastguard Worker * - OK, write operation was successful; 76*4d7e907cSAndroid Build Coastguard Worker * - INVALID_ARGUMENTS, stream was not configured properly; 77*4d7e907cSAndroid Build Coastguard Worker * - INVALID_STATE, stream is in a state that doesn't allow writes; 78*4d7e907cSAndroid Build Coastguard Worker * - INVALID_OPERATION, retrieving presentation position isn't supported. 79*4d7e907cSAndroid Build Coastguard Worker */ 80*4d7e907cSAndroid Build Coastguard Worker struct WriteStatus { 81*4d7e907cSAndroid Build Coastguard Worker Result retval; 82*4d7e907cSAndroid Build Coastguard Worker WriteCommand replyTo; // discriminator 83*4d7e907cSAndroid Build Coastguard Worker union Reply { 84*4d7e907cSAndroid Build Coastguard Worker uint64_t written; // WRITE command, amount of bytes written, >= 0. 85*4d7e907cSAndroid Build Coastguard Worker struct PresentationPosition { // same as generated by 86*4d7e907cSAndroid Build Coastguard Worker uint64_t frames; // getPresentationPosition. 87*4d7e907cSAndroid Build Coastguard Worker TimeSpec timeStamp; 88*4d7e907cSAndroid Build Coastguard Worker } presentationPosition; 89*4d7e907cSAndroid Build Coastguard Worker uint32_t latencyMs; // Same as generated by getLatency. 90*4d7e907cSAndroid Build Coastguard Worker } reply; 91*4d7e907cSAndroid Build Coastguard Worker }; 92*4d7e907cSAndroid Build Coastguard Worker 93*4d7e907cSAndroid Build Coastguard Worker /** 94*4d7e907cSAndroid Build Coastguard Worker * Set up required transports for passing audio buffers to the driver. 95*4d7e907cSAndroid Build Coastguard Worker * 96*4d7e907cSAndroid Build Coastguard Worker * The transport consists of three message queues: 97*4d7e907cSAndroid Build Coastguard Worker * -- command queue is used to instruct the writer thread what operation 98*4d7e907cSAndroid Build Coastguard Worker * to perform; 99*4d7e907cSAndroid Build Coastguard Worker * -- data queue is used for passing audio data from the client 100*4d7e907cSAndroid Build Coastguard Worker * to the driver; 101*4d7e907cSAndroid Build Coastguard Worker * -- status queue is used for reporting operation status 102*4d7e907cSAndroid Build Coastguard Worker * (e.g. amount of bytes actually written or error code). 103*4d7e907cSAndroid Build Coastguard Worker * 104*4d7e907cSAndroid Build Coastguard Worker * The driver operates on a dedicated thread. The client must ensure that 105*4d7e907cSAndroid Build Coastguard Worker * the thread is given an appropriate priority and assigned to correct 106*4d7e907cSAndroid Build Coastguard Worker * scheduler and cgroup. For this purpose, the method returns the identifier 107*4d7e907cSAndroid Build Coastguard Worker * of the driver thread. 108*4d7e907cSAndroid Build Coastguard Worker * 109*4d7e907cSAndroid Build Coastguard Worker * @param frameSize the size of a single frame, in bytes. 110*4d7e907cSAndroid Build Coastguard Worker * @param framesCount the number of frames in a buffer. 111*4d7e907cSAndroid Build Coastguard Worker * @return retval OK if both message queues were created successfully. 112*4d7e907cSAndroid Build Coastguard Worker * INVALID_STATE if the method was already called. 113*4d7e907cSAndroid Build Coastguard Worker * INVALID_ARGUMENTS if there was a problem setting up 114*4d7e907cSAndroid Build Coastguard Worker * the queues. 115*4d7e907cSAndroid Build Coastguard Worker * @return commandMQ a message queue used for passing commands. 116*4d7e907cSAndroid Build Coastguard Worker * @return dataMQ a message queue used for passing audio data in the format 117*4d7e907cSAndroid Build Coastguard Worker * specified at the stream opening. 118*4d7e907cSAndroid Build Coastguard Worker * @return statusMQ a message queue used for passing status from the driver 119*4d7e907cSAndroid Build Coastguard Worker * using WriteStatus structures. 120*4d7e907cSAndroid Build Coastguard Worker * @return threadId identifier of the driver's dedicated thread; the caller 121*4d7e907cSAndroid Build Coastguard Worker * may adjust the thread priority to match the priority 122*4d7e907cSAndroid Build Coastguard Worker * of the thread that provides audio data. 123*4d7e907cSAndroid Build Coastguard Worker */ 124*4d7e907cSAndroid Build Coastguard Worker prepareForWriting(uint32_t frameSize, uint32_t framesCount) 125*4d7e907cSAndroid Build Coastguard Worker generates ( 126*4d7e907cSAndroid Build Coastguard Worker Result retval, 127*4d7e907cSAndroid Build Coastguard Worker fmq_sync<WriteCommand> commandMQ, 128*4d7e907cSAndroid Build Coastguard Worker fmq_sync<uint8_t> dataMQ, 129*4d7e907cSAndroid Build Coastguard Worker fmq_sync<WriteStatus> statusMQ, 130*4d7e907cSAndroid Build Coastguard Worker int32_t threadId); 131*4d7e907cSAndroid Build Coastguard Worker 132*4d7e907cSAndroid Build Coastguard Worker /** 133*4d7e907cSAndroid Build Coastguard Worker * Return the number of audio frames written by the audio DSP to DAC since 134*4d7e907cSAndroid Build Coastguard Worker * the output has exited standby. 135*4d7e907cSAndroid Build Coastguard Worker * 136*4d7e907cSAndroid Build Coastguard Worker * Optional method 137*4d7e907cSAndroid Build Coastguard Worker * 138*4d7e907cSAndroid Build Coastguard Worker * @return retval operation completion status. 139*4d7e907cSAndroid Build Coastguard Worker * @return dspFrames number of audio frames written. 140*4d7e907cSAndroid Build Coastguard Worker */ 141*4d7e907cSAndroid Build Coastguard Worker getRenderPosition() generates (Result retval, uint32_t dspFrames); 142*4d7e907cSAndroid Build Coastguard Worker 143*4d7e907cSAndroid Build Coastguard Worker /** 144*4d7e907cSAndroid Build Coastguard Worker * Get the local time at which the next write to the audio driver will be 145*4d7e907cSAndroid Build Coastguard Worker * presented. The units are microseconds, where the epoch is decided by the 146*4d7e907cSAndroid Build Coastguard Worker * local audio HAL. 147*4d7e907cSAndroid Build Coastguard Worker * 148*4d7e907cSAndroid Build Coastguard Worker * Optional method 149*4d7e907cSAndroid Build Coastguard Worker * 150*4d7e907cSAndroid Build Coastguard Worker * @return retval operation completion status. 151*4d7e907cSAndroid Build Coastguard Worker * @return timestampUs time of the next write. 152*4d7e907cSAndroid Build Coastguard Worker */ 153*4d7e907cSAndroid Build Coastguard Worker getNextWriteTimestamp() generates (Result retval, int64_t timestampUs); 154*4d7e907cSAndroid Build Coastguard Worker 155*4d7e907cSAndroid Build Coastguard Worker /** 156*4d7e907cSAndroid Build Coastguard Worker * Set the callback interface for notifying completion of non-blocking 157*4d7e907cSAndroid Build Coastguard Worker * write and drain. 158*4d7e907cSAndroid Build Coastguard Worker * 159*4d7e907cSAndroid Build Coastguard Worker * Calling this function implies that all future 'write' and 'drain' 160*4d7e907cSAndroid Build Coastguard Worker * must be non-blocking and use the callback to signal completion. 161*4d7e907cSAndroid Build Coastguard Worker * 162*4d7e907cSAndroid Build Coastguard Worker * 'clearCallback' method needs to be called in order to release the local 163*4d7e907cSAndroid Build Coastguard Worker * callback proxy on the server side and thus dereference the callback 164*4d7e907cSAndroid Build Coastguard Worker * implementation on the client side. 165*4d7e907cSAndroid Build Coastguard Worker * 166*4d7e907cSAndroid Build Coastguard Worker * @return retval operation completion status. 167*4d7e907cSAndroid Build Coastguard Worker */ 168*4d7e907cSAndroid Build Coastguard Worker setCallback(IStreamOutCallback callback) generates (Result retval); 169*4d7e907cSAndroid Build Coastguard Worker 170*4d7e907cSAndroid Build Coastguard Worker /** 171*4d7e907cSAndroid Build Coastguard Worker * Clears the callback previously set via 'setCallback' method. 172*4d7e907cSAndroid Build Coastguard Worker * 173*4d7e907cSAndroid Build Coastguard Worker * Warning: failure to call this method results in callback implementation 174*4d7e907cSAndroid Build Coastguard Worker * on the client side being held until the HAL server termination. 175*4d7e907cSAndroid Build Coastguard Worker * 176*4d7e907cSAndroid Build Coastguard Worker * If no callback was previously set, the method should be a no-op 177*4d7e907cSAndroid Build Coastguard Worker * and return OK. 178*4d7e907cSAndroid Build Coastguard Worker * 179*4d7e907cSAndroid Build Coastguard Worker * @return retval operation completion status: OK or NOT_SUPPORTED. 180*4d7e907cSAndroid Build Coastguard Worker */ 181*4d7e907cSAndroid Build Coastguard Worker clearCallback() generates (Result retval); 182*4d7e907cSAndroid Build Coastguard Worker 183*4d7e907cSAndroid Build Coastguard Worker /** 184*4d7e907cSAndroid Build Coastguard Worker * Set the callback interface for notifying about an output stream event. 185*4d7e907cSAndroid Build Coastguard Worker * 186*4d7e907cSAndroid Build Coastguard Worker * Calling this method with a null pointer will result in releasing 187*4d7e907cSAndroid Build Coastguard Worker * the local callback proxy on the server side and thus dereference 188*4d7e907cSAndroid Build Coastguard Worker * the callback implementation on the client side. 189*4d7e907cSAndroid Build Coastguard Worker * 190*4d7e907cSAndroid Build Coastguard Worker * @return retval operation completion status. 191*4d7e907cSAndroid Build Coastguard Worker */ 192*4d7e907cSAndroid Build Coastguard Worker setEventCallback(IStreamOutEventCallback callback) 193*4d7e907cSAndroid Build Coastguard Worker generates (Result retval); 194*4d7e907cSAndroid Build Coastguard Worker 195*4d7e907cSAndroid Build Coastguard Worker /** 196*4d7e907cSAndroid Build Coastguard Worker * Returns whether HAL supports pausing and resuming of streams. 197*4d7e907cSAndroid Build Coastguard Worker * 198*4d7e907cSAndroid Build Coastguard Worker * @return supportsPause true if pausing is supported. 199*4d7e907cSAndroid Build Coastguard Worker * @return supportsResume true if resume is supported. 200*4d7e907cSAndroid Build Coastguard Worker */ 201*4d7e907cSAndroid Build Coastguard Worker supportsPauseAndResume() 202*4d7e907cSAndroid Build Coastguard Worker generates (bool supportsPause, bool supportsResume); 203*4d7e907cSAndroid Build Coastguard Worker 204*4d7e907cSAndroid Build Coastguard Worker /** 205*4d7e907cSAndroid Build Coastguard Worker * Notifies to the audio driver to stop playback however the queued buffers 206*4d7e907cSAndroid Build Coastguard Worker * are retained by the hardware. Useful for implementing pause/resume. Empty 207*4d7e907cSAndroid Build Coastguard Worker * implementation if not supported however must be implemented for hardware 208*4d7e907cSAndroid Build Coastguard Worker * with non-trivial latency. In the pause state, some audio hardware may 209*4d7e907cSAndroid Build Coastguard Worker * still be using power. Client code may consider calling 'suspend' after a 210*4d7e907cSAndroid Build Coastguard Worker * timeout to prevent that excess power usage. 211*4d7e907cSAndroid Build Coastguard Worker * 212*4d7e907cSAndroid Build Coastguard Worker * Implementation of this function is mandatory for offloaded playback. 213*4d7e907cSAndroid Build Coastguard Worker * 214*4d7e907cSAndroid Build Coastguard Worker * @return retval operation completion status. 215*4d7e907cSAndroid Build Coastguard Worker */ 216*4d7e907cSAndroid Build Coastguard Worker pause() generates (Result retval); 217*4d7e907cSAndroid Build Coastguard Worker 218*4d7e907cSAndroid Build Coastguard Worker /** 219*4d7e907cSAndroid Build Coastguard Worker * Notifies to the audio driver to resume playback following a pause. 220*4d7e907cSAndroid Build Coastguard Worker * Returns error INVALID_STATE if called without matching pause. 221*4d7e907cSAndroid Build Coastguard Worker * 222*4d7e907cSAndroid Build Coastguard Worker * Implementation of this function is mandatory for offloaded playback. 223*4d7e907cSAndroid Build Coastguard Worker * 224*4d7e907cSAndroid Build Coastguard Worker * @return retval operation completion status. 225*4d7e907cSAndroid Build Coastguard Worker */ 226*4d7e907cSAndroid Build Coastguard Worker resume() generates (Result retval); 227*4d7e907cSAndroid Build Coastguard Worker 228*4d7e907cSAndroid Build Coastguard Worker /** 229*4d7e907cSAndroid Build Coastguard Worker * Returns whether HAL supports draining of streams. 230*4d7e907cSAndroid Build Coastguard Worker * 231*4d7e907cSAndroid Build Coastguard Worker * @return supports true if draining is supported. 232*4d7e907cSAndroid Build Coastguard Worker */ 233*4d7e907cSAndroid Build Coastguard Worker supportsDrain() generates (bool supports); 234*4d7e907cSAndroid Build Coastguard Worker 235*4d7e907cSAndroid Build Coastguard Worker /** 236*4d7e907cSAndroid Build Coastguard Worker * Requests notification when data buffered by the driver/hardware has been 237*4d7e907cSAndroid Build Coastguard Worker * played. If 'setCallback' has previously been called to enable 238*4d7e907cSAndroid Build Coastguard Worker * non-blocking mode, then 'drain' must not block, instead it must return 239*4d7e907cSAndroid Build Coastguard Worker * quickly and completion of the drain is notified through the callback. If 240*4d7e907cSAndroid Build Coastguard Worker * 'setCallback' has not been called, then 'drain' must block until 241*4d7e907cSAndroid Build Coastguard Worker * completion. 242*4d7e907cSAndroid Build Coastguard Worker * 243*4d7e907cSAndroid Build Coastguard Worker * If 'type' is 'ALL', the drain completes when all previously written data 244*4d7e907cSAndroid Build Coastguard Worker * has been played. 245*4d7e907cSAndroid Build Coastguard Worker * 246*4d7e907cSAndroid Build Coastguard Worker * If 'type' is 'EARLY_NOTIFY', the drain completes shortly before all data 247*4d7e907cSAndroid Build Coastguard Worker * for the current track has played to allow time for the framework to 248*4d7e907cSAndroid Build Coastguard Worker * perform a gapless track switch. 249*4d7e907cSAndroid Build Coastguard Worker * 250*4d7e907cSAndroid Build Coastguard Worker * Drain must return immediately on 'stop' and 'flush' calls. 251*4d7e907cSAndroid Build Coastguard Worker * 252*4d7e907cSAndroid Build Coastguard Worker * Implementation of this function is mandatory for offloaded playback. 253*4d7e907cSAndroid Build Coastguard Worker * 254*4d7e907cSAndroid Build Coastguard Worker * @param type type of drain. 255*4d7e907cSAndroid Build Coastguard Worker * @return retval operation completion status. 256*4d7e907cSAndroid Build Coastguard Worker */ 257*4d7e907cSAndroid Build Coastguard Worker drain(AudioDrain type) generates (Result retval); 258*4d7e907cSAndroid Build Coastguard Worker 259*4d7e907cSAndroid Build Coastguard Worker /** 260*4d7e907cSAndroid Build Coastguard Worker * Notifies to the audio driver to flush (that is, drop) the queued 261*4d7e907cSAndroid Build Coastguard Worker * data. Stream must already be paused before calling 'flush'. For 262*4d7e907cSAndroid Build Coastguard Worker * compressed and offload streams the frame count returned by 263*4d7e907cSAndroid Build Coastguard Worker * 'getPresentationPosition' must reset after flush. 264*4d7e907cSAndroid Build Coastguard Worker * 265*4d7e907cSAndroid Build Coastguard Worker * Optional method 266*4d7e907cSAndroid Build Coastguard Worker * 267*4d7e907cSAndroid Build Coastguard Worker * Implementation of this function is mandatory for offloaded playback. 268*4d7e907cSAndroid Build Coastguard Worker * 269*4d7e907cSAndroid Build Coastguard Worker * @return retval operation completion status. 270*4d7e907cSAndroid Build Coastguard Worker */ 271*4d7e907cSAndroid Build Coastguard Worker flush() generates (Result retval); 272*4d7e907cSAndroid Build Coastguard Worker 273*4d7e907cSAndroid Build Coastguard Worker /** 274*4d7e907cSAndroid Build Coastguard Worker * Return a recent count of the number of audio frames presented to an 275*4d7e907cSAndroid Build Coastguard Worker * external observer. This excludes frames which have been written but are 276*4d7e907cSAndroid Build Coastguard Worker * still in the pipeline. The count must not reset to zero when a PCM output 277*4d7e907cSAndroid Build Coastguard Worker * enters standby. For compressed and offload streams it is recommended that 278*4d7e907cSAndroid Build Coastguard Worker * HAL resets the frame count. 279*4d7e907cSAndroid Build Coastguard Worker * 280*4d7e907cSAndroid Build Coastguard Worker * This method also returns the value of CLOCK_MONOTONIC as of this 281*4d7e907cSAndroid Build Coastguard Worker * presentation count. The returned count is expected to be 'recent', but 282*4d7e907cSAndroid Build Coastguard Worker * does not need to be the most recent possible value. However, the 283*4d7e907cSAndroid Build Coastguard Worker * associated time must correspond to whatever count is returned. 284*4d7e907cSAndroid Build Coastguard Worker * Example: assume that N+M frames have been presented, where M is a 'small' 285*4d7e907cSAndroid Build Coastguard Worker * number. Then it is permissible to return N instead of N+M, and the 286*4d7e907cSAndroid Build Coastguard Worker * timestamp must correspond to N rather than N+M. The terms 'recent' and 287*4d7e907cSAndroid Build Coastguard Worker * 'small' are not defined. They reflect the quality of the implementation. 288*4d7e907cSAndroid Build Coastguard Worker * 289*4d7e907cSAndroid Build Coastguard Worker * @return retval operation completion status. 290*4d7e907cSAndroid Build Coastguard Worker * @return frames count of presented audio frames. 291*4d7e907cSAndroid Build Coastguard Worker * @return timeStamp associated clock time. 292*4d7e907cSAndroid Build Coastguard Worker */ 293*4d7e907cSAndroid Build Coastguard Worker getPresentationPosition() 294*4d7e907cSAndroid Build Coastguard Worker generates (Result retval, uint64_t frames, TimeSpec timeStamp); 295*4d7e907cSAndroid Build Coastguard Worker 296*4d7e907cSAndroid Build Coastguard Worker /** 297*4d7e907cSAndroid Build Coastguard Worker * Selects a presentation for decoding from a next generation media stream 298*4d7e907cSAndroid Build Coastguard Worker * (as defined per ETSI TS 103 190-2) and a program within the presentation. 299*4d7e907cSAndroid Build Coastguard Worker * 300*4d7e907cSAndroid Build Coastguard Worker * Optional method 301*4d7e907cSAndroid Build Coastguard Worker * 302*4d7e907cSAndroid Build Coastguard Worker * @param presentationId selected audio presentation. 303*4d7e907cSAndroid Build Coastguard Worker * @param programId refinement for the presentation. 304*4d7e907cSAndroid Build Coastguard Worker * @return retval operation completion status. 305*4d7e907cSAndroid Build Coastguard Worker */ 306*4d7e907cSAndroid Build Coastguard Worker selectPresentation(int32_t presentationId, int32_t programId) 307*4d7e907cSAndroid Build Coastguard Worker generates (Result retval); 308*4d7e907cSAndroid Build Coastguard Worker 309*4d7e907cSAndroid Build Coastguard Worker /** 310*4d7e907cSAndroid Build Coastguard Worker * Returns the Dual Mono mode presentation setting. 311*4d7e907cSAndroid Build Coastguard Worker * 312*4d7e907cSAndroid Build Coastguard Worker * Optional method 313*4d7e907cSAndroid Build Coastguard Worker * 314*4d7e907cSAndroid Build Coastguard Worker * @return retval operation completion status. 315*4d7e907cSAndroid Build Coastguard Worker * @return mode current setting of Dual Mono mode. 316*4d7e907cSAndroid Build Coastguard Worker */ 317*4d7e907cSAndroid Build Coastguard Worker getDualMonoMode() generates (Result retval, DualMonoMode mode); 318*4d7e907cSAndroid Build Coastguard Worker 319*4d7e907cSAndroid Build Coastguard Worker /** 320*4d7e907cSAndroid Build Coastguard Worker * Sets the Dual Mono mode presentation on the output device. 321*4d7e907cSAndroid Build Coastguard Worker * 322*4d7e907cSAndroid Build Coastguard Worker * The Dual Mono mode is generally applied to stereo audio streams 323*4d7e907cSAndroid Build Coastguard Worker * where the left and right channels come from separate sources. 324*4d7e907cSAndroid Build Coastguard Worker * 325*4d7e907cSAndroid Build Coastguard Worker * Optional method 326*4d7e907cSAndroid Build Coastguard Worker * 327*4d7e907cSAndroid Build Coastguard Worker * @param mode selected Dual Mono mode. 328*4d7e907cSAndroid Build Coastguard Worker * @return retval operation completion status. 329*4d7e907cSAndroid Build Coastguard Worker */ 330*4d7e907cSAndroid Build Coastguard Worker setDualMonoMode(DualMonoMode mode) generates (Result retval); 331*4d7e907cSAndroid Build Coastguard Worker 332*4d7e907cSAndroid Build Coastguard Worker /** 333*4d7e907cSAndroid Build Coastguard Worker * Returns the Audio Description Mix level in dB. 334*4d7e907cSAndroid Build Coastguard Worker * 335*4d7e907cSAndroid Build Coastguard Worker * The level is applied to streams incorporating a secondary Audio 336*4d7e907cSAndroid Build Coastguard Worker * Description stream. It specifies the relative level of mixing for 337*4d7e907cSAndroid Build Coastguard Worker * the Audio Description with a reference to the Main Audio. 338*4d7e907cSAndroid Build Coastguard Worker * 339*4d7e907cSAndroid Build Coastguard Worker * Optional method 340*4d7e907cSAndroid Build Coastguard Worker * 341*4d7e907cSAndroid Build Coastguard Worker * The value of the relative level is in the range from negative infinity 342*4d7e907cSAndroid Build Coastguard Worker * to +48. 343*4d7e907cSAndroid Build Coastguard Worker * 344*4d7e907cSAndroid Build Coastguard Worker * @return retval operation completion status. 345*4d7e907cSAndroid Build Coastguard Worker * @return leveldB the current Audio Description Mix Level in dB. 346*4d7e907cSAndroid Build Coastguard Worker */ 347*4d7e907cSAndroid Build Coastguard Worker getAudioDescriptionMixLevel() generates (Result retval, float leveldB); 348*4d7e907cSAndroid Build Coastguard Worker 349*4d7e907cSAndroid Build Coastguard Worker /** 350*4d7e907cSAndroid Build Coastguard Worker * Sets the Audio Description Mix level in dB. 351*4d7e907cSAndroid Build Coastguard Worker * 352*4d7e907cSAndroid Build Coastguard Worker * For streams incorporating a secondary Audio Description stream 353*4d7e907cSAndroid Build Coastguard Worker * the relative level of mixing of the Audio Description to the Main Audio 354*4d7e907cSAndroid Build Coastguard Worker * is controlled by this method. 355*4d7e907cSAndroid Build Coastguard Worker * 356*4d7e907cSAndroid Build Coastguard Worker * Optional method 357*4d7e907cSAndroid Build Coastguard Worker * 358*4d7e907cSAndroid Build Coastguard Worker * The value of the relative level must be in the range from negative 359*4d7e907cSAndroid Build Coastguard Worker * infinity to +48. 360*4d7e907cSAndroid Build Coastguard Worker * 361*4d7e907cSAndroid Build Coastguard Worker * @param leveldB Audio Description Mix Level in dB 362*4d7e907cSAndroid Build Coastguard Worker * @return retval operation completion status. 363*4d7e907cSAndroid Build Coastguard Worker */ 364*4d7e907cSAndroid Build Coastguard Worker setAudioDescriptionMixLevel(float leveldB) generates (Result retval); 365*4d7e907cSAndroid Build Coastguard Worker 366*4d7e907cSAndroid Build Coastguard Worker /** 367*4d7e907cSAndroid Build Coastguard Worker * Retrieves current playback rate parameters. 368*4d7e907cSAndroid Build Coastguard Worker * 369*4d7e907cSAndroid Build Coastguard Worker * Optional method 370*4d7e907cSAndroid Build Coastguard Worker * 371*4d7e907cSAndroid Build Coastguard Worker * @return retval operation completion status. 372*4d7e907cSAndroid Build Coastguard Worker * @return playbackRate current playback parameters 373*4d7e907cSAndroid Build Coastguard Worker */ 374*4d7e907cSAndroid Build Coastguard Worker getPlaybackRateParameters() 375*4d7e907cSAndroid Build Coastguard Worker generates (Result retval, PlaybackRate playbackRate); 376*4d7e907cSAndroid Build Coastguard Worker 377*4d7e907cSAndroid Build Coastguard Worker /** 378*4d7e907cSAndroid Build Coastguard Worker * Sets the playback rate parameters that control playback behavior. 379*4d7e907cSAndroid Build Coastguard Worker * This is normally used when playing encoded content and decoding 380*4d7e907cSAndroid Build Coastguard Worker * is performed in hardware. Otherwise, the framework can apply 381*4d7e907cSAndroid Build Coastguard Worker * necessary transformations. 382*4d7e907cSAndroid Build Coastguard Worker * 383*4d7e907cSAndroid Build Coastguard Worker * Optional method 384*4d7e907cSAndroid Build Coastguard Worker * 385*4d7e907cSAndroid Build Coastguard Worker * If the HAL supports setting the playback rate, it is recommended 386*4d7e907cSAndroid Build Coastguard Worker * to support speed and pitch values at least in the range 387*4d7e907cSAndroid Build Coastguard Worker * from 0.5f to 2.0f, inclusive (see the definition of PlaybackRate struct). 388*4d7e907cSAndroid Build Coastguard Worker * 389*4d7e907cSAndroid Build Coastguard Worker * @param playbackRate playback parameters 390*4d7e907cSAndroid Build Coastguard Worker * @return retval operation completion status. 391*4d7e907cSAndroid Build Coastguard Worker */ 392*4d7e907cSAndroid Build Coastguard Worker setPlaybackRateParameters(PlaybackRate playbackRate) 393*4d7e907cSAndroid Build Coastguard Worker generates (Result retval); 394*4d7e907cSAndroid Build Coastguard Worker}; 395