summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMarco Nelissen <marcone@google.com>2012-03-21 13:36:07 -0700
committerMarco Nelissen <marcone@google.com>2012-03-22 10:06:03 -0700
commitda9deca7bab75f39a236d04b9e43d9da833ce4a0 (patch)
treeda55de4303ab3e4a2e32c70e9fc539dbc3da5745 /include
parent222dfc784e5c5b4eb6a4770b9f46fe96eecbd65d (diff)
downloadframeworks_base-da9deca7bab75f39a236d04b9e43d9da833ce4a0.zip
frameworks_base-da9deca7bab75f39a236d04b9e43d9da833ce4a0.tar.gz
frameworks_base-da9deca7bab75f39a236d04b9e43d9da833ce4a0.tar.bz2
Support gapless playback for mp3 and m4a
Gapless playback for appropriately tagged mp3 and m4a files. Currently this is implemented in OMXCodec, which most players use, but should be easy to support in other players as well by using the SkipCutBuffer utility class. Change-Id: I748c669adc1cfbe5ee9a7dea2fad945d48882551
Diffstat (limited to 'include')
-rw-r--r--include/media/stagefright/OMXCodec.h3
-rw-r--r--include/media/stagefright/SkipCutBuffer.h58
2 files changed, 61 insertions, 0 deletions
diff --git a/include/media/stagefright/OMXCodec.h b/include/media/stagefright/OMXCodec.h
index 392ea87..7c612ba 100644
--- a/include/media/stagefright/OMXCodec.h
+++ b/include/media/stagefright/OMXCodec.h
@@ -30,6 +30,7 @@ struct MediaCodecList;
class MemoryDealer;
struct OMXCodecObserver;
struct CodecProfileLevel;
+class SkipCutBuffer;
struct OMXCodec : public MediaSource,
public MediaBufferObserver {
@@ -201,6 +202,7 @@ private:
ReadOptions::SeekMode mSeekMode;
int64_t mTargetTimeUs;
bool mOutputPortSettingsChangedPending;
+ SkipCutBuffer *mSkipCutBuffer;
MediaBuffer *mLeftOverBuffer;
@@ -378,6 +380,7 @@ status_t QueryCodecs(
const char *mimeType, bool queryDecoders,
Vector<CodecCapabilities> *results);
+
} // namespace android
#endif // OMX_CODEC_H_
diff --git a/include/media/stagefright/SkipCutBuffer.h b/include/media/stagefright/SkipCutBuffer.h
new file mode 100644
index 0000000..5c7cd47
--- /dev/null
+++ b/include/media/stagefright/SkipCutBuffer.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SKIP_CUT_BUFFER_H_
+
+#define SKIP_CUT_BUFFER_H_
+
+#include <media/stagefright/MediaBuffer.h>
+
+namespace android {
+
+/**
+ * utility class to cut the start and end off a stream of data in MediaBuffers
+ *
+ */
+class SkipCutBuffer {
+ public:
+ // 'skip' is the number of bytes to skip from the beginning
+ // 'cut' is the number of bytes to cut from the end
+ // 'output_size' is the size in bytes of the MediaBuffers that will be used
+ SkipCutBuffer(int32_t skip, int32_t cut, int32_t output_size);
+ 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.
+ // After this, the caller should continue processing the buffer as usual.
+ void submit(MediaBuffer *buffer);
+ void clear();
+ size_t size(); // how many bytes are currently stored in the buffer
+
+ private:
+ void write(const char *src, size_t num);
+ size_t read(char *dst, size_t num);
+ int32_t mFrontPadding;
+ int32_t mBackPadding;
+ int32_t mWriteHead;
+ int32_t mReadHead;
+ int32_t mCapacity;
+ char* mCutBuffer;
+ DISALLOW_EVIL_CONSTRUCTORS(SkipCutBuffer);
+};
+
+} // namespace android
+
+#endif // OMX_CODEC_H_