summaryrefslogtreecommitdiffstats
path: root/include/media
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2011-02-15 10:08:07 -0800
committerJames Dong <jdong@google.com>2011-02-16 11:23:21 -0800
commitd33a4ccb5c3b58406cee45a4d933d40219177f8c (patch)
treebd4aa2d8998465284ece77fc98cd1e9c654bb20c /include/media
parent5a5b4ba9fe40605d5e43b7ff25a58f7174509a53 (diff)
downloadframeworks_base-d33a4ccb5c3b58406cee45a4d933d40219177f8c.zip
frameworks_base-d33a4ccb5c3b58406cee45a4d933d40219177f8c.tar.gz
frameworks_base-d33a4ccb5c3b58406cee45a4d933d40219177f8c.tar.bz2
Decouple AudioRecord read and audio encoding
bug - 3313754 Change-Id: I951dd0e21e34aa1412c391f003bc32103d0424b0
Diffstat (limited to 'include/media')
-rw-r--r--include/media/stagefright/AudioSource.h24
1 files changed, 18 insertions, 6 deletions
diff --git a/include/media/stagefright/AudioSource.h b/include/media/stagefright/AudioSource.h
index d484d60..b35a6e6 100644
--- a/include/media/stagefright/AudioSource.h
+++ b/include/media/stagefright/AudioSource.h
@@ -18,15 +18,17 @@
#define AUDIO_SOURCE_H_
+#include <media/AudioRecord.h>
#include <media/AudioSystem.h>
#include <media/stagefright/MediaSource.h>
+#include <media/stagefright/MediaBuffer.h>
+#include <utils/List.h>
namespace android {
class AudioRecord;
-struct MediaBufferGroup;
-struct AudioSource : public MediaSource {
+struct AudioSource : public MediaSource, public MediaBufferObserver {
// Note that the "channels" parameter is _not_ the number of channels,
// but a bitmask of AudioSystem::audio_channels constants.
AudioSource(
@@ -45,6 +47,9 @@ struct AudioSource : public MediaSource {
virtual status_t read(
MediaBuffer **buffer, const ReadOptions *options = NULL);
+ status_t dataCallbackTimestamp(const AudioRecord::Buffer& buffer, int64_t timeUs);
+ virtual void signalBufferReturned(MediaBuffer *buffer);
+
protected:
virtual ~AudioSource();
@@ -61,20 +66,24 @@ private:
kAutoRampStartUs = 1000000,
};
+ Mutex mLock;
+ Condition mFrameAvailableCondition;
+ Condition mFrameEncodingCompletionCondition;
+
AudioRecord *mRecord;
status_t mInitCheck;
bool mStarted;
+ int32_t mSampleRate;
- bool mCollectStats;
bool mTrackMaxAmplitude;
int64_t mStartTimeUs;
int16_t mMaxAmplitude;
int64_t mPrevSampleTimeUs;
- int64_t mTotalLostFrames;
- int64_t mPrevLostBytes;
int64_t mInitialReadTimeUs;
+ int64_t mNumFramesReceived;
+ int64_t mNumClientOwnedBuffers;
- MediaBufferGroup *mGroup;
+ List<MediaBuffer * > mBuffersReceived;
void trackMaxAmplitude(int16_t *data, int nSamples);
@@ -84,6 +93,9 @@ private:
int32_t startFrame, int32_t rampDurationFrames,
uint8_t *data, size_t bytes);
+ void releaseQueuedFrames_l();
+ void waitOutstandingEncodingFrames_l();
+
AudioSource(const AudioSource &);
AudioSource &operator=(const AudioSource &);
};