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

Commit 05bca2fd authored by Eric Laurent's avatar Eric Laurent
Browse files

Issue 2071329: audio track is shorter than video track for video capture on sholes

Add API to retrieve number of frames dropped by audio input kernel driver.

Submitted on behalf of Masaki Sato <masaki.sato@motorola.com>
parent 949c5037
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -294,6 +294,13 @@ public:
     */
            ssize_t     read(void* buffer, size_t size);

    /* Return the amount of input frames lost in the audio driver since the last call of this function.
     * Audio driver is expected to reset the value to 0 and restart counting upon returning the current value by this function call.
     * Such loss typically occurs when the user space process is blocked longer than the capacity of audio driver buffers.
     * Unit: the number of input audio frames
     */
            unsigned int  getInputFramesLost();

private:
    /* copying audio tracks is not allowed */
                        AudioRecord(const AudioRecord& other);
@@ -348,6 +355,7 @@ private:
    uint32_t                mUpdatePeriod;
    uint32_t                mFlags;
    uint32_t                mChannels;
    audio_io_handle_t       mInput;
};

}; // namespace android
+1 −0
Original line number Diff line number Diff line
@@ -233,6 +233,7 @@ public:
    // necessary to check returned status before using the returned values.
    static status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, int stream = DEFAULT);

    static unsigned int  getInputFramesLost(audio_io_handle_t ioHandle);
    //
    // AudioPolicyService interface
    //
+3 −0
Original line number Diff line number Diff line
@@ -130,7 +130,10 @@ public:
    virtual status_t setStreamOutput(uint32_t stream, int output) = 0;

    virtual status_t setVoiceVolume(float volume) = 0;

    virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, int output) = 0;

    virtual unsigned int  getInputFramesLost(int ioHandle) = 0;
};


+10 −1
Original line number Diff line number Diff line
@@ -199,6 +199,7 @@ status_t AudioRecord::set(
    mUpdatePeriod = 0;
    mInputSource = (uint8_t)inputSource;
    mFlags = flags;
    mInput = input;

    return NO_ERROR;
}
@@ -384,6 +385,13 @@ status_t AudioRecord::getPosition(uint32_t *position)
    return NO_ERROR;
}

unsigned int AudioRecord::getInputFramesLost()
{
    if (mActive)
        return AudioSystem::getInputFramesLost(mInput);
    else
        return 0;
}

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

@@ -517,10 +525,11 @@ void AudioRecord::releaseBuffer(Buffer* audioBuffer)

audio_io_handle_t AudioRecord::getInput()
{
   return AudioSystem::getInput(mInputSource,
    mInput = AudioSystem::getInput(mInputSource,
                                mCblk->sampleRate,
                                mFormat, mChannels,
                                (AudioSystem::audio_in_acoustics)mFlags);
    return mInput;
}

// -------------------------------------------------------------------------
+10 −0
Original line number Diff line number Diff line
@@ -354,6 +354,16 @@ status_t AudioSystem::getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames
    return af->getRenderPosition(halFrames, dspFrames, getOutput((stream_type)stream));
}

unsigned int AudioSystem::getInputFramesLost(audio_io_handle_t ioHandle) {
    const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
    unsigned int result = 0;
    if (af == 0) return result;
    if (ioHandle == NULL) return result;

    result = af->getInputFramesLost(ioHandle);
    return result;
}

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

void AudioSystem::AudioFlingerClient::binderDied(const wp<IBinder>& who) {
Loading