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/media/libmedia/AudioRecord.cpp b/media/libmedia/AudioRecord.cpp
index 7bbd0b2..bce3371 100644
--- a/media/libmedia/AudioRecord.cpp
+++ b/media/libmedia/AudioRecord.cpp
@@ -199,6 +199,7 @@
mUpdatePeriod = 0;
mInputSource = (uint8_t)inputSource;
mFlags = flags;
+ mInput = input;
return NO_ERROR;
}
@@ -384,6 +385,13 @@
return NO_ERROR;
}
+unsigned int AudioRecord::getInputFramesLost()
+{
+ if (mActive)
+ return AudioSystem::getInputFramesLost(mInput);
+ else
+ return 0;
+}
// -------------------------------------------------------------------------
@@ -517,10 +525,11 @@
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;
}
// -------------------------------------------------------------------------
diff --git a/media/libmedia/AudioSystem.cpp b/media/libmedia/AudioSystem.cpp
index 3f9c6d6..4b364f2 100644
--- a/media/libmedia/AudioSystem.cpp
+++ b/media/libmedia/AudioSystem.cpp
@@ -354,6 +354,16 @@
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) {
diff --git a/media/libmedia/IAudioFlinger.cpp b/media/libmedia/IAudioFlinger.cpp
index ca3a2a6..47bcc12 100644
--- a/media/libmedia/IAudioFlinger.cpp
+++ b/media/libmedia/IAudioFlinger.cpp
@@ -61,7 +61,8 @@
CLOSE_INPUT,
SET_STREAM_OUTPUT,
SET_VOICE_VOLUME,
- GET_RENDER_POSITION
+ GET_RENDER_POSITION,
+ GET_INPUT_FRAMES_LOST
};
class BpAudioFlinger : public BpInterface<IAudioFlinger>
@@ -487,6 +488,15 @@
}
return status;
}
+
+ virtual unsigned int getInputFramesLost(int ioHandle)
+ {
+ Parcel data, reply;
+ data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
+ data.writeInt32(ioHandle);
+ remote()->transact(GET_INPUT_FRAMES_LOST, data, &reply);
+ return reply.readInt32();
+ }
};
IMPLEMENT_META_INTERFACE(AudioFlinger, "android.media.IAudioFlinger");
@@ -752,6 +762,13 @@
}
return NO_ERROR;
}
+ case GET_INPUT_FRAMES_LOST: {
+ CHECK_INTERFACE(IAudioFlinger, data, reply);
+ int ioHandle = data.readInt32();
+ reply->writeInt32(getInputFramesLost(ioHandle));
+ return NO_ERROR;
+ } break;
+
default:
return BBinder::onTransact(code, data, reply, flags);
}