Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 226939c6 authored by Eric Laurent's avatar Eric Laurent Committed by Android (Google) Code Review
Browse files

Merge "Public API changes for audio offload support."

parents 25d729c3 ad3af330
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -128,7 +128,9 @@ public:
    // - BAD_VALUE: invalid parameter
    // NOTE: this feature is not supported on all hardware platforms and it is
    // necessary to check returned status before using the returned values.
    static status_t getRenderPosition(size_t *halFrames, size_t *dspFrames,
    static status_t getRenderPosition(audio_io_handle_t output,
                                      size_t *halFrames,
                                      size_t *dspFrames,
                                      audio_stream_type_t stream = AUDIO_STREAM_DEFAULT);

    // return the number of input frames lost by HAL implementation, or 0 if the handle is invalid
@@ -197,7 +199,8 @@ public:
                                        uint32_t samplingRate = 0,
                                        audio_format_t format = AUDIO_FORMAT_DEFAULT,
                                        audio_channel_mask_t channelMask = AUDIO_CHANNEL_OUT_STEREO,
                                        audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE);
                                        audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE,
                                        const audio_offload_info_t *offloadInfo = NULL);
    static status_t startOutput(audio_io_handle_t output,
                                audio_stream_type_t stream,
                                int session = 0);
@@ -245,6 +248,10 @@ public:
    static uint32_t getPrimaryOutputSamplingRate();
    static size_t getPrimaryOutputFrameCount();

    // Check if hw offload is possible for given format, stream type, sample rate,
    // bit rate, duration, video and streaming or offload property is enabled
    static bool isOffloadSupported(const audio_offload_info_t& info);

    // ----------------------------------------------------------------------------

private:
+31 −3
Original line number Diff line number Diff line
@@ -60,6 +60,8 @@ public:
                                    // Not currently used by android.media.AudioTrack.
        EVENT_NEW_IAUDIOTRACK = 6,  // IAudioTrack was re-created, either due to re-routing and
                                    // voluntary invalidation by mediaserver, or mediaserver crash.
        EVENT_STREAM_END = 7,       // Sent after all the buffers queued in AF and HW are played
                                    // back (after stop is called)
    };

    /* Client should declare Buffer on the stack and pass address to obtainBuffer()
@@ -175,7 +177,8 @@ public:
                                    void* user           = NULL,
                                    int notificationFrames = 0,
                                    int sessionId        = 0,
                                    transfer_type transferType = TRANSFER_DEFAULT);
                                    transfer_type transferType = TRANSFER_DEFAULT,
                                    const audio_offload_info_t *offloadInfo = NULL);

    /* Creates an audio track and registers it with AudioFlinger.
     * With this constructor, the track is configured for static buffer mode.
@@ -198,7 +201,8 @@ public:
                                    void* user          = NULL,
                                    int notificationFrames = 0,
                                    int sessionId       = 0,
                                    transfer_type transferType = TRANSFER_DEFAULT);
                                    transfer_type transferType = TRANSFER_DEFAULT,
                                    const audio_offload_info_t *offloadInfo = NULL);

    /* Terminates the AudioTrack and unregisters it from AudioFlinger.
     * Also destroys all resources associated with the AudioTrack.
@@ -233,7 +237,8 @@ public:
                            const sp<IMemory>& sharedBuffer = 0,
                            bool threadCanCallJava = false,
                            int sessionId       = 0,
                            transfer_type transferType = TRANSFER_DEFAULT);
                            transfer_type transferType = TRANSFER_DEFAULT,
                            const audio_offload_info_t *offloadInfo = NULL);

    /* Result of constructing the AudioTrack. This must be checked
     * before using any AudioTrack API (except for set()), because using
@@ -521,6 +526,15 @@ private:
                                     struct timespec *elapsed = NULL, size_t *nonContig = NULL);
public:

//EL_FIXME to be reconciled with new obtainBuffer() return codes and control block proxy
//            enum {
//            NO_MORE_BUFFERS = 0x80000001,   // same name in AudioFlinger.h, ok to be different value
//            TEAR_DOWN       = 0x80000002,
//            STOPPED = 1,
//            STREAM_END_WAIT,
//            STREAM_END
//        };

    /* Release a filled buffer of "audioBuffer->frameCount" frames for AudioFlinger to process. */
    // FIXME make private when obtainBuffer() for TRANSFER_OBTAIN is removed
            void        releaseBuffer(Buffer* audioBuffer);
@@ -550,6 +564,15 @@ public:
     */
            uint32_t    getUnderrunFrames() const;

    /* Get the flags */
            audio_output_flags_t getFlags() const { return mFlags; }

    /* Set parameters - only possible when using direct output */
            status_t    setParameters(const String8& keyValuePairs);

    /* Get parameters */
            String8     getParameters(const String8& keys);

protected:
    /* copying audio tracks is not allowed */
                        AudioTrack(const AudioTrack& other);
@@ -590,8 +613,11 @@ protected:
            //      NS_NEVER    never again
            static const nsecs_t NS_WHENEVER = -1, NS_INACTIVE = -2, NS_NEVER = -3;
            nsecs_t processAudioBuffer(const sp<AudioTrackThread>& thread);
            status_t processStreamEnd(int32_t waitCount);


            // caller must hold lock on mLock for all _l methods

            status_t createTrack_l(audio_stream_type_t streamType,
                                 uint32_t sampleRate,
                                 audio_format_t format,
@@ -607,6 +633,8 @@ protected:
            void setLoop_l(uint32_t loopStart, uint32_t loopEnd, int loopCount);
            audio_io_handle_t getOutput_l();

            status_t getPosition_l(uint32_t *position);

            // FIXME enum is faster than strcmp() for parameter 'from'
            status_t restoreTrack_l(const char *from);

+3 −1
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ public:
        TRACK_DEFAULT = 0,  // client requests a default AudioTrack
        TRACK_TIMED   = 1,  // client requests a TimedAudioTrack
        TRACK_FAST    = 2,  // client requests a fast AudioTrack or AudioRecord
        TRACK_OFFLOAD = 4,  // client requests offload to hw codec
    };
    typedef uint32_t track_flags_t;

@@ -137,7 +138,8 @@ public:
                                         audio_format_t *pFormat,
                                         audio_channel_mask_t *pChannelMask,
                                         uint32_t *pLatencyMs,
                                         audio_output_flags_t flags) = 0;
                                         audio_output_flags_t flags,
                                         const audio_offload_info_t *offloadInfo = NULL) = 0;
    virtual audio_io_handle_t openDuplicateOutput(audio_io_handle_t output1,
                                    audio_io_handle_t output2) = 0;
    virtual status_t closeOutput(audio_io_handle_t output) = 0;
+5 −1
Original line number Diff line number Diff line
@@ -53,7 +53,8 @@ public:
                                        uint32_t samplingRate = 0,
                                        audio_format_t format = AUDIO_FORMAT_DEFAULT,
                                        audio_channel_mask_t channelMask = 0,
                                        audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE) = 0;
                                        audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE,
                                        const audio_offload_info_t *offloadInfo = NULL) = 0;
    virtual status_t startOutput(audio_io_handle_t output,
                                 audio_stream_type_t stream,
                                 int session = 0) = 0;
@@ -95,6 +96,9 @@ public:
    virtual status_t queryDefaultPreProcessing(int audioSession,
                                              effect_descriptor_t *descriptors,
                                              uint32_t *count) = 0;
   // Check if offload is possible for given format, stream type, sample rate,
    // bit rate, duration, video and streaming or offload property is enabled
    virtual bool isOffloadSupported(const audio_offload_info_t& info) = 0;
};


+4 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
#include <binder/IInterface.h>
#include <binder/IMemory.h>
#include <utils/LinearTransform.h>
#include <utils/String8.h>

namespace android {

@@ -82,6 +83,9 @@ public:
       or Tungsten time. The values for target are defined in AudioTrack.h */
    virtual status_t    setMediaTimeTransform(const LinearTransform& xform,
                                              int target) = 0;

    /* Send parameters to the audio hardware */
    virtual status_t    setParameters(const String8& keyValuePairs) = 0;
};

// ----------------------------------------------------------------------------
Loading