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>
diff --git a/include/media/AudioRecord.h b/include/media/AudioRecord.h
index 622c596..92bc126 100644
--- a/include/media/AudioRecord.h
+++ b/include/media/AudioRecord.h
@@ -294,6 +294,13 @@
*/
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 @@
uint32_t mUpdatePeriod;
uint32_t mFlags;
uint32_t mChannels;
+ audio_io_handle_t mInput;
};
}; // namespace android
diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h
index 42bb4df..d0ccc505 100644
--- a/include/media/AudioSystem.h
+++ b/include/media/AudioSystem.h
@@ -233,6 +233,7 @@
// 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
//
diff --git a/include/media/IAudioFlinger.h b/include/media/IAudioFlinger.h
index bddd23e..c147632 100644
--- a/include/media/IAudioFlinger.h
+++ b/include/media/IAudioFlinger.h
@@ -130,7 +130,10 @@
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;
};