summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2010-02-26 02:47:27 -0800
committerEric Laurent <elaurent@google.com>2010-03-02 08:20:13 -0800
commit05bca2fde53bfe3063d2a0a877f2b6bfdd6052cf (patch)
tree7f99a6ebacbc1f76b561b95a04808636486b48ba
parent949c5037a6e019ff575bd481d286908c2eaa1e34 (diff)
downloadframeworks_av-05bca2fde53bfe3063d2a0a877f2b6bfdd6052cf.zip
frameworks_av-05bca2fde53bfe3063d2a0a877f2b6bfdd6052cf.tar.gz
frameworks_av-05bca2fde53bfe3063d2a0a877f2b6bfdd6052cf.tar.bz2
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>
-rw-r--r--include/media/AudioRecord.h8
-rw-r--r--include/media/AudioSystem.h1
-rw-r--r--include/media/IAudioFlinger.h3
-rw-r--r--media/libmedia/AudioRecord.cpp11
-rw-r--r--media/libmedia/AudioSystem.cpp10
-rw-r--r--media/libmedia/IAudioFlinger.cpp19
6 files changed, 50 insertions, 2 deletions
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 @@ 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
diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h
index 42bb4df..d0ccc50 100644
--- a/include/media/AudioSystem.h
+++ b/include/media/AudioSystem.h
@@ -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
//
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 @@ 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;
};
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 @@ 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;
}
// -------------------------------------------------------------------------
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 @@ 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) {
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 @@ enum {
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 @@ public:
}
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 @@ status_t BnAudioFlinger::onTransact(
}
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);
}