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

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

Merge "Add support for deep audio buffers"

parents fc554559 1948eb3e
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -63,6 +63,9 @@ enum player_type {
// when the channel mask isn't known, use the channel count to derive a mask in AudioSink::open()
#define CHANNEL_MASK_USE_CHANNEL_ORDER 0

// duration below which we do not allow deep audio buffering
#define AUDIO_SINK_MIN_DEEP_BUFFER_DURATION_US 5000000

// callback mechanism for passing messages to MediaPlayer object
typedef void (*notify_callback_f)(void* cookie,
        int msg, int ext1, int ext2, const Parcel *obj);
@@ -98,7 +101,8 @@ public:
                audio_format_t format=AUDIO_FORMAT_PCM_16_BIT,
                int bufferCount=DEFAULT_AUDIOSINK_BUFFERCOUNT,
                AudioCallback cb = NULL,
                void *cookie = NULL) = 0;
                void *cookie = NULL,
                audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE) = 0;

        virtual void        start() = 0;
        virtual ssize_t     write(const void* buffer, size_t size) = 0;
+3 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ public:
    };

    AudioPlayer(const sp<MediaPlayerBase::AudioSink> &audioSink,
                bool allowDeepBuffering = false,
                AwesomePlayer *audioObserver = NULL);

    virtual ~AudioPlayer();
@@ -95,6 +96,8 @@ private:
    MediaBuffer *mFirstBuffer;

    sp<MediaPlayerBase::AudioSink> mAudioSink;
    bool mAllowDeepBuffering;       // allow audio deep audio buffers. Helps with low power audio
                                    // playback but implies high latency
    AwesomePlayer *mObserver;

    static void AudioCallback(int event, void *user, void *info);
+4 −3
Original line number Diff line number Diff line
@@ -392,7 +392,7 @@ status_t VideoEditorPlayer::VeAudioOutput::getFramesWritten(uint32_t *written) c
status_t VideoEditorPlayer::VeAudioOutput::open(
        uint32_t sampleRate, int channelCount, audio_channel_mask_t channelMask,
        audio_format_t format, int bufferCount,
        AudioCallback cb, void *cookie) {
        AudioCallback cb, void *cookie, audio_output_flags_t flags) {

    mCallback = cb;
    mCallbackCookie = cookie;
@@ -442,7 +442,7 @@ status_t VideoEditorPlayer::VeAudioOutput::open(
                format,
                channelMask,
                frameCount,
                AUDIO_OUTPUT_FLAG_NONE,
                flags,
                CallbackWrapper,
                this);
    } else {
@@ -451,7 +451,8 @@ status_t VideoEditorPlayer::VeAudioOutput::open(
                sampleRate,
                format,
                channelMask,
                frameCount);
                frameCount,
                flags);
    }

    if ((t == 0) || (t->initCheck() != NO_ERROR)) {
+1 −1
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ class VideoEditorPlayer : public MediaPlayerInterface {
        virtual status_t        open(
                uint32_t sampleRate, int channelCount, audio_channel_mask_t channelMask,
                audio_format_t format, int bufferCount,
                AudioCallback cb, void *cookie);
                AudioCallback cb, void *cookie, audio_output_flags_t flags);

        virtual void            start();
        virtual ssize_t         write(const void* buffer, size_t size);
+4 −0
Original line number Diff line number Diff line
@@ -225,6 +225,10 @@ status_t AudioTrack::set(
        flags = (audio_output_flags_t)
                ((flags | AUDIO_OUTPUT_FLAG_DIRECT) & ~AUDIO_OUTPUT_FLAG_FAST);
    }
    // only allow deep buffering for music stream type
    if (streamType != AUDIO_STREAM_MUSIC) {
        flags = (audio_output_flags_t)(flags &~AUDIO_OUTPUT_FLAG_DEEP_BUFFER);
    }

    if (!audio_is_output_channel(channelMask)) {
        ALOGE("Invalid channel mask");
Loading