summaryrefslogtreecommitdiffstats
path: root/include/media/stagefright
diff options
context:
space:
mode:
authorMarco Nelissen <marcone@google.com>2012-04-27 09:33:24 -0700
committerMarco Nelissen <marcone@google.com>2012-04-30 09:40:47 -0700
commit8b71241ce7353731ab75322c46e090ee35014a33 (patch)
treeafc21859dae503e57aa5a3cc777512800d1fd64e /include/media/stagefright
parent83faee053cfd4251dbb591b62039f563ffdac399 (diff)
downloadframeworks_av-8b71241ce7353731ab75322c46e090ee35014a33.zip
frameworks_av-8b71241ce7353731ab75322c46e090ee35014a33.tar.gz
frameworks_av-8b71241ce7353731ab75322c46e090ee35014a33.tar.bz2
Fix mono gapless playback for decoders that output stereo
The old AAC decoder always outputs stereo, even for mono source material, so we need to use the number of channels of the output when calculating the number of bytes to skip, not the number of channels in the source. This makes OMXCodec skip the right amount of data, and prevents NuPlayer from writing half a frame and then asserting when the AudioSink doesn't accept it. Also move use of the SkipCutBuffer from NuPlayer to ACodec, so that it also works when using the new Java APIs, and make SkipCutBuffer derive from RefBase. b/774846 Change-Id: I34df9fea3e6730617eae559afaa556f4085ef0a0
Diffstat (limited to 'include/media/stagefright')
-rw-r--r--include/media/stagefright/ACodec.h4
-rw-r--r--include/media/stagefright/OMXCodec.h2
-rw-r--r--include/media/stagefright/SkipCutBuffer.h6
3 files changed, 9 insertions, 3 deletions
diff --git a/include/media/stagefright/ACodec.h b/include/media/stagefright/ACodec.h
index b8d925e..72827c1 100644
--- a/include/media/stagefright/ACodec.h
+++ b/include/media/stagefright/ACodec.h
@@ -22,6 +22,7 @@
#include <android/native_window.h>
#include <media/IOMX.h>
#include <media/stagefright/foundation/AHierarchicalStateMachine.h>
+#include <media/stagefright/SkipCutBuffer.h>
#include <OMX_Audio.h>
namespace android {
@@ -120,6 +121,9 @@ private:
sp<ExecutingToIdleState> mExecutingToIdleState;
sp<IdleToLoadedState> mIdleToLoadedState;
sp<FlushingState> mFlushingState;
+ int32_t mEncoderDelay;
+ int32_t mEncoderPadding;
+ sp<SkipCutBuffer> mSkipCutBuffer;
AString mComponentName;
uint32_t mFlags;
diff --git a/include/media/stagefright/OMXCodec.h b/include/media/stagefright/OMXCodec.h
index 887ce5d..81350ca 100644
--- a/include/media/stagefright/OMXCodec.h
+++ b/include/media/stagefright/OMXCodec.h
@@ -204,7 +204,7 @@ private:
ReadOptions::SeekMode mSeekMode;
int64_t mTargetTimeUs;
bool mOutputPortSettingsChangedPending;
- SkipCutBuffer *mSkipCutBuffer;
+ sp<SkipCutBuffer> mSkipCutBuffer;
MediaBuffer *mLeftOverBuffer;
diff --git a/include/media/stagefright/SkipCutBuffer.h b/include/media/stagefright/SkipCutBuffer.h
index 27851ca..2653b53 100644
--- a/include/media/stagefright/SkipCutBuffer.h
+++ b/include/media/stagefright/SkipCutBuffer.h
@@ -27,12 +27,11 @@ namespace android {
* utility class to cut the start and end off a stream of data in MediaBuffers
*
*/
-class SkipCutBuffer {
+class SkipCutBuffer: public RefBase {
public:
// 'skip' is the number of bytes to skip from the beginning
// 'cut' is the number of bytes to cut from the end
SkipCutBuffer(int32_t skip, int32_t cut);
- virtual ~SkipCutBuffer();
// Submit one MediaBuffer for skipping and cutting. This may consume all or
// some of the data in the buffer, or it may add data to it.
@@ -42,6 +41,9 @@ class SkipCutBuffer {
void clear();
size_t size(); // how many bytes are currently stored in the buffer
+ protected:
+ virtual ~SkipCutBuffer();
+
private:
void write(const char *src, size_t num);
size_t read(char *dst, size_t num);