Merge "aaudio: turn off RAW flag for sessions"
diff --git a/cmds/stagefright/codec.cpp b/cmds/stagefright/codec.cpp
index 6a58467..980d1d2 100644
--- a/cmds/stagefright/codec.cpp
+++ b/cmds/stagefright/codec.cpp
@@ -366,13 +366,13 @@
case 'T':
{
useTimestamp = true;
+ FALLTHROUGH_INTENDED;
}
- // fall through
case 'R':
{
renderSurface = true;
+ FALLTHROUGH_INTENDED;
}
- // fall through
case 'S':
{
useSurface = true;
diff --git a/cmds/stagefright/mediafilter.cpp b/cmds/stagefright/mediafilter.cpp
index f24d2dd..630de25 100644
--- a/cmds/stagefright/mediafilter.cpp
+++ b/cmds/stagefright/mediafilter.cpp
@@ -706,13 +706,13 @@
case 'T':
{
useTimestamp = true;
+ FALLTHROUGH_INTENDED;
}
- // fall through
case 'R':
{
renderSurface = true;
+ FALLTHROUGH_INTENDED;
}
- // fall through
case 'S':
{
useSurface = true;
diff --git a/include/media/MediaExtractorPluginApi.h b/include/media/MediaExtractorPluginApi.h
index 930b6e2..9caea3e 100644
--- a/include/media/MediaExtractorPluginApi.h
+++ b/include/media/MediaExtractorPluginApi.h
@@ -19,10 +19,13 @@
#include <utils/Errors.h> // for status_t
+struct AMediaFormat;
+
namespace android {
struct MediaTrack;
class MetaDataBase;
+class MediaBufferBase;
extern "C" {
@@ -34,12 +37,45 @@
void *handle;
};
-struct CMediaExtractor {
+enum CMediaTrackReadOptions : uint32_t {
+ SEEK_PREVIOUS_SYNC = 0,
+ SEEK_NEXT_SYNC = 1,
+ SEEK_CLOSEST_SYNC = 2,
+ SEEK_CLOSEST = 3,
+ SEEK_FRAME_INDEX = 4,
+ SEEK = 8,
+ NONBLOCKING = 16
+};
+
+struct CMediaTrack {
+ void *data;
+ void (*free)(void *data);
+
+ status_t (*start)(void *data, MetaDataBase *params);
+ status_t (*stop)(void *data);
+ status_t (*getFormat)(void *data, MetaDataBase &format);
+ status_t (*read)(void *data, MediaBufferBase **buffer, uint32_t options, int64_t seekPosUs);
+ bool (*supportsNonBlockingRead)(void *data);
+};
+
+struct CMediaTrackV2 {
+ void *data;
+ void (*free)(void *data);
+
+ status_t (*start)(void *data, AMediaFormat *params);
+ status_t (*stop)(void *data);
+ status_t (*getFormat)(void *data, AMediaFormat *format);
+ status_t (*read)(void *data, MediaBufferBase **buffer, uint32_t options, int64_t seekPosUs);
+ bool (*supportsNonBlockingRead)(void *data);
+};
+
+
+struct CMediaExtractorV1 {
void *data;
void (*free)(void *data);
size_t (*countTracks)(void *data);
- MediaTrack* (*getTrack)(void *data, size_t index);
+ CMediaTrack* (*getTrack)(void *data, size_t index);
status_t (*getTrackMetaData)(
void *data,
MetaDataBase& meta,
@@ -51,22 +87,49 @@
const char * (*name)(void *data);
};
-typedef CMediaExtractor* (*CreatorFunc)(CDataSource *source, void *meta);
+struct CMediaExtractorV2 {
+ void *data;
+
+ void (*free)(void *data);
+ size_t (*countTracks)(void *data);
+ CMediaTrackV2* (*getTrack)(void *data, size_t index);
+ status_t (*getTrackMetaData)(
+ void *data,
+ AMediaFormat *meta,
+ size_t index, uint32_t flags);
+
+ status_t (*getMetaData)(void *data, AMediaFormat *meta);
+ uint32_t (*flags)(void *data);
+ status_t (*setMediaCas)(void *data, const uint8_t* casToken, size_t size);
+ const char * (*name)(void *data);
+};
+
+typedef CMediaExtractorV1* (*CreatorFuncV1)(CDataSource *source, void *meta);
typedef void (*FreeMetaFunc)(void *meta);
// The sniffer can optionally fill in an opaque object, "meta", that helps
// the corresponding extractor initialize its state without duplicating
// effort already exerted by the sniffer. If "freeMeta" is given, it will be
// called against the opaque object when it is no longer used.
-typedef CreatorFunc (*SnifferFunc)(
+typedef CreatorFuncV1 (*SnifferFuncV1)(
CDataSource *source, float *confidence,
void **meta, FreeMetaFunc *freeMeta);
+typedef CMediaExtractorV2* (*CreatorFuncV2)(CDataSource *source, void *meta);
+
+typedef CreatorFuncV2 (*SnifferFuncV2)(
+ CDataSource *source, float *confidence,
+ void **meta, FreeMetaFunc *freeMeta);
+
+typedef CMediaExtractorV1 CMediaExtractor;
+typedef CreatorFuncV1 CreatorFunc;
+
+
typedef struct {
const uint8_t b[16];
} media_uuid_t;
-typedef struct {
+struct ExtractorDef {
// version number of this structure
const uint32_t def_version;
@@ -82,11 +145,16 @@
// a human readable name
const char *extractor_name;
- // the sniffer function
- const SnifferFunc sniff;
-} ExtractorDef;
+ union {
+ SnifferFuncV1 v1;
+ SnifferFuncV2 v2;
+ } sniff;
+};
-const uint32_t EXTRACTORDEF_VERSION = 1;
+const uint32_t EXTRACTORDEF_VERSION_LEGACY = 1;
+const uint32_t EXTRACTORDEF_VERSION_CURRENT = 2;
+
+const uint32_t EXTRACTORDEF_VERSION = EXTRACTORDEF_VERSION_LEGACY;
// each plugin library exports one function of this type
typedef ExtractorDef (*GetExtractorDef)();
diff --git a/include/media/MediaExtractorPluginHelper.h b/include/media/MediaExtractorPluginHelper.h
index a659660..2acc2bf 100644
--- a/include/media/MediaExtractorPluginHelper.h
+++ b/include/media/MediaExtractorPluginHelper.h
@@ -33,6 +33,146 @@
class MetaDataBase;
struct MediaTrack;
+
+class MediaTrackHelper {
+public:
+ virtual ~MediaTrackHelper() {};
+ virtual status_t start(MetaDataBase *params = NULL) = 0;
+ virtual status_t stop() = 0;
+ virtual status_t getFormat(MetaDataBase& format) = 0;
+
+ class ReadOptions {
+ public:
+ enum SeekMode : int32_t {
+ SEEK_PREVIOUS_SYNC,
+ SEEK_NEXT_SYNC,
+ SEEK_CLOSEST_SYNC,
+ SEEK_CLOSEST,
+ SEEK_FRAME_INDEX,
+ };
+
+ ReadOptions(uint32_t options, int64_t seekPosUs) {
+ mOptions = options;
+ mSeekPosUs = seekPosUs;
+ }
+ bool getSeekTo(int64_t *time_us, SeekMode *mode) const {
+ if ((mOptions & CMediaTrackReadOptions::SEEK) == 0) {
+ return false;
+ }
+ *time_us = mSeekPosUs;
+ *mode = (SeekMode) (mOptions & 7);
+ return true;
+ }
+ bool getNonBlocking() const {
+ return mOptions & CMediaTrackReadOptions::NONBLOCKING;
+ }
+ private:
+ uint32_t mOptions;
+ int64_t mSeekPosUs;
+ };
+
+ virtual status_t read(
+ MediaBufferBase **buffer, const ReadOptions *options = NULL) = 0;
+ virtual bool supportsNonBlockingRead() { return false; }
+};
+
+inline CMediaTrack *wrap(MediaTrackHelper *track) {
+ CMediaTrack *wrapper = (CMediaTrack*) malloc(sizeof(CMediaTrack));
+ wrapper->data = track;
+ wrapper->free = [](void *data) -> void {
+ delete (MediaTrackHelper*)(data);
+ };
+ wrapper->start = [](void *data, MetaDataBase *params) -> status_t {
+ return ((MediaTrackHelper*)data)->start(params);
+ };
+ wrapper->stop = [](void *data) -> status_t {
+ return ((MediaTrackHelper*)data)->stop();
+ };
+ wrapper->getFormat = [](void *data, MetaDataBase &meta) -> status_t {
+ return ((MediaTrackHelper*)data)->getFormat(meta);
+ };
+ wrapper->read = [](void *data, MediaBufferBase **buffer, uint32_t options, int64_t seekPosUs)
+ -> status_t {
+ MediaTrackHelper::ReadOptions opts(options, seekPosUs);
+ return ((MediaTrackHelper*)data)->read(buffer, &opts);
+ };
+ wrapper->supportsNonBlockingRead = [](void *data) -> bool {
+ return ((MediaTrackHelper*)data)->supportsNonBlockingRead();
+ };
+ return wrapper;
+}
+
+
+class MediaTrackHelperV2 {
+public:
+ virtual ~MediaTrackHelperV2() {};
+ virtual status_t start(AMediaFormat *params = NULL) = 0;
+ virtual status_t stop() = 0;
+ virtual status_t getFormat(AMediaFormat *format) = 0;
+
+ class ReadOptions {
+ public:
+ enum SeekMode : int32_t {
+ SEEK_PREVIOUS_SYNC,
+ SEEK_NEXT_SYNC,
+ SEEK_CLOSEST_SYNC,
+ SEEK_CLOSEST,
+ SEEK_FRAME_INDEX,
+ };
+
+ ReadOptions(uint32_t options, int64_t seekPosUs) {
+ mOptions = options;
+ mSeekPosUs = seekPosUs;
+ }
+ bool getSeekTo(int64_t *time_us, SeekMode *mode) const {
+ if ((mOptions & CMediaTrackReadOptions::SEEK) == 0) {
+ return false;
+ }
+ *time_us = mSeekPosUs;
+ *mode = (SeekMode) (mOptions & 7);
+ return true;
+ }
+ bool getNonBlocking() const {
+ return mOptions & CMediaTrackReadOptions::NONBLOCKING;
+ }
+ private:
+ uint32_t mOptions;
+ int64_t mSeekPosUs;
+ };
+
+ virtual status_t read(
+ MediaBufferBase **buffer, const ReadOptions *options = NULL) = 0;
+ virtual bool supportsNonBlockingRead() { return false; }
+};
+
+inline CMediaTrackV2 *wrapV2(MediaTrackHelperV2 *track) {
+ CMediaTrackV2 *wrapper = (CMediaTrackV2*) malloc(sizeof(CMediaTrackV2));
+ wrapper->data = track;
+ wrapper->free = [](void *data) -> void {
+ delete (MediaTrackHelperV2*)(data);
+ };
+ wrapper->start = [](void *data, AMediaFormat *params) -> status_t {
+ return ((MediaTrackHelperV2*)data)->start(params);
+ };
+ wrapper->stop = [](void *data) -> status_t {
+ return ((MediaTrackHelperV2*)data)->stop();
+ };
+ wrapper->getFormat = [](void *data, AMediaFormat *meta) -> status_t {
+ return ((MediaTrackHelperV2*)data)->getFormat(meta);
+ };
+ wrapper->read = [](void *data, MediaBufferBase **buffer, uint32_t options, int64_t seekPosUs)
+ -> status_t {
+ MediaTrackHelperV2::ReadOptions opts(options, seekPosUs);
+ return ((MediaTrackHelperV2*)data)->read(buffer, &opts);
+ };
+ wrapper->supportsNonBlockingRead = [](void *data) -> bool {
+ return ((MediaTrackHelperV2*)data)->supportsNonBlockingRead();
+ };
+ return wrapper;
+}
+
+
+
// extractor plugins can derive from this class which looks remarkably
// like MediaExtractor and can be easily wrapped in the required C API
class MediaExtractorPluginHelper
@@ -40,7 +180,7 @@
public:
virtual ~MediaExtractorPluginHelper() {}
virtual size_t countTracks() = 0;
- virtual MediaTrack *getTrack(size_t index) = 0;
+ virtual MediaTrackHelper *getTrack(size_t index) = 0;
enum GetTrackMetaDataFlags {
kIncludeExtensiveMetaData = 1
@@ -89,8 +229,8 @@
wrapper->countTracks = [](void *data) -> size_t {
return ((MediaExtractorPluginHelper*)data)->countTracks();
};
- wrapper->getTrack = [](void *data, size_t index) -> MediaTrack* {
- return ((MediaExtractorPluginHelper*)data)->getTrack(index);
+ wrapper->getTrack = [](void *data, size_t index) -> CMediaTrack* {
+ return wrap(((MediaExtractorPluginHelper*)data)->getTrack(index));
};
wrapper->getTrackMetaData = [](
void *data,
@@ -118,6 +258,89 @@
return wrapper;
}
+class MediaExtractorPluginHelperV2
+{
+public:
+ virtual ~MediaExtractorPluginHelperV2() {}
+ virtual size_t countTracks() = 0;
+ virtual MediaTrackHelperV2 *getTrack(size_t index) = 0;
+
+ enum GetTrackMetaDataFlags {
+ kIncludeExtensiveMetaData = 1
+ };
+ virtual status_t getTrackMetaData(
+ AMediaFormat *meta,
+ size_t index, uint32_t flags = 0) = 0;
+
+ // Return container specific meta-data. The default implementation
+ // returns an empty metadata object.
+ virtual status_t getMetaData(AMediaFormat *meta) = 0;
+
+ enum Flags {
+ CAN_SEEK_BACKWARD = 1, // the "seek 10secs back button"
+ CAN_SEEK_FORWARD = 2, // the "seek 10secs forward button"
+ CAN_PAUSE = 4,
+ CAN_SEEK = 8, // the "seek bar"
+ };
+
+ // If subclasses do _not_ override this, the default is
+ // CAN_SEEK_BACKWARD | CAN_SEEK_FORWARD | CAN_SEEK | CAN_PAUSE
+ virtual uint32_t flags() const {
+ return CAN_SEEK_BACKWARD | CAN_SEEK_FORWARD | CAN_SEEK | CAN_PAUSE;
+ };
+
+ virtual status_t setMediaCas(const uint8_t* /*casToken*/, size_t /*size*/) {
+ return INVALID_OPERATION;
+ }
+
+ virtual const char * name() { return "<unspecified>"; }
+
+protected:
+ MediaExtractorPluginHelperV2() {}
+
+private:
+ MediaExtractorPluginHelperV2(const MediaExtractorPluginHelperV2 &);
+ MediaExtractorPluginHelperV2 &operator=(const MediaExtractorPluginHelperV2 &);
+};
+
+inline CMediaExtractorV2 *wrapV2(MediaExtractorPluginHelperV2 *extractor) {
+ CMediaExtractorV2 *wrapper = (CMediaExtractorV2*) malloc(sizeof(CMediaExtractorV2));
+ wrapper->data = extractor;
+ wrapper->free = [](void *data) -> void {
+ delete (MediaExtractorPluginHelperV2*)(data);
+ };
+ wrapper->countTracks = [](void *data) -> size_t {
+ return ((MediaExtractorPluginHelperV2*)data)->countTracks();
+ };
+ wrapper->getTrack = [](void *data, size_t index) -> CMediaTrackV2* {
+ return wrapV2(((MediaExtractorPluginHelperV2*)data)->getTrack(index));
+ };
+ wrapper->getTrackMetaData = [](
+ void *data,
+ AMediaFormat *meta,
+ size_t index, uint32_t flags) -> status_t {
+ return ((MediaExtractorPluginHelperV2*)data)->getTrackMetaData(meta, index, flags);
+ };
+ wrapper->getMetaData = [](
+ void *data,
+ AMediaFormat *meta) -> status_t {
+ return ((MediaExtractorPluginHelperV2*)data)->getMetaData(meta);
+ };
+ wrapper->flags = [](
+ void *data) -> uint32_t {
+ return ((MediaExtractorPluginHelperV2*)data)->flags();
+ };
+ wrapper->setMediaCas = [](
+ void *data, const uint8_t *casToken, size_t size) -> status_t {
+ return ((MediaExtractorPluginHelperV2*)data)->setMediaCas(casToken, size);
+ };
+ wrapper->name = [](
+ void *data) -> const char * {
+ return ((MediaExtractorPluginHelperV2*)data)->name();
+ };
+ return wrapper;
+}
+
/* adds some convience methods */
class DataSourceHelper {
public:
diff --git a/include/media/MediaTrack.h b/include/media/MediaTrack.h
deleted file mode 120000
index 5a63287a..0000000
--- a/include/media/MediaTrack.h
+++ /dev/null
@@ -1 +0,0 @@
-../../media/libmediaextractor/include/media/MediaTrack.h
\ No newline at end of file
diff --git a/media/libmediaextractor/include/media/MediaTrack.h b/include/media/MediaTrack.h
similarity index 68%
rename from media/libmediaextractor/include/media/MediaTrack.h
rename to include/media/MediaTrack.h
index 94510a2..174f4cc 100644
--- a/media/libmediaextractor/include/media/MediaTrack.h
+++ b/include/media/MediaTrack.h
@@ -22,8 +22,10 @@
#include <binder/IMemory.h>
#include <binder/MemoryDealer.h>
+#include <media/MediaExtractorPluginApi.h>
#include <media/stagefright/MediaErrors.h>
#include <media/stagefright/MetaData.h>
+#include <media/MediaExtractorPluginApi.h>
#include <utils/Log.h>
#include <utils/RefBase.h>
#include <utils/Vector.h>
@@ -31,6 +33,7 @@
namespace android {
class MediaBufferBase;
+struct CMediaTrack;
class SourceBaseAllocTracker {
public:
@@ -67,20 +70,30 @@
// b) not be late, i.e. lateness_us = 0
struct ReadOptions {
enum SeekMode : int32_t {
- SEEK_PREVIOUS_SYNC,
- SEEK_NEXT_SYNC,
- SEEK_CLOSEST_SYNC,
- SEEK_CLOSEST,
- SEEK_FRAME_INDEX,
+ SEEK_PREVIOUS_SYNC = CMediaTrackReadOptions::SEEK_PREVIOUS_SYNC,
+ SEEK_NEXT_SYNC = CMediaTrackReadOptions::SEEK_NEXT_SYNC,
+ SEEK_CLOSEST_SYNC = CMediaTrackReadOptions::SEEK_CLOSEST_SYNC,
+ SEEK_CLOSEST = CMediaTrackReadOptions::SEEK_CLOSEST,
+ SEEK_FRAME_INDEX = CMediaTrackReadOptions::SEEK_FRAME_INDEX,
};
- ReadOptions();
+ ReadOptions() {
+ reset();
+ }
// Reset everything back to defaults.
- void reset();
+ void reset() {
+ mOptions = 0;
+ mSeekTimeUs = 0;
+ mNonBlocking = false;
+ }
void setSeekTo(int64_t time_us, SeekMode mode = SEEK_CLOSEST_SYNC);
- void clearSeekTo();
+ void clearSeekTo() {
+ mOptions &= ~kSeekTo_Option;
+ mSeekTimeUs = 0;
+ mSeekMode = SEEK_CLOSEST_SYNC;
+ }
bool getSeekTo(int64_t *time_us, SeekMode *mode) const;
void setNonBlocking();
@@ -126,6 +139,42 @@
MediaTrack &operator=(const MediaTrack &);
};
+class MediaTrackCUnwrapper : public MediaTrack {
+public:
+ explicit MediaTrackCUnwrapper(CMediaTrack *wrapper);
+
+ virtual status_t start(MetaDataBase *params = NULL);
+ virtual status_t stop();
+ virtual status_t getFormat(MetaDataBase& format);
+ virtual status_t read(MediaBufferBase **buffer, const ReadOptions *options = NULL);
+
+ virtual bool supportNonblockingRead();
+
+protected:
+ virtual ~MediaTrackCUnwrapper();
+
+private:
+ CMediaTrack *wrapper;
+};
+
+class MediaTrackCUnwrapperV2 : public MediaTrack {
+public:
+ explicit MediaTrackCUnwrapperV2(CMediaTrackV2 *wrapper);
+
+ virtual status_t start(MetaDataBase *params = NULL);
+ virtual status_t stop();
+ virtual status_t getFormat(MetaDataBase& format);
+ virtual status_t read(MediaBufferBase **buffer, const ReadOptions *options = NULL);
+
+ virtual bool supportNonblockingRead();
+
+protected:
+ virtual ~MediaTrackCUnwrapperV2();
+
+private:
+ CMediaTrackV2 *wrapper;
+};
+
} // namespace android
#endif // MEDIA_SOURCE_BASE_H_
diff --git a/media/bufferpool/2.0/Accessor.cpp b/media/bufferpool/2.0/Accessor.cpp
index c1b62f8..b9837f7 100644
--- a/media/bufferpool/2.0/Accessor.cpp
+++ b/media/bufferpool/2.0/Accessor.cpp
@@ -122,7 +122,7 @@
ResultStatus status = connect(&connection, &connectionId, &fmqDesc, false);
if (status == ResultStatus::OK) {
_hidl_cb(status, connection, connectionId, *fmqDesc,
- android::hardware::MQDescriptorSync<BufferInvalidationMessage>(
+ android::hardware::MQDescriptorUnsync<BufferInvalidationMessage>(
std::vector<android::hardware::GrantorDescriptor>(),
nullptr /* nhandle */, 0 /* size */));
} else {
@@ -130,7 +130,7 @@
android::hardware::MQDescriptorSync<BufferStatusMessage>(
std::vector<android::hardware::GrantorDescriptor>(),
nullptr /* nhandle */, 0 /* size */),
- android::hardware::MQDescriptorSync<BufferInvalidationMessage>(
+ android::hardware::MQDescriptorUnsync<BufferInvalidationMessage>(
std::vector<android::hardware::GrantorDescriptor>(),
nullptr /* nhandle */, 0 /* size */));
}
diff --git a/media/bufferpool/2.0/include/bufferpool/BufferPoolTypes.h b/media/bufferpool/2.0/include/bufferpool/BufferPoolTypes.h
index eb845e1..7c906cb 100644
--- a/media/bufferpool/2.0/include/bufferpool/BufferPoolTypes.h
+++ b/media/bufferpool/2.0/include/bufferpool/BufferPoolTypes.h
@@ -48,6 +48,7 @@
namespace implementation {
using ::android::hardware::kSynchronizedReadWrite;
+using ::android::hardware::kUnsynchronizedWrite;
typedef uint32_t BufferId;
typedef uint64_t TransactionId;
@@ -60,7 +61,7 @@
typedef android::hardware::MessageQueue<BufferStatusMessage, kSynchronizedReadWrite> BufferStatusQueue;
typedef BufferStatusQueue::Descriptor StatusDescriptor;
-typedef android::hardware::MessageQueue<BufferInvalidationMessage, kSynchronizedReadWrite>
+typedef android::hardware::MessageQueue<BufferInvalidationMessage, kUnsynchronizedWrite>
BufferInvalidationQueue;
typedef BufferInvalidationQueue::Descriptor InvalidationDescriptor;
diff --git a/media/extractors/aac/AACExtractor.cpp b/media/extractors/aac/AACExtractor.cpp
index 955a588..b52aec5 100644
--- a/media/extractors/aac/AACExtractor.cpp
+++ b/media/extractors/aac/AACExtractor.cpp
@@ -20,7 +20,6 @@
#include "AACExtractor.h"
#include <media/MediaExtractorPluginApi.h>
-#include <media/MediaTrack.h>
#include <media/stagefright/foundation/ABuffer.h>
#include <media/stagefright/foundation/AMessage.h>
#include <media/stagefright/foundation/ADebug.h>
@@ -33,7 +32,7 @@
namespace android {
-class AACSource : public MediaTrack {
+class AACSource : public MediaTrackHelper {
public:
AACSource(
DataSourceHelper *source,
@@ -196,7 +195,7 @@
return mInitCheck == OK ? 1 : 0;
}
-MediaTrack *AACExtractor::getTrack(size_t index) {
+MediaTrackHelper *AACExtractor::getTrack(size_t index) {
if (mInitCheck != OK || index != 0) {
return NULL;
}
@@ -394,7 +393,7 @@
UUID("4fd80eae-03d2-4d72-9eb9-48fa6bb54613"),
1, // version
"AAC Extractor",
- Sniff
+ { Sniff }
};
}
diff --git a/media/extractors/aac/AACExtractor.h b/media/extractors/aac/AACExtractor.h
index 3f20461..7afdeb7 100644
--- a/media/extractors/aac/AACExtractor.h
+++ b/media/extractors/aac/AACExtractor.h
@@ -34,7 +34,7 @@
AACExtractor(DataSourceHelper *source, off64_t offset);
virtual size_t countTracks();
- virtual MediaTrack *getTrack(size_t index);
+ virtual MediaTrackHelper *getTrack(size_t index);
virtual status_t getTrackMetaData(MetaDataBase& meta, size_t index, uint32_t flags);
virtual status_t getMetaData(MetaDataBase& meta);
diff --git a/media/extractors/amr/AMRExtractor.cpp b/media/extractors/amr/AMRExtractor.cpp
index e109fb3..8039f3a 100644
--- a/media/extractors/amr/AMRExtractor.cpp
+++ b/media/extractors/amr/AMRExtractor.cpp
@@ -20,7 +20,6 @@
#include "AMRExtractor.h"
-#include <media/MediaTrack.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/MediaBufferGroup.h>
#include <media/stagefright/MediaDefs.h>
@@ -30,7 +29,7 @@
namespace android {
-class AMRSource : public MediaTrack {
+class AMRSource : public MediaTrackHelper {
public:
AMRSource(
DataSourceHelper *source,
@@ -208,7 +207,7 @@
return mInitCheck == OK ? 1 : 0;
}
-MediaTrack *AMRExtractor::getTrack(size_t index) {
+MediaTrackHelper *AMRExtractor::getTrack(size_t index) {
if (mInitCheck != OK || index != 0) {
return NULL;
}
@@ -371,19 +370,21 @@
UUID("c86639c9-2f31-40ac-a715-fa01b4493aaf"),
1,
"AMR Extractor",
- [](
- CDataSource *source,
- float *confidence,
- void **,
- FreeMetaFunc *) -> CreatorFunc {
- DataSourceHelper helper(source);
- if (SniffAMR(&helper, nullptr, confidence)) {
- return [](
- CDataSource *source,
- void *) -> CMediaExtractor* {
- return wrap(new AMRExtractor(new DataSourceHelper(source)));};
+ {
+ [](
+ CDataSource *source,
+ float *confidence,
+ void **,
+ FreeMetaFunc *) -> CreatorFunc {
+ DataSourceHelper helper(source);
+ if (SniffAMR(&helper, nullptr, confidence)) {
+ return [](
+ CDataSource *source,
+ void *) -> CMediaExtractor* {
+ return wrap(new AMRExtractor(new DataSourceHelper(source)));};
+ }
+ return NULL;
}
- return NULL;
}
};
}
diff --git a/media/extractors/amr/AMRExtractor.h b/media/extractors/amr/AMRExtractor.h
index 499ca67..b9a4e9e 100644
--- a/media/extractors/amr/AMRExtractor.h
+++ b/media/extractors/amr/AMRExtractor.h
@@ -34,7 +34,7 @@
explicit AMRExtractor(DataSourceHelper *source);
virtual size_t countTracks();
- virtual MediaTrack *getTrack(size_t index);
+ virtual MediaTrackHelper *getTrack(size_t index);
virtual status_t getTrackMetaData(MetaDataBase& meta, size_t index, uint32_t flags);
virtual status_t getMetaData(MetaDataBase& meta);
diff --git a/media/extractors/flac/FLACExtractor.cpp b/media/extractors/flac/FLACExtractor.cpp
index 1efaa0c..debdcfc 100644
--- a/media/extractors/flac/FLACExtractor.cpp
+++ b/media/extractors/flac/FLACExtractor.cpp
@@ -25,13 +25,13 @@
#include "FLAC/stream_decoder.h"
#include <media/MediaExtractorPluginApi.h>
-#include <media/MediaTrack.h>
#include <media/VorbisComment.h>
#include <media/stagefright/foundation/ABuffer.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/base64.h>
#include <media/stagefright/MediaBufferGroup.h>
#include <media/stagefright/MediaDefs.h>
+#include <media/stagefright/MediaErrors.h>
#include <media/stagefright/MetaData.h>
#include <media/stagefright/MediaBufferBase.h>
@@ -39,7 +39,7 @@
class FLACParser;
-class FLACSource : public MediaTrack {
+class FLACSource : public MediaTrackHelper {
public:
FLACSource(
@@ -812,7 +812,7 @@
return mInitCheck == OK ? 1 : 0;
}
-MediaTrack *FLACExtractor::getTrack(size_t index)
+MediaTrackHelper *FLACExtractor::getTrack(size_t index)
{
if (mInitCheck != OK || index > 0) {
return NULL;
@@ -866,19 +866,21 @@
UUID("1364b048-cc45-4fda-9934-327d0ebf9829"),
1,
"FLAC Extractor",
- [](
- CDataSource *source,
- float *confidence,
- void **,
- FreeMetaFunc *) -> CreatorFunc {
- DataSourceHelper helper(source);
- if (SniffFLAC(&helper, confidence)) {
- return [](
- CDataSource *source,
- void *) -> CMediaExtractor* {
- return wrap(new FLACExtractor(new DataSourceHelper(source)));};
+ {
+ [](
+ CDataSource *source,
+ float *confidence,
+ void **,
+ FreeMetaFunc *) -> CreatorFunc {
+ DataSourceHelper helper(source);
+ if (SniffFLAC(&helper, confidence)) {
+ return [](
+ CDataSource *source,
+ void *) -> CMediaExtractor* {
+ return wrap(new FLACExtractor(new DataSourceHelper(source)));};
+ }
+ return NULL;
}
- return NULL;
}
};
}
diff --git a/media/extractors/flac/FLACExtractor.h b/media/extractors/flac/FLACExtractor.h
index 1ddff43..829f661 100644
--- a/media/extractors/flac/FLACExtractor.h
+++ b/media/extractors/flac/FLACExtractor.h
@@ -33,7 +33,7 @@
explicit FLACExtractor(DataSourceHelper *source);
virtual size_t countTracks();
- virtual MediaTrack *getTrack(size_t index);
+ virtual MediaTrackHelper *getTrack(size_t index);
virtual status_t getTrackMetaData(MetaDataBase& meta, size_t index, uint32_t flags);
virtual status_t getMetaData(MetaDataBase& meta);
diff --git a/media/extractors/midi/Android.bp b/media/extractors/midi/Android.bp
index fde09df18..c5df5c7 100644
--- a/media/extractors/midi/Android.bp
+++ b/media/extractors/midi/Android.bp
@@ -9,6 +9,7 @@
shared_libs: [
"liblog",
"libmediaextractor",
+ "libmediandk",
],
static_libs: [
diff --git a/media/extractors/midi/MidiExtractor.cpp b/media/extractors/midi/MidiExtractor.cpp
index 233033e..9b0f4e7 100644
--- a/media/extractors/midi/MidiExtractor.cpp
+++ b/media/extractors/midi/MidiExtractor.cpp
@@ -24,8 +24,8 @@
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/MediaBufferGroup.h>
#include <media/stagefright/MediaDefs.h>
+#include <media/stagefright/MediaErrors.h>
#include <media/stagefright/MetaData.h>
-#include <media/MediaTrack.h>
#include <libsonivox/eas_reverb.h>
namespace android {
@@ -33,16 +33,16 @@
// how many Sonivox output buffers to aggregate into one MediaBufferBase
static const int NUM_COMBINE_BUFFERS = 4;
-class MidiSource : public MediaTrack {
+class MidiSource : public MediaTrackHelperV2 {
public:
MidiSource(
MidiEngine &engine,
- MetaDataBase &trackMetadata);
+ AMediaFormat *trackMetadata);
- virtual status_t start(MetaDataBase *params);
+ virtual status_t start(AMediaFormat *params);
virtual status_t stop();
- virtual status_t getFormat(MetaDataBase&);
+ virtual status_t getFormat(AMediaFormat *);
virtual status_t read(
MediaBufferBase **buffer, const ReadOptions *options = NULL);
@@ -52,7 +52,7 @@
private:
MidiEngine &mEngine;
- MetaDataBase &mTrackMetadata;
+ AMediaFormat *mTrackMetadata;
bool mInitCheck;
bool mStarted;
@@ -69,7 +69,7 @@
MidiSource::MidiSource(
MidiEngine &engine,
- MetaDataBase &trackMetadata)
+ AMediaFormat *trackMetadata)
: mEngine(engine),
mTrackMetadata(trackMetadata),
mInitCheck(false),
@@ -87,7 +87,7 @@
}
}
-status_t MidiSource::start(MetaDataBase * /* params */)
+status_t MidiSource::start(AMediaFormat * /* params */)
{
ALOGV("MidiSource::start");
@@ -108,9 +108,9 @@
return OK;
}
-status_t MidiSource::getFormat(MetaDataBase &meta)
+status_t MidiSource::getFormat(AMediaFormat *meta)
{
- meta = mTrackMetadata;
+ AMediaFormat_copy(meta, mTrackMetadata);
return OK;
}
@@ -143,8 +143,8 @@
// MidiEngine
MidiEngine::MidiEngine(CDataSource *dataSource,
- MetaDataBase *fileMetadata,
- MetaDataBase *trackMetadata) :
+ AMediaFormat *fileMetadata,
+ AMediaFormat *trackMetadata) :
mGroup(NULL),
mEasData(NULL),
mEasHandle(NULL),
@@ -170,16 +170,20 @@
}
if (fileMetadata != NULL) {
- fileMetadata->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_MIDI);
+ AMediaFormat_setString(fileMetadata, AMEDIAFORMAT_KEY_MIME, MEDIA_MIMETYPE_AUDIO_MIDI);
}
if (trackMetadata != NULL) {
- trackMetadata->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_RAW);
- trackMetadata->setInt64(kKeyDuration, 1000ll * temp); // milli->micro
+ AMediaFormat_setString(trackMetadata, AMEDIAFORMAT_KEY_MIME, MEDIA_MIMETYPE_AUDIO_RAW);
+ AMediaFormat_setInt64(
+ trackMetadata, AMEDIAFORMAT_KEY_DURATION, 1000ll * temp); // milli->micro
mEasConfig = EAS_Config();
- trackMetadata->setInt32(kKeySampleRate, mEasConfig->sampleRate);
- trackMetadata->setInt32(kKeyChannelCount, mEasConfig->numChannels);
- trackMetadata->setInt32(kKeyPcmEncoding, kAudioEncodingPcm16bit);
+ AMediaFormat_setInt32(
+ trackMetadata, AMEDIAFORMAT_KEY_SAMPLE_RATE, mEasConfig->sampleRate);
+ AMediaFormat_setInt32(
+ trackMetadata, AMEDIAFORMAT_KEY_CHANNEL_COUNT, mEasConfig->numChannels);
+ AMediaFormat_setInt32(
+ trackMetadata, AMEDIAFORMAT_KEY_PCM_ENCODING, kAudioEncodingPcm16bit);
}
mIsInitialized = true;
}
@@ -268,13 +272,17 @@
mInitCheck(false)
{
ALOGV("MidiExtractor ctor");
- mEngine = new MidiEngine(mDataSource, &mFileMetadata, &mTrackMetadata);
+ mFileMetadata = AMediaFormat_new();
+ mTrackMetadata = AMediaFormat_new();
+ mEngine = new MidiEngine(mDataSource, mFileMetadata, mTrackMetadata);
mInitCheck = mEngine->initCheck();
}
MidiExtractor::~MidiExtractor()
{
ALOGV("MidiExtractor dtor");
+ AMediaFormat_delete(mFileMetadata);
+ AMediaFormat_delete(mTrackMetadata);
}
size_t MidiExtractor::countTracks()
@@ -282,7 +290,7 @@
return mInitCheck == OK ? 1 : 0;
}
-MediaTrack *MidiExtractor::getTrack(size_t index)
+MediaTrackHelperV2 *MidiExtractor::getTrack(size_t index)
{
if (mInitCheck != OK || index > 0) {
return NULL;
@@ -291,20 +299,20 @@
}
status_t MidiExtractor::getTrackMetaData(
- MetaDataBase &meta,
+ AMediaFormat *meta,
size_t index, uint32_t /* flags */) {
ALOGV("MidiExtractor::getTrackMetaData");
if (mInitCheck != OK || index > 0) {
return UNKNOWN_ERROR;
}
- meta = mTrackMetadata;
+ AMediaFormat_copy(meta, mTrackMetadata);
return OK;
}
-status_t MidiExtractor::getMetaData(MetaDataBase &meta)
+status_t MidiExtractor::getMetaData(AMediaFormat *meta)
{
ALOGV("MidiExtractor::getMetaData");
- meta = mFileMetadata;
+ AMediaFormat_copy(meta, mFileMetadata);
return OK;
}
@@ -323,27 +331,30 @@
}
+
extern "C" {
// This is the only symbol that needs to be exported
__attribute__ ((visibility ("default")))
ExtractorDef GETEXTRACTORDEF() {
return {
- EXTRACTORDEF_VERSION,
+ EXTRACTORDEF_VERSION_CURRENT,
UUID("ef6cca0a-f8a2-43e6-ba5f-dfcd7c9a7ef2"),
1,
"MIDI Extractor",
- [](
+ {
+ .v2 = [](
CDataSource *source,
float *confidence,
void **,
- FreeMetaFunc *) -> CreatorFunc {
- if (SniffMidi(source, confidence)) {
- return [](
- CDataSource *source,
- void *) -> CMediaExtractor* {
- return wrap(new MidiExtractor(source));};
+ FreeMetaFunc *) -> CreatorFuncV2 {
+ if (SniffMidi(source, confidence)) {
+ return [](
+ CDataSource *source,
+ void *) -> CMediaExtractorV2* {
+ return wrapV2(new MidiExtractor(source));};
+ }
+ return NULL;
}
- return NULL;
}
};
}
diff --git a/media/extractors/midi/MidiExtractor.h b/media/extractors/midi/MidiExtractor.h
index fbbe93e..d82c5be 100644
--- a/media/extractors/midi/MidiExtractor.h
+++ b/media/extractors/midi/MidiExtractor.h
@@ -22,8 +22,8 @@
#include <media/MediaExtractorPluginHelper.h>
#include <media/stagefright/MediaBufferBase.h>
#include <media/stagefright/MediaBufferGroup.h>
-#include <media/stagefright/MetaDataBase.h>
#include <media/MidiIoWrapper.h>
+#include <media/NdkMediaFormat.h>
#include <utils/String8.h>
#include <libsonivox/eas.h>
@@ -32,8 +32,8 @@
class MidiEngine {
public:
explicit MidiEngine(CDataSource *dataSource,
- MetaDataBase *fileMetadata,
- MetaDataBase *trackMetadata);
+ AMediaFormat *fileMetadata,
+ AMediaFormat *trackMetadata);
~MidiEngine();
status_t initCheck();
@@ -51,16 +51,16 @@
bool mIsInitialized;
};
-class MidiExtractor : public MediaExtractorPluginHelper {
+class MidiExtractor : public MediaExtractorPluginHelperV2 {
public:
explicit MidiExtractor(CDataSource *source);
virtual size_t countTracks();
- virtual MediaTrack *getTrack(size_t index);
- virtual status_t getTrackMetaData(MetaDataBase& meta, size_t index, uint32_t flags);
+ virtual MediaTrackHelperV2 *getTrack(size_t index);
+ virtual status_t getTrackMetaData(AMediaFormat *meta, size_t index, uint32_t flags);
- virtual status_t getMetaData(MetaDataBase& meta);
+ virtual status_t getMetaData(AMediaFormat *meta);
virtual const char * name() { return "MidiExtractor"; }
protected:
@@ -69,10 +69,10 @@
private:
CDataSource *mDataSource;
status_t mInitCheck;
- MetaDataBase mFileMetadata;
+ AMediaFormat *mFileMetadata;
// There is only one track
- MetaDataBase mTrackMetadata;
+ AMediaFormat *mTrackMetadata;
MidiEngine *mEngine;
diff --git a/media/extractors/mkv/MatroskaExtractor.cpp b/media/extractors/mkv/MatroskaExtractor.cpp
index a387970..73c8d17 100644
--- a/media/extractors/mkv/MatroskaExtractor.cpp
+++ b/media/extractors/mkv/MatroskaExtractor.cpp
@@ -23,7 +23,6 @@
#include <media/DataSourceBase.h>
#include <media/ExtractorUtils.h>
-#include <media/MediaTrack.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/AUtils.h>
#include <media/stagefright/foundation/ABuffer.h>
@@ -124,7 +123,7 @@
BlockIterator &operator=(const BlockIterator &);
};
-struct MatroskaSource : public MediaTrack {
+struct MatroskaSource : public MediaTrackHelper {
MatroskaSource(MatroskaExtractor *extractor, size_t index);
virtual status_t start(MetaDataBase *params);
@@ -1002,7 +1001,7 @@
return mTracks.size();
}
-MediaTrack *MatroskaExtractor::getTrack(size_t index) {
+MediaTrackHelper *MatroskaExtractor::getTrack(size_t index) {
if (index >= mTracks.size()) {
return NULL;
}
@@ -1646,19 +1645,21 @@
UUID("abbedd92-38c4-4904-a4c1-b3f45f899980"),
1,
"Matroska Extractor",
- [](
- CDataSource *source,
- float *confidence,
- void **,
- FreeMetaFunc *) -> CreatorFunc {
- DataSourceHelper helper(source);
- if (SniffMatroska(&helper, confidence)) {
- return [](
- CDataSource *source,
- void *) -> CMediaExtractor* {
- return wrap(new MatroskaExtractor(new DataSourceHelper(source)));};
+ {
+ [](
+ CDataSource *source,
+ float *confidence,
+ void **,
+ FreeMetaFunc *) -> CreatorFunc {
+ DataSourceHelper helper(source);
+ if (SniffMatroska(&helper, confidence)) {
+ return [](
+ CDataSource *source,
+ void *) -> CMediaExtractor* {
+ return wrap(new MatroskaExtractor(new DataSourceHelper(source)));};
+ }
+ return NULL;
}
- return NULL;
}
};
}
diff --git a/media/extractors/mkv/MatroskaExtractor.h b/media/extractors/mkv/MatroskaExtractor.h
index 2c6ca85..43971a0 100644
--- a/media/extractors/mkv/MatroskaExtractor.h
+++ b/media/extractors/mkv/MatroskaExtractor.h
@@ -40,7 +40,7 @@
virtual size_t countTracks();
- virtual MediaTrack *getTrack(size_t index);
+ virtual MediaTrackHelper *getTrack(size_t index);
virtual status_t getTrackMetaData(MetaDataBase& meta, size_t index, uint32_t flags);
diff --git a/media/extractors/mp3/MP3Extractor.cpp b/media/extractors/mp3/MP3Extractor.cpp
index a1e5593..e56a71b 100644
--- a/media/extractors/mp3/MP3Extractor.cpp
+++ b/media/extractors/mp3/MP3Extractor.cpp
@@ -24,7 +24,6 @@
#include "VBRISeeker.h"
#include "XINGSeeker.h"
-#include <media/MediaTrack.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/AMessage.h>
#include <media/stagefright/foundation/avc_utils.h>
@@ -208,7 +207,7 @@
return valid;
}
-class MP3Source : public MediaTrack {
+class MP3Source : public MediaTrackHelper {
public:
MP3Source(
MetaDataBase &meta, DataSourceHelper *source,
@@ -411,7 +410,7 @@
return mInitCheck != OK ? 0 : 1;
}
-MediaTrack *MP3Extractor::getTrack(size_t index) {
+MediaTrackHelper *MP3Extractor::getTrack(size_t index) {
if (mInitCheck != OK || index != 0) {
return NULL;
}
@@ -719,7 +718,7 @@
UUID("812a3f6c-c8cf-46de-b529-3774b14103d4"),
1, // version
"MP3 Extractor",
- Sniff
+ { Sniff }
};
}
diff --git a/media/extractors/mp3/MP3Extractor.h b/media/extractors/mp3/MP3Extractor.h
index 585d9f6..92e0665 100644
--- a/media/extractors/mp3/MP3Extractor.h
+++ b/media/extractors/mp3/MP3Extractor.h
@@ -38,7 +38,7 @@
~MP3Extractor();
virtual size_t countTracks();
- virtual MediaTrack *getTrack(size_t index);
+ virtual MediaTrackHelper *getTrack(size_t index);
virtual status_t getTrackMetaData(MetaDataBase& meta, size_t index, uint32_t flags);
virtual status_t getMetaData(MetaDataBase& meta);
diff --git a/media/extractors/mp4/MPEG4Extractor.cpp b/media/extractors/mp4/MPEG4Extractor.cpp
index 9d2f5d2..e3da6d8 100644
--- a/media/extractors/mp4/MPEG4Extractor.cpp
+++ b/media/extractors/mp4/MPEG4Extractor.cpp
@@ -34,7 +34,6 @@
#include <media/DataSourceBase.h>
#include <media/ExtractorUtils.h>
-#include <media/MediaTrack.h>
#include <media/stagefright/foundation/ABitReader.h>
#include <media/stagefright/foundation/ABuffer.h>
#include <media/stagefright/foundation/ADebug.h>
@@ -68,7 +67,7 @@
kMaxAtomSize = 64 * 1024 * 1024,
};
-class MPEG4Source : public MediaTrack {
+class MPEG4Source : public MediaTrackHelper {
static const size_t kMaxPcmFrameSize = 8192;
public:
// Caller retains ownership of both "dataSource" and "sampleTable".
@@ -3616,7 +3615,7 @@
}
}
-MediaTrack *MPEG4Extractor::getTrack(size_t index) {
+MediaTrackHelper *MPEG4Extractor::getTrack(size_t index) {
status_t err;
if ((err = readMetaData()) != OK) {
return NULL;
@@ -5970,7 +5969,7 @@
UUID("27575c67-4417-4c54-8d3d-8e626985a164"),
1, // version
"MP4 Extractor",
- Sniff
+ { Sniff }
};
}
diff --git a/media/extractors/mp4/MPEG4Extractor.h b/media/extractors/mp4/MPEG4Extractor.h
index b1e04c7..9b8de20 100644
--- a/media/extractors/mp4/MPEG4Extractor.h
+++ b/media/extractors/mp4/MPEG4Extractor.h
@@ -58,7 +58,7 @@
explicit MPEG4Extractor(DataSourceHelper *source, const char *mime = NULL);
virtual size_t countTracks();
- virtual MediaTrack *getTrack(size_t index);
+ virtual MediaTrackHelper *getTrack(size_t index);
virtual status_t getTrackMetaData(MetaDataBase& meta, size_t index, uint32_t flags);
virtual status_t getMetaData(MetaDataBase& meta);
diff --git a/media/extractors/mpeg2/ExtractorBundle.cpp b/media/extractors/mpeg2/ExtractorBundle.cpp
index 88c2d87..366aa59 100644
--- a/media/extractors/mpeg2/ExtractorBundle.cpp
+++ b/media/extractors/mpeg2/ExtractorBundle.cpp
@@ -35,24 +35,26 @@
UUID("3d1dcfeb-e40a-436d-a574-c2438a555e5f"),
1,
"MPEG2-PS/TS Extractor",
- [](
- CDataSource *source,
- float *confidence,
- void **,
- FreeMetaFunc *) -> CreatorFunc {
- DataSourceHelper helper(source);
- if (SniffMPEG2TS(&helper, confidence)) {
- return [](
- CDataSource *source,
- void *) -> CMediaExtractor* {
- return wrap(new MPEG2TSExtractor(new DataSourceHelper(source)));};
- } else if (SniffMPEG2PS(&helper, confidence)) {
- return [](
- CDataSource *source,
- void *) -> CMediaExtractor* {
- return wrap(new MPEG2PSExtractor(new DataSourceHelper(source)));};
+ {
+ [](
+ CDataSource *source,
+ float *confidence,
+ void **,
+ FreeMetaFunc *) -> CreatorFunc {
+ DataSourceHelper helper(source);
+ if (SniffMPEG2TS(&helper, confidence)) {
+ return [](
+ CDataSource *source,
+ void *) -> CMediaExtractor* {
+ return wrap(new MPEG2TSExtractor(new DataSourceHelper(source)));};
+ } else if (SniffMPEG2PS(&helper, confidence)) {
+ return [](
+ CDataSource *source,
+ void *) -> CMediaExtractor* {
+ return wrap(new MPEG2PSExtractor(new DataSourceHelper(source)));};
+ }
+ return NULL;
}
- return NULL;
}
};
}
diff --git a/media/extractors/mpeg2/MPEG2PSExtractor.cpp b/media/extractors/mpeg2/MPEG2PSExtractor.cpp
index ae1e6ba..577d1be 100644
--- a/media/extractors/mpeg2/MPEG2PSExtractor.cpp
+++ b/media/extractors/mpeg2/MPEG2PSExtractor.cpp
@@ -24,7 +24,6 @@
#include "mpeg2ts/ESQueue.h"
#include <media/DataSourceBase.h>
-#include <media/MediaTrack.h>
#include <media/stagefright/foundation/ABitReader.h>
#include <media/stagefright/foundation/ABuffer.h>
#include <media/stagefright/foundation/ADebug.h>
@@ -40,7 +39,7 @@
namespace android {
-struct MPEG2PSExtractor::Track : public MediaTrack, public RefBase {
+struct MPEG2PSExtractor::Track : public MediaTrackHelper, public RefBase {
Track(MPEG2PSExtractor *extractor,
unsigned stream_id, unsigned stream_type);
@@ -72,7 +71,7 @@
DISALLOW_EVIL_CONSTRUCTORS(Track);
};
-struct MPEG2PSExtractor::WrappedTrack : public MediaTrack {
+struct MPEG2PSExtractor::WrappedTrack : public MediaTrackHelper {
WrappedTrack(MPEG2PSExtractor *extractor, const sp<Track> &track);
virtual status_t start(MetaDataBase *params);
@@ -127,7 +126,7 @@
return mTracks.size();
}
-MediaTrack *MPEG2PSExtractor::getTrack(size_t index) {
+MediaTrackHelper *MPEG2PSExtractor::getTrack(size_t index) {
if (index >= mTracks.size()) {
return NULL;
}
@@ -681,7 +680,7 @@
}
}
- return mSource->read(buffer, options);
+ return mSource->read(buffer, (MediaSource::ReadOptions*)options);
}
status_t MPEG2PSExtractor::Track::appendPESData(
diff --git a/media/extractors/mpeg2/MPEG2PSExtractor.h b/media/extractors/mpeg2/MPEG2PSExtractor.h
index 7689910..c4082ef 100644
--- a/media/extractors/mpeg2/MPEG2PSExtractor.h
+++ b/media/extractors/mpeg2/MPEG2PSExtractor.h
@@ -36,7 +36,7 @@
explicit MPEG2PSExtractor(DataSourceHelper *source);
virtual size_t countTracks();
- virtual MediaTrack *getTrack(size_t index);
+ virtual MediaTrackHelper *getTrack(size_t index);
virtual status_t getTrackMetaData(MetaDataBase& meta, size_t index, uint32_t flags);
virtual status_t getMetaData(MetaDataBase& meta);
diff --git a/media/extractors/mpeg2/MPEG2TSExtractor.cpp b/media/extractors/mpeg2/MPEG2TSExtractor.cpp
index 0d7c831..c0826c9 100644
--- a/media/extractors/mpeg2/MPEG2TSExtractor.cpp
+++ b/media/extractors/mpeg2/MPEG2TSExtractor.cpp
@@ -26,7 +26,6 @@
#include <media/DataSourceBase.h>
#include <media/IStreamSource.h>
-#include <media/MediaTrack.h>
#include <media/stagefright/foundation/ABuffer.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/ALooper.h>
@@ -51,7 +50,7 @@
static const int kMaxDurationReadSize = 250000LL;
static const int kMaxDurationRetry = 6;
-struct MPEG2TSSource : public MediaTrack {
+struct MPEG2TSSource : public MediaTrackHelper {
MPEG2TSSource(
MPEG2TSExtractor *extractor,
const sp<AnotherPacketSource> &impl,
@@ -110,7 +109,7 @@
ReadOptions::SeekMode seekMode;
if (mDoesSeek && options && options->getSeekTo(&seekTimeUs, &seekMode)) {
// seek is needed
- status_t err = mExtractor->seek(seekTimeUs, seekMode);
+ status_t err = mExtractor->seek(seekTimeUs, (ReadOptions::SeekMode)seekMode);
if (err != OK) {
return err;
}
@@ -120,7 +119,7 @@
return ERROR_END_OF_STREAM;
}
- return mImpl->read(out, options);
+ return mImpl->read(out, (MediaSource::ReadOptions*) options);
}
////////////////////////////////////////////////////////////////////////////////
@@ -141,7 +140,7 @@
return mSourceImpls.size();
}
-MediaTrack *MPEG2TSExtractor::getTrack(size_t index) {
+MediaTrackHelper *MPEG2TSExtractor::getTrack(size_t index) {
if (index >= mSourceImpls.size()) {
return NULL;
}
@@ -483,7 +482,7 @@
}
status_t MPEG2TSExtractor::seek(int64_t seekTimeUs,
- const MediaTrack::ReadOptions::SeekMode &seekMode) {
+ const MediaTrackHelper::ReadOptions::SeekMode &seekMode) {
if (mSeekSyncPoints == NULL || mSeekSyncPoints->isEmpty()) {
ALOGW("No sync point to seek to.");
// ... and therefore we have nothing useful to do here.
@@ -504,18 +503,18 @@
}
switch (seekMode) {
- case MediaTrack::ReadOptions::SEEK_NEXT_SYNC:
+ case MediaTrackHelper::ReadOptions::SEEK_NEXT_SYNC:
if (index == mSeekSyncPoints->size()) {
ALOGW("Next sync not found; starting from the latest sync.");
--index;
}
break;
- case MediaTrack::ReadOptions::SEEK_CLOSEST_SYNC:
- case MediaTrack::ReadOptions::SEEK_CLOSEST:
+ case MediaTrackHelper::ReadOptions::SEEK_CLOSEST_SYNC:
+ case MediaTrackHelper::ReadOptions::SEEK_CLOSEST:
ALOGW("seekMode not supported: %d; falling back to PREVIOUS_SYNC",
seekMode);
FALLTHROUGH_INTENDED;
- case MediaTrack::ReadOptions::SEEK_PREVIOUS_SYNC:
+ case MediaTrackHelper::ReadOptions::SEEK_PREVIOUS_SYNC:
if (index == 0) {
ALOGW("Previous sync not found; starting from the earliest "
"sync.");
diff --git a/media/extractors/mpeg2/MPEG2TSExtractor.h b/media/extractors/mpeg2/MPEG2TSExtractor.h
index cdaede3..4013442 100644
--- a/media/extractors/mpeg2/MPEG2TSExtractor.h
+++ b/media/extractors/mpeg2/MPEG2TSExtractor.h
@@ -22,7 +22,6 @@
#include <media/stagefright/foundation/ABase.h>
#include <media/MediaExtractorPluginApi.h>
#include <media/MediaExtractorPluginHelper.h>
-#include <media/MediaTrack.h>
#include <media/stagefright/MetaDataBase.h>
#include <utils/threads.h>
#include <utils/KeyedVector.h>
@@ -43,7 +42,7 @@
explicit MPEG2TSExtractor(DataSourceHelper *source);
virtual size_t countTracks();
- virtual MediaTrack *getTrack(size_t index);
+ virtual MediaTrackHelper *getTrack(size_t index);
virtual status_t getTrackMetaData(MetaDataBase &meta, size_t index, uint32_t flags);
virtual status_t getMetaData(MetaDataBase& meta);
@@ -91,7 +90,7 @@
// the data has syntax error during parsing, etc.
status_t feedMore(bool isInit = false);
status_t seek(int64_t seekTimeUs,
- const MediaSource::ReadOptions::SeekMode& seekMode);
+ const MediaTrackHelper::ReadOptions::SeekMode& seekMode);
status_t queueDiscontinuityForSeek(int64_t actualSeekTimeUs);
status_t seekBeyond(int64_t seekTimeUs);
diff --git a/media/extractors/ogg/OggExtractor.cpp b/media/extractors/ogg/OggExtractor.cpp
index 4e97921..dc6b0b7 100644
--- a/media/extractors/ogg/OggExtractor.cpp
+++ b/media/extractors/ogg/OggExtractor.cpp
@@ -21,9 +21,9 @@
#include "OggExtractor.h"
#include <cutils/properties.h>
+#include <utils/Vector.h>
#include <media/DataSourceBase.h>
#include <media/ExtractorUtils.h>
-#include <media/MediaTrack.h>
#include <media/VorbisComment.h>
#include <media/stagefright/foundation/ABuffer.h>
#include <media/stagefright/foundation/ADebug.h>
@@ -47,7 +47,7 @@
namespace android {
-struct OggSource : public MediaTrack {
+struct OggSource : public MediaTrackHelper {
explicit OggSource(OggExtractor *extractor);
virtual status_t getFormat(MetaDataBase &);
@@ -1227,7 +1227,7 @@
return mInitCheck != OK ? 0 : 1;
}
-MediaTrack *OggExtractor::getTrack(size_t index) {
+MediaTrackHelper *OggExtractor::getTrack(size_t index) {
if (index >= 1) {
return NULL;
}
@@ -1280,7 +1280,7 @@
UUID("8cc5cd06-f772-495e-8a62-cba9649374e9"),
1, // version
"Ogg Extractor",
- Sniff
+ { Sniff }
};
}
diff --git a/media/extractors/ogg/OggExtractor.h b/media/extractors/ogg/OggExtractor.h
index fbd4663..c70f832 100644
--- a/media/extractors/ogg/OggExtractor.h
+++ b/media/extractors/ogg/OggExtractor.h
@@ -34,7 +34,7 @@
explicit OggExtractor(DataSourceHelper *source);
virtual size_t countTracks();
- virtual MediaTrack *getTrack(size_t index);
+ virtual MediaTrackHelper *getTrack(size_t index);
virtual status_t getTrackMetaData(MetaDataBase& meta, size_t index, uint32_t flags);
virtual status_t getMetaData(MetaDataBase& meta);
diff --git a/media/extractors/wav/Android.bp b/media/extractors/wav/Android.bp
index 067933e..d8b4144 100644
--- a/media/extractors/wav/Android.bp
+++ b/media/extractors/wav/Android.bp
@@ -9,6 +9,7 @@
shared_libs: [
"liblog",
"libmediaextractor",
+ "libmediandk",
],
static_libs: [
diff --git a/media/extractors/wav/WAVExtractor.cpp b/media/extractors/wav/WAVExtractor.cpp
index c739c2a..1b7c2e4 100644
--- a/media/extractors/wav/WAVExtractor.cpp
+++ b/media/extractors/wav/WAVExtractor.cpp
@@ -22,7 +22,6 @@
#include <audio_utils/primitives.h>
#include <media/DataSourceBase.h>
-#include <media/MediaTrack.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/MediaBufferGroup.h>
#include <media/stagefright/MediaDefs.h>
@@ -55,17 +54,17 @@
return ptr[1] << 8 | ptr[0];
}
-struct WAVSource : public MediaTrack {
+struct WAVSource : public MediaTrackHelperV2 {
WAVSource(
DataSourceHelper *dataSource,
- MetaDataBase &meta,
+ AMediaFormat *meta,
uint16_t waveFormat,
int32_t bitsPerSample,
off64_t offset, size_t size);
- virtual status_t start(MetaDataBase *params = NULL);
+ virtual status_t start(AMediaFormat *params = NULL);
virtual status_t stop();
- virtual status_t getFormat(MetaDataBase &meta);
+ virtual status_t getFormat(AMediaFormat *meta);
virtual status_t read(
MediaBufferBase **buffer, const ReadOptions *options = NULL);
@@ -79,7 +78,7 @@
static const size_t kMaxFrameSize;
DataSourceHelper *mDataSource;
- MetaDataBase &mMeta;
+ AMediaFormat *mMeta;
uint16_t mWaveFormat;
int32_t mSampleRate;
int32_t mNumChannels;
@@ -98,17 +97,19 @@
: mDataSource(source),
mValidFormat(false),
mChannelMask(CHANNEL_MASK_USE_CHANNEL_ORDER) {
+ mTrackMeta = AMediaFormat_new();
mInitCheck = init();
}
WAVExtractor::~WAVExtractor() {
delete mDataSource;
+ AMediaFormat_delete(mTrackMeta);
}
-status_t WAVExtractor::getMetaData(MetaDataBase &meta) {
- meta.clear();
+status_t WAVExtractor::getMetaData(AMediaFormat *meta) {
+ AMediaFormat_clear(meta);
if (mInitCheck == OK) {
- meta.setCString(kKeyMIMEType, MEDIA_MIMETYPE_CONTAINER_WAV);
+ AMediaFormat_setString(meta, AMEDIAFORMAT_KEY_MIME, MEDIA_MIMETYPE_CONTAINER_WAV);
}
return OK;
@@ -118,7 +119,7 @@
return mInitCheck == OK ? 1 : 0;
}
-MediaTrack *WAVExtractor::getTrack(size_t index) {
+MediaTrackHelperV2 *WAVExtractor::getTrack(size_t index) {
if (mInitCheck != OK || index > 0) {
return NULL;
}
@@ -129,13 +130,13 @@
}
status_t WAVExtractor::getTrackMetaData(
- MetaDataBase &meta,
+ AMediaFormat *meta,
size_t index, uint32_t /* flags */) {
if (mInitCheck != OK || index > 0) {
return UNKNOWN_ERROR;
}
- meta = mTrackMeta;
+ AMediaFormat_copy(meta, mTrackMeta);
return OK;
}
@@ -285,33 +286,34 @@
mDataOffset = offset;
mDataSize = chunkSize;
- mTrackMeta.clear();
+ AMediaFormat_clear(mTrackMeta);
switch (mWaveFormat) {
case WAVE_FORMAT_PCM:
case WAVE_FORMAT_IEEE_FLOAT:
- mTrackMeta.setCString(
- kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_RAW);
+ AMediaFormat_setString(mTrackMeta,
+ AMEDIAFORMAT_KEY_MIME, MEDIA_MIMETYPE_AUDIO_RAW);
break;
case WAVE_FORMAT_ALAW:
- mTrackMeta.setCString(
- kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_G711_ALAW);
+ AMediaFormat_setString(mTrackMeta,
+ AMEDIAFORMAT_KEY_MIME, MEDIA_MIMETYPE_AUDIO_G711_ALAW);
break;
case WAVE_FORMAT_MSGSM:
- mTrackMeta.setCString(
- kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_MSGSM);
+ AMediaFormat_setString(mTrackMeta,
+ AMEDIAFORMAT_KEY_MIME, MEDIA_MIMETYPE_AUDIO_MSGSM);
break;
default:
CHECK_EQ(mWaveFormat, (uint16_t)WAVE_FORMAT_MULAW);
- mTrackMeta.setCString(
- kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_G711_MLAW);
+ AMediaFormat_setString(mTrackMeta,
+ AMEDIAFORMAT_KEY_MIME, MEDIA_MIMETYPE_AUDIO_G711_MLAW);
break;
}
- mTrackMeta.setInt32(kKeyChannelCount, mNumChannels);
- mTrackMeta.setInt32(kKeyChannelMask, mChannelMask);
- mTrackMeta.setInt32(kKeySampleRate, mSampleRate);
- mTrackMeta.setInt32(kKeyPcmEncoding, kAudioEncodingPcm16bit);
+ AMediaFormat_setInt32(mTrackMeta, AMEDIAFORMAT_KEY_CHANNEL_COUNT, mNumChannels);
+ AMediaFormat_setInt32(mTrackMeta, AMEDIAFORMAT_KEY_CHANNEL_MASK, mChannelMask);
+ AMediaFormat_setInt32(mTrackMeta, AMEDIAFORMAT_KEY_SAMPLE_RATE, mSampleRate);
+ AMediaFormat_setInt32(mTrackMeta, AMEDIAFORMAT_KEY_PCM_ENCODING,
+ kAudioEncodingPcm16bit);
int64_t durationUs = 0;
if (mWaveFormat == WAVE_FORMAT_MSGSM) {
@@ -333,7 +335,7 @@
1000000LL * num_samples / mSampleRate;
}
- mTrackMeta.setInt64(kKeyDuration, durationUs);
+ AMediaFormat_setInt64(mTrackMeta, AMEDIAFORMAT_KEY_DURATION, durationUs);
return OK;
}
@@ -349,7 +351,7 @@
WAVSource::WAVSource(
DataSourceHelper *dataSource,
- MetaDataBase &meta,
+ AMediaFormat *meta,
uint16_t waveFormat,
int32_t bitsPerSample,
off64_t offset, size_t size)
@@ -363,10 +365,10 @@
mSize(size),
mStarted(false),
mGroup(NULL) {
- CHECK(mMeta.findInt32(kKeySampleRate, &mSampleRate));
- CHECK(mMeta.findInt32(kKeyChannelCount, &mNumChannels));
+ CHECK(AMediaFormat_getInt32(mMeta, AMEDIAFORMAT_KEY_SAMPLE_RATE, &mSampleRate));
+ CHECK(AMediaFormat_getInt32(mMeta, AMEDIAFORMAT_KEY_CHANNEL_COUNT, &mNumChannels));
- mMeta.setInt32(kKeyMaxInputSize, kMaxFrameSize);
+ AMediaFormat_setInt32(mMeta, AMEDIAFORMAT_KEY_MAX_INPUT_SIZE, kMaxFrameSize);
}
WAVSource::~WAVSource() {
@@ -375,7 +377,7 @@
}
}
-status_t WAVSource::start(MetaDataBase * /* params */) {
+status_t WAVSource::start(AMediaFormat * /* params */) {
ALOGV("WAVSource::start");
CHECK(!mStarted);
@@ -408,10 +410,10 @@
return OK;
}
-status_t WAVSource::getFormat(MetaDataBase &meta) {
+status_t WAVSource::getFormat(AMediaFormat *meta) {
ALOGV("WAVSource::getFormat");
- meta = mMeta;
+ AMediaFormat_copy(meta, mMeta);
return OK;
}
@@ -545,13 +547,13 @@
////////////////////////////////////////////////////////////////////////////////
-static CMediaExtractor* CreateExtractor(
+static CMediaExtractorV2* CreateExtractor(
CDataSource *source,
void *) {
- return wrap(new WAVExtractor(new DataSourceHelper(source)));
+ return wrapV2(new WAVExtractor(new DataSourceHelper(source)));
}
-static CreatorFunc Sniff(
+static CreatorFuncV2 Sniff(
CDataSource *source,
float *confidence,
void **,
@@ -585,11 +587,11 @@
__attribute__ ((visibility ("default")))
ExtractorDef GETEXTRACTORDEF() {
return {
- EXTRACTORDEF_VERSION,
+ EXTRACTORDEF_VERSION_CURRENT,
UUID("7d613858-5837-4a38-84c5-332d1cddee27"),
1, // version
"WAV Extractor",
- Sniff
+ { .v2 = Sniff }
};
}
diff --git a/media/extractors/wav/WAVExtractor.h b/media/extractors/wav/WAVExtractor.h
index 5136aa8..2822e80 100644
--- a/media/extractors/wav/WAVExtractor.h
+++ b/media/extractors/wav/WAVExtractor.h
@@ -21,7 +21,7 @@
#include <utils/Errors.h>
#include <media/MediaExtractorPluginApi.h>
#include <media/MediaExtractorPluginHelper.h>
-#include <media/stagefright/MetaDataBase.h>
+#include <media/NdkMediaFormat.h>
namespace android {
@@ -29,15 +29,15 @@
struct CDataSource;
class String8;
-class WAVExtractor : public MediaExtractorPluginHelper {
+class WAVExtractor : public MediaExtractorPluginHelperV2 {
public:
explicit WAVExtractor(DataSourceHelper *source);
virtual size_t countTracks();
- virtual MediaTrack *getTrack(size_t index);
- virtual status_t getTrackMetaData(MetaDataBase& meta, size_t index, uint32_t flags);
+ virtual MediaTrackHelperV2 *getTrack(size_t index);
+ virtual status_t getTrackMetaData(AMediaFormat *meta, size_t index, uint32_t flags);
- virtual status_t getMetaData(MetaDataBase& meta);
+ virtual status_t getMetaData(AMediaFormat *meta);
virtual const char * name() { return "WAVExtractor"; }
virtual ~WAVExtractor();
@@ -53,7 +53,7 @@
uint16_t mBitsPerSample;
off64_t mDataOffset;
size_t mDataSize;
- MetaDataBase mTrackMeta;
+ AMediaFormat *mTrackMeta;
status_t init();
diff --git a/media/libmedia/Android.bp b/media/libmedia/Android.bp
index e150f2b..bb87b10 100644
--- a/media/libmedia/Android.bp
+++ b/media/libmedia/Android.bp
@@ -266,18 +266,13 @@
},
}
-cc_library {
+cc_library_static {
name: "libmedia_player2_util",
srcs: [
"BufferingSettings.cpp",
"DataSourceDesc.cpp",
- "IDataSource.cpp",
- "IMediaExtractor.cpp",
- "IMediaExtractorService.cpp",
- "IMediaSource.cpp",
"MediaCodecBuffer.cpp",
- "MediaUtils.cpp",
"Metadata.cpp",
"NdkWrapper.cpp",
],
diff --git a/media/libmedia/NdkWrapper.cpp b/media/libmedia/NdkWrapper.cpp
index 272bc30..7d67262 100644
--- a/media/libmedia/NdkWrapper.cpp
+++ b/media/libmedia/NdkWrapper.cpp
@@ -31,18 +31,6 @@
#include <media/stagefright/foundation/AMessage.h>
#include <utils/Errors.h>
-// TODO: remove forward declaration when AMediaExtractor_disconnect is offcially added to NDK
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-media_status_t AMediaExtractor_disconnect(AMediaExtractor *);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
namespace android {
static const size_t kAESBlockSize = 16; // AES_BLOCK_SIZE
@@ -1080,14 +1068,6 @@
return OK;
}
-status_t AMediaExtractorWrapper::disconnect() {
- if (mAMediaExtractor != NULL) {
- media_status_t err = AMediaExtractor_disconnect(mAMediaExtractor);
- return translateErrorCode(err);
- }
- return DEAD_OBJECT;
-}
-
AMediaExtractor *AMediaExtractorWrapper::getAMediaExtractor() const {
return mAMediaExtractor;
}
diff --git a/media/libmedia/include/media/NdkWrapper.h b/media/libmedia/include/media/NdkWrapper.h
index c97d171..191665a 100644
--- a/media/libmedia/include/media/NdkWrapper.h
+++ b/media/libmedia/include/media/NdkWrapper.h
@@ -287,8 +287,6 @@
status_t release();
- status_t disconnect();
-
status_t setDataSource(int fd, off64_t offset, off64_t length);
status_t setDataSource(const char *location);
diff --git a/media/libmediaextractor/Android.bp b/media/libmediaextractor/Android.bp
index 0208ad4..cf7d74f 100644
--- a/media/libmediaextractor/Android.bp
+++ b/media/libmediaextractor/Android.bp
@@ -28,7 +28,6 @@
"MediaBufferBase.cpp",
"MediaBufferGroup.cpp",
"MediaSource.cpp",
- "MediaTrack.cpp",
"MetaData.cpp",
"MetaDataBase.cpp",
"VorbisComment.cpp",
diff --git a/media/libmediaextractor/MediaTrack.cpp b/media/libmediaextractor/MediaTrack.cpp
deleted file mode 100644
index 4963f58..0000000
--- a/media/libmediaextractor/MediaTrack.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-#include <media/MediaTrack.h>
-
-namespace android {
-
-MediaTrack::MediaTrack() {}
-
-MediaTrack::~MediaTrack() {}
-
-////////////////////////////////////////////////////////////////////////////////
-
-MediaTrack::ReadOptions::ReadOptions() {
- reset();
-}
-
-void MediaTrack::ReadOptions::reset() {
- mOptions = 0;
- mSeekTimeUs = 0;
- mNonBlocking = false;
-}
-
-void MediaTrack::ReadOptions::setNonBlocking() {
- mNonBlocking = true;
-}
-
-void MediaTrack::ReadOptions::clearNonBlocking() {
- mNonBlocking = false;
-}
-
-bool MediaTrack::ReadOptions::getNonBlocking() const {
- return mNonBlocking;
-}
-
-void MediaTrack::ReadOptions::setSeekTo(int64_t time_us, SeekMode mode) {
- mOptions |= kSeekTo_Option;
- mSeekTimeUs = time_us;
- mSeekMode = mode;
-}
-
-void MediaTrack::ReadOptions::clearSeekTo() {
- mOptions &= ~kSeekTo_Option;
- mSeekTimeUs = 0;
- mSeekMode = SEEK_CLOSEST_SYNC;
-}
-
-bool MediaTrack::ReadOptions::getSeekTo(
- int64_t *time_us, SeekMode *mode) const {
- *time_us = mSeekTimeUs;
- *mode = mSeekMode;
- return (mOptions & kSeekTo_Option) != 0;
-}
-
-} // namespace android
diff --git a/media/libmediaextractor/include/media/DataSourceBase.h b/media/libmediaextractor/include/media/DataSourceBase.h
index fc620fd..8ce6592 100644
--- a/media/libmediaextractor/include/media/DataSourceBase.h
+++ b/media/libmediaextractor/include/media/DataSourceBase.h
@@ -66,8 +66,6 @@
virtual void close() {};
- virtual void disconnect() {}
-
virtual ssize_t getAvailableSize(status_t * /*err*/) {
return -1;
}
diff --git a/media/libmediaplayer2/Android.bp b/media/libmediaplayer2/Android.bp
index e30da85..a26cc81 100644
--- a/media/libmediaplayer2/Android.bp
+++ b/media/libmediaplayer2/Android.bp
@@ -4,7 +4,7 @@
export_include_dirs: ["include"],
}
-cc_library {
+cc_library_static {
name: "libmediaplayer2",
srcs: [
@@ -20,14 +20,12 @@
"libgui",
"liblog",
"libmedia_omx",
- "libmedia_player2_util",
"libmediaextractor",
"libstagefright_foundation",
"libui",
"libutils",
"libcrypto",
- "libmediadrm",
"libmediametrics",
"libmediandk",
"libmediautils",
@@ -35,7 +33,6 @@
"libnativewindow",
"libpowermanager",
"libstagefright_httplive",
- "libstagefright_player2",
],
export_shared_lib_headers: [
@@ -55,8 +52,10 @@
static_libs: [
"libmedia_helper",
"libmediaplayer2-protos",
+ "libmedia_player2_util",
"libprotobuf-cpp-lite",
"libstagefright_nuplayer2",
+ "libstagefright_player2",
"libstagefright_rtsp",
"libstagefright_timedtext2",
],
diff --git a/media/libmediaplayer2/include/mediaplayer2/MediaPlayer2Types.h b/media/libmediaplayer2/include/mediaplayer2/MediaPlayer2Types.h
index 1fe2efa..10e07ea 100644
--- a/media/libmediaplayer2/include/mediaplayer2/MediaPlayer2Types.h
+++ b/media/libmediaplayer2/include/mediaplayer2/MediaPlayer2Types.h
@@ -154,8 +154,8 @@
enum mediaplayer2_states {
MEDIAPLAYER2_STATE_IDLE = 1001,
MEDIAPLAYER2_STATE_PREPARED = 1002,
- MEDIAPLAYER2_STATE_PLAYING = 1003,
- MEDIAPLAYER2_STATE_PAUSED = 1004,
+ MEDIAPLAYER2_STATE_PAUSED = 1003,
+ MEDIAPLAYER2_STATE_PLAYING = 1004,
MEDIAPLAYER2_STATE_ERROR = 1005,
};
diff --git a/media/libmediaplayer2/mediaplayer2.cpp b/media/libmediaplayer2/mediaplayer2.cpp
index bafd32c..d9c9826 100644
--- a/media/libmediaplayer2/mediaplayer2.cpp
+++ b/media/libmediaplayer2/mediaplayer2.cpp
@@ -660,7 +660,7 @@
Mutex::Autolock _l(mLock);
if (mCurrentState & (MEDIA_PLAYER2_PAUSED|MEDIA_PLAYER2_PLAYBACK_COMPLETE))
return NO_ERROR;
- if ((mPlayer != 0) && (mCurrentState & MEDIA_PLAYER2_STARTED)) {
+ if ((mPlayer != 0) && (mCurrentState & (MEDIA_PLAYER2_STARTED | MEDIA_PLAYER2_PREPARED))) {
status_t ret = mPlayer->pause();
if (ret != NO_ERROR) {
mCurrentState = MEDIA_PLAYER2_STATE_ERROR;
diff --git a/media/libmediaplayer2/nuplayer2/Android.bp b/media/libmediaplayer2/nuplayer2/Android.bp
index 7cf4522..26da491 100644
--- a/media/libmediaplayer2/nuplayer2/Android.bp
+++ b/media/libmediaplayer2/nuplayer2/Android.bp
@@ -48,7 +48,6 @@
"libui",
"libgui",
"libmedia",
- "libmediadrm",
"libmediandk",
"libpowermanager",
],
diff --git a/media/libmediaplayer2/nuplayer2/NuPlayer2.cpp b/media/libmediaplayer2/nuplayer2/NuPlayer2.cpp
index e51727b..5bd1674 100644
--- a/media/libmediaplayer2/nuplayer2/NuPlayer2.cpp
+++ b/media/libmediaplayer2/nuplayer2/NuPlayer2.cpp
@@ -969,7 +969,7 @@
onResume();
}
} else {
- onStart();
+ onStart(true /* play */);
}
mPausedByClient = false;
notifyListener(mSrcId, MEDIA2_STARTED, 0, 0);
@@ -1502,6 +1502,9 @@
case kWhatPause:
{
+ if (!mStarted) {
+ onStart(false /* play */);
+ }
onPause();
notifyListener(mSrcId, MEDIA2_PAUSED, 0, 0);
mPausedByClient = true;
@@ -1575,7 +1578,7 @@
startPlaybackTimer("onresume");
}
-void NuPlayer2::onStart() {
+void NuPlayer2::onStart(bool play) {
ALOGV("onStart: mCrypto: %p", mCrypto.get());
if (!mSourceStarted) {
@@ -1649,6 +1652,11 @@
mRenderer->setVideoFrameRate(rate);
}
+ // Renderer is created in paused state.
+ if (play) {
+ mRenderer->resume();
+ }
+
if (mVideoDecoder != NULL) {
mVideoDecoder->setRenderer(mRenderer);
}
@@ -2472,7 +2480,7 @@
mRenderer->resume();
}
- onStart();
+ onStart(true /* play */);
mPausedByClient = false;
notifyListener(mSrcId, MEDIA2_STARTED, 0, 0);
}
diff --git a/media/libmediaplayer2/nuplayer2/NuPlayer2.h b/media/libmediaplayer2/nuplayer2/NuPlayer2.h
index 77845ac..e55cdbe 100644
--- a/media/libmediaplayer2/nuplayer2/NuPlayer2.h
+++ b/media/libmediaplayer2/nuplayer2/NuPlayer2.h
@@ -301,7 +301,7 @@
void handleFlushComplete(bool audio, bool isDecoder);
void finishFlushIfPossible();
- void onStart();
+ void onStart(bool play);
void onResume();
void onPause();
diff --git a/media/libmediaplayer2/nuplayer2/NuPlayer2Driver.cpp b/media/libmediaplayer2/nuplayer2/NuPlayer2Driver.cpp
index b02e3f6..cb4b06d 100644
--- a/media/libmediaplayer2/nuplayer2/NuPlayer2Driver.cpp
+++ b/media/libmediaplayer2/nuplayer2/NuPlayer2Driver.cpp
@@ -327,9 +327,9 @@
switch (mState) {
case STATE_PAUSED:
- case STATE_PREPARED:
return OK;
+ case STATE_PREPARED:
case STATE_RUNNING:
mState = STATE_PAUSED;
mPlayer->pause();
diff --git a/media/libmediaplayer2/nuplayer2/NuPlayer2Renderer.cpp b/media/libmediaplayer2/nuplayer2/NuPlayer2Renderer.cpp
index 021ddde..c5ce15a 100644
--- a/media/libmediaplayer2/nuplayer2/NuPlayer2Renderer.cpp
+++ b/media/libmediaplayer2/nuplayer2/NuPlayer2Renderer.cpp
@@ -115,7 +115,7 @@
mNotifyCompleteAudio(false),
mNotifyCompleteVideo(false),
mSyncQueues(false),
- mPaused(false),
+ mPaused(true),
mPauseDrainAudioAllowedUs(0),
mVideoSampleReceived(false),
mVideoRenderingStarted(false),
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index 3526047..f720667 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -1619,7 +1619,7 @@
if (portIndex == kPortIndexOutput && mNativeWindow != NULL) {
(void)cancelBufferToNativeWindow(info);
}
- // fall through
+ FALLTHROUGH_INTENDED;
case BufferInfo::OWNED_BY_NATIVE_WINDOW:
err = mOMXNode->freeBuffer(portIndex, info->mBufferID);
@@ -5019,6 +5019,7 @@
}
}
// Fall through to set up mime.
+ FALLTHROUGH_INTENDED;
}
default:
@@ -5383,7 +5384,7 @@
AudioEncoding pcmEncoding = kAudioEncodingPcm16bit;
(void)mConfigFormat->findInt32("pcm-encoding", (int32_t*)&pcmEncoding);
AudioEncoding codecPcmEncoding = kAudioEncodingPcm16bit;
- (void)mOutputFormat->findInt32("pcm-encoding", (int32_t*)&pcmEncoding);
+ (void)mOutputFormat->findInt32("pcm-encoding", (int32_t*)&codecPcmEncoding);
mConverter[kPortIndexOutput] = AudioConverter::Create(codecPcmEncoding, pcmEncoding);
if (mConverter[kPortIndexOutput] != NULL) {
@@ -7854,7 +7855,7 @@
msg->setInt32("generation", mCodec->mStateGeneration);
msg->post(3000000);
}
- // fall-through
+ FALLTHROUGH_INTENDED;
}
case kWhatResume:
case kWhatSetParameters:
diff --git a/media/libstagefright/Android.bp b/media/libstagefright/Android.bp
index ae2f61b..90a7eb5 100644
--- a/media/libstagefright/Android.bp
+++ b/media/libstagefright/Android.bp
@@ -124,6 +124,7 @@
"MediaExtractor.cpp",
"MediaExtractorFactory.cpp",
"MediaSync.cpp",
+ "MediaTrack.cpp",
"http/ClearMediaHTTP.cpp",
"http/MediaHTTP.cpp",
"MediaMuxer.cpp",
@@ -230,7 +231,7 @@
},
}
-cc_library {
+cc_library_static {
name: "libstagefright_player2",
srcs: [
@@ -259,7 +260,6 @@
"libcutils",
"libgui",
"liblog",
- "libmedia_player2_util",
"libaudioclient",
"libmediaextractor",
"libmediametrics",
@@ -274,16 +274,13 @@
static_libs: [
"libstagefright_esds",
+ "libmedia_player2_util",
],
header_libs:[
"media_plugin_headers",
],
- export_shared_lib_headers: [
- "libmedia_player2_util",
- ],
-
export_include_dirs: [
"include",
],
diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp
index f91c543..70064ea 100644
--- a/media/libstagefright/MediaCodec.cpp
+++ b/media/libstagefright/MediaCodec.cpp
@@ -1829,8 +1829,8 @@
// the shutdown complete notification. If we
// don't, we'll timeout and force release.
sendErrorResponse = false;
+ FALLTHROUGH_INTENDED;
}
- // fall-thru
case STOPPING:
{
if (mFlags & kFlagSawMediaServerDie) {
diff --git a/media/libstagefright/MediaExtractor.cpp b/media/libstagefright/MediaExtractor.cpp
index 5e1dc77..e00c3c8 100644
--- a/media/libstagefright/MediaExtractor.cpp
+++ b/media/libstagefright/MediaExtractor.cpp
@@ -22,6 +22,8 @@
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/MediaExtractor.h>
#include <media/stagefright/MetaData.h>
+#include <media/stagefright/Utils.h>
+#include <media/NdkMediaFormatPriv.h>
namespace android {
@@ -40,42 +42,95 @@
}
// --------------------------------------------------------------------------------
-MediaExtractorCUnwrapper::MediaExtractorCUnwrapper(CMediaExtractor *wrapper) {
- this->wrapper = wrapper;
+MediaExtractorCUnwrapperV1::MediaExtractorCUnwrapperV1(CMediaExtractor *plugin) {
+ this->plugin = plugin;
}
-MediaExtractorCUnwrapper::~MediaExtractorCUnwrapper() {
- wrapper->free(wrapper->data);
- free(wrapper);
+MediaExtractorCUnwrapperV1::~MediaExtractorCUnwrapperV1() {
+ plugin->free(plugin->data);
+ free(plugin);
}
-size_t MediaExtractorCUnwrapper::countTracks() {
- return wrapper->countTracks(wrapper->data);
+size_t MediaExtractorCUnwrapperV1::countTracks() {
+ return plugin->countTracks(plugin->data);
}
-MediaTrack *MediaExtractorCUnwrapper::getTrack(size_t index) {
- return wrapper->getTrack(wrapper->data, index);
+MediaTrack *MediaExtractorCUnwrapperV1::getTrack(size_t index) {
+ return new MediaTrackCUnwrapper(plugin->getTrack(plugin->data, index));
}
-status_t MediaExtractorCUnwrapper::getTrackMetaData(
+status_t MediaExtractorCUnwrapperV1::getTrackMetaData(
MetaDataBase& meta, size_t index, uint32_t flags) {
- return wrapper->getTrackMetaData(wrapper->data, meta, index, flags);
+ return plugin->getTrackMetaData(plugin->data, meta, index, flags);
}
-status_t MediaExtractorCUnwrapper::getMetaData(MetaDataBase& meta) {
- return wrapper->getMetaData(wrapper->data, meta);
+status_t MediaExtractorCUnwrapperV1::getMetaData(MetaDataBase& meta) {
+ return plugin->getMetaData(plugin->data, meta);
}
-const char * MediaExtractorCUnwrapper::name() {
- return wrapper->name(wrapper->data);
+const char * MediaExtractorCUnwrapperV1::name() {
+ return plugin->name(plugin->data);
}
-uint32_t MediaExtractorCUnwrapper::flags() const {
- return wrapper->flags(wrapper->data);
+uint32_t MediaExtractorCUnwrapperV1::flags() const {
+ return plugin->flags(plugin->data);
}
-status_t MediaExtractorCUnwrapper::setMediaCas(const uint8_t* casToken, size_t size) {
- return wrapper->setMediaCas(wrapper->data, casToken, size);
+status_t MediaExtractorCUnwrapperV1::setMediaCas(const uint8_t* casToken, size_t size) {
+ return plugin->setMediaCas(plugin->data, casToken, size);
+}
+
+// --------------------------------------------------------------------------------
+MediaExtractorCUnwrapperV2::MediaExtractorCUnwrapperV2(CMediaExtractorV2 *plugin) {
+ this->plugin = plugin;
+}
+
+MediaExtractorCUnwrapperV2::~MediaExtractorCUnwrapperV2() {
+ plugin->free(plugin->data);
+ free(plugin);
+}
+
+size_t MediaExtractorCUnwrapperV2::countTracks() {
+ return plugin->countTracks(plugin->data);
+}
+
+MediaTrack *MediaExtractorCUnwrapperV2::getTrack(size_t index) {
+ return new MediaTrackCUnwrapperV2(plugin->getTrack(plugin->data, index));
+}
+
+status_t MediaExtractorCUnwrapperV2::getTrackMetaData(
+ MetaDataBase& meta, size_t index, uint32_t flags) {
+ sp<AMessage> msg = new AMessage();
+ AMediaFormat *format = AMediaFormat_fromMsg(&msg);
+ status_t ret = plugin->getTrackMetaData(plugin->data, format, index, flags);
+ sp<MetaData> newMeta = new MetaData();
+ convertMessageToMetaData(msg, newMeta);
+ delete format;
+ meta = *newMeta;
+ return ret;
+}
+
+status_t MediaExtractorCUnwrapperV2::getMetaData(MetaDataBase& meta) {
+ sp<AMessage> msg = new AMessage();
+ AMediaFormat *format = AMediaFormat_fromMsg(&msg);
+ status_t ret = plugin->getMetaData(plugin->data, format);
+ sp<MetaData> newMeta = new MetaData();
+ convertMessageToMetaData(msg, newMeta);
+ delete format;
+ meta = *newMeta;
+ return ret;
+}
+
+const char * MediaExtractorCUnwrapperV2::name() {
+ return plugin->name(plugin->data);
+}
+
+uint32_t MediaExtractorCUnwrapperV2::flags() const {
+ return plugin->flags(plugin->data);
+}
+
+status_t MediaExtractorCUnwrapperV2::setMediaCas(const uint8_t* casToken, size_t size) {
+ return plugin->setMediaCas(plugin->data, casToken, size);
}
} // namespace android
diff --git a/media/libstagefright/MediaExtractorFactory.cpp b/media/libstagefright/MediaExtractorFactory.cpp
index a0a3a75..8f1dd36 100644
--- a/media/libstagefright/MediaExtractorFactory.cpp
+++ b/media/libstagefright/MediaExtractorFactory.cpp
@@ -74,22 +74,32 @@
source->DrmInitialization(nullptr /* mime */);
void *meta = nullptr;
- CreatorFunc creator = NULL;
+ void *creator = NULL;
FreeMetaFunc freeMeta = nullptr;
float confidence;
sp<ExtractorPlugin> plugin;
- creator = sniff(source, &confidence, &meta, &freeMeta, plugin);
+ uint32_t creatorVersion = 0;
+ creator = sniff(source, &confidence, &meta, &freeMeta, plugin, &creatorVersion);
if (!creator) {
ALOGV("FAILED to autodetect media content.");
return NULL;
}
- CMediaExtractor *ret = creator(source->wrap(), meta);
- if (meta != nullptr && freeMeta != nullptr) {
- freeMeta(meta);
+ MediaExtractor *ex = nullptr;
+ if (creatorVersion == 1) {
+ CMediaExtractor *ret = ((CreatorFuncV1)creator)(source->wrap(), meta);
+ if (meta != nullptr && freeMeta != nullptr) {
+ freeMeta(meta);
+ }
+ ex = ret != nullptr ? new MediaExtractorCUnwrapperV1(ret) : nullptr;
+ } else if (creatorVersion == 2) {
+ CMediaExtractorV2 *ret = ((CreatorFuncV2)creator)(source->wrap(), meta);
+ if (meta != nullptr && freeMeta != nullptr) {
+ freeMeta(meta);
+ }
+ ex = ret != nullptr ? new MediaExtractorCUnwrapperV2(ret) : nullptr;
}
- MediaExtractor *ex = ret != nullptr ? new MediaExtractorCUnwrapper(ret) : nullptr;
ALOGV("Created an extractor '%s' with confidence %.2f",
ex != nullptr ? ex->name() : "<null>", confidence);
@@ -129,9 +139,9 @@
bool MediaExtractorFactory::gIgnoreVersion = false;
// static
-CreatorFunc MediaExtractorFactory::sniff(
+void *MediaExtractorFactory::sniff(
const sp<DataSource> &source, float *confidence, void **meta,
- FreeMetaFunc *freeMeta, sp<ExtractorPlugin> &plugin) {
+ FreeMetaFunc *freeMeta, sp<ExtractorPlugin> &plugin, uint32_t *creatorVersion) {
*confidence = 0.0f;
*meta = nullptr;
@@ -144,15 +154,23 @@
plugins = gPlugins;
}
- CreatorFunc curCreator = NULL;
- CreatorFunc bestCreator = NULL;
+ void *bestCreator = NULL;
for (auto it = plugins->begin(); it != plugins->end(); ++it) {
ALOGV("sniffing %s", (*it)->def.extractor_name);
float newConfidence;
void *newMeta = nullptr;
FreeMetaFunc newFreeMeta = nullptr;
- if ((curCreator = (*it)->def.sniff(
- source->wrap(), &newConfidence, &newMeta, &newFreeMeta))) {
+
+ void *curCreator = NULL;
+ if ((*it)->def.def_version == 1) {
+ curCreator = (void*) (*it)->def.sniff.v1(
+ source->wrap(), &newConfidence, &newMeta, &newFreeMeta);
+ } else if ((*it)->def.def_version == 2) {
+ curCreator = (void*) (*it)->def.sniff.v2(
+ source->wrap(), &newConfidence, &newMeta, &newFreeMeta);
+ }
+
+ if (curCreator) {
if (newConfidence > *confidence) {
*confidence = newConfidence;
if (*meta != nullptr && *freeMeta != nullptr) {
@@ -162,6 +180,7 @@
*freeMeta = newFreeMeta;
plugin = *it;
bestCreator = curCreator;
+ *creatorVersion = (*it)->def.def_version;
} else {
if (newMeta != nullptr && newFreeMeta != nullptr) {
newFreeMeta(newMeta);
@@ -178,7 +197,7 @@
std::list<sp<ExtractorPlugin>> &pluginList) {
// sanity check check struct version, uuid, name
if (plugin->def.def_version == 0
- || plugin->def.def_version > EXTRACTORDEF_VERSION) {
+ || plugin->def.def_version > EXTRACTORDEF_VERSION_CURRENT) {
ALOGE("don't understand extractor format %u, ignoring.", plugin->def.def_version);
return;
}
@@ -271,6 +290,9 @@
if (libDir) {
struct dirent* libEntry;
while ((libEntry = readdir(libDir))) {
+ if (libEntry->d_name[0] == '.') {
+ continue;
+ }
String8 libPath = String8(libDirPath) + "/" + libEntry->d_name;
void *libHandle = dlopen(libPath.string(), RTLD_NOW | RTLD_LOCAL);
if (libHandle) {
@@ -334,8 +356,9 @@
out.append("Available extractors:\n");
if (gPluginsRegistered) {
for (auto it = gPlugins->begin(); it != gPlugins->end(); ++it) {
- out.appendFormat(" %25s: uuid(%s), version(%u), path(%s)\n",
+ out.appendFormat(" %25s: plugin_version(%d), uuid(%s), version(%u), path(%s)\n",
(*it)->def.extractor_name,
+ (*it)->def.def_version,
(*it)->uuidString.c_str(),
(*it)->def.extractor_version,
(*it)->libPath.c_str());
diff --git a/media/libstagefright/MediaTrack.cpp b/media/libstagefright/MediaTrack.cpp
new file mode 100644
index 0000000..792b317
--- /dev/null
+++ b/media/libstagefright/MediaTrack.cpp
@@ -0,0 +1,160 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+#include <mutex>
+
+#include <media/stagefright/foundation/AMessage.h>
+#include <media/stagefright/Utils.h>
+
+#include <media/MediaTrack.h>
+#include <media/MediaExtractorPluginApi.h>
+#include <media/NdkMediaFormatPriv.h>
+
+namespace android {
+
+MediaTrack::MediaTrack() {}
+
+MediaTrack::~MediaTrack() {}
+
+////////////////////////////////////////////////////////////////////////////////
+
+void MediaTrack::ReadOptions::setNonBlocking() {
+ mNonBlocking = true;
+}
+
+void MediaTrack::ReadOptions::clearNonBlocking() {
+ mNonBlocking = false;
+}
+
+bool MediaTrack::ReadOptions::getNonBlocking() const {
+ return mNonBlocking;
+}
+
+void MediaTrack::ReadOptions::setSeekTo(int64_t time_us, SeekMode mode) {
+ mOptions |= kSeekTo_Option;
+ mSeekTimeUs = time_us;
+ mSeekMode = mode;
+}
+
+bool MediaTrack::ReadOptions::getSeekTo(
+ int64_t *time_us, SeekMode *mode) const {
+ *time_us = mSeekTimeUs;
+ *mode = mSeekMode;
+ return (mOptions & kSeekTo_Option) != 0;
+}
+
+/* -------------- unwrapper v1 --------------- */
+
+MediaTrackCUnwrapper::MediaTrackCUnwrapper(CMediaTrack *cmediatrack) {
+ wrapper = cmediatrack;
+}
+
+MediaTrackCUnwrapper::~MediaTrackCUnwrapper() {
+ wrapper->free(wrapper->data);
+ free(wrapper);
+}
+
+status_t MediaTrackCUnwrapper::start(MetaDataBase *params) {
+ return wrapper->start(wrapper->data, params);
+}
+
+status_t MediaTrackCUnwrapper::stop() {
+ return wrapper->stop(wrapper->data);
+}
+
+status_t MediaTrackCUnwrapper::getFormat(MetaDataBase& format) {
+ return wrapper->getFormat(wrapper->data, format);
+}
+
+status_t MediaTrackCUnwrapper::read(MediaBufferBase **buffer, const ReadOptions *options) {
+
+ uint32_t opts = 0;
+
+ if (options->getNonBlocking()) {
+ opts |= CMediaTrackReadOptions::NONBLOCKING;
+ }
+
+ int64_t seekPosition = 0;
+ MediaTrack::ReadOptions::SeekMode seekMode;
+ if (options->getSeekTo(&seekPosition, &seekMode)) {
+ opts |= SEEK;
+ opts |= (uint32_t) seekMode;
+ }
+
+
+ return wrapper->read(wrapper->data, buffer, opts, seekPosition);
+}
+
+bool MediaTrackCUnwrapper::supportNonblockingRead() {
+ return wrapper->supportsNonBlockingRead(wrapper->data);
+}
+
+/* -------------- unwrapper v2 --------------- */
+
+MediaTrackCUnwrapperV2::MediaTrackCUnwrapperV2(CMediaTrackV2 *cmediatrack2) {
+ wrapper = cmediatrack2;
+}
+
+MediaTrackCUnwrapperV2::~MediaTrackCUnwrapperV2() {
+}
+
+status_t MediaTrackCUnwrapperV2::start(MetaDataBase *meta) {
+ sp<AMessage> msg;
+ convertMetaDataToMessage(meta, &msg);
+ AMediaFormat *format = AMediaFormat_fromMsg(&msg);
+ status_t ret = wrapper->start(wrapper->data, format);
+ delete format;
+ return ret;
+}
+
+status_t MediaTrackCUnwrapperV2::stop() {
+ return wrapper->stop(wrapper->data);
+}
+
+status_t MediaTrackCUnwrapperV2::getFormat(MetaDataBase& format) {
+ sp<AMessage> msg = new AMessage();
+ AMediaFormat *tmpFormat = AMediaFormat_fromMsg(&msg);
+ status_t ret = wrapper->getFormat(wrapper->data, tmpFormat);
+ sp<MetaData> newMeta = new MetaData();
+ convertMessageToMetaData(msg, newMeta);
+ delete tmpFormat;
+ format = *newMeta;
+ return ret;
+}
+
+status_t MediaTrackCUnwrapperV2::read(MediaBufferBase **buffer, const ReadOptions *options) {
+
+ uint32_t opts = 0;
+
+ if (options->getNonBlocking()) {
+ opts |= CMediaTrackReadOptions::NONBLOCKING;
+ }
+
+ int64_t seekPosition = 0;
+ MediaTrack::ReadOptions::SeekMode seekMode;
+ if (options->getSeekTo(&seekPosition, &seekMode)) {
+ opts |= SEEK;
+ opts |= (uint32_t) seekMode;
+ }
+
+ return wrapper->read(wrapper->data, buffer, opts, seekPosition);
+}
+
+bool MediaTrackCUnwrapperV2::supportNonblockingRead() {
+ return wrapper->supportsNonBlockingRead(wrapper->data);
+}
+
+} // namespace android
diff --git a/media/libstagefright/NuCachedSource2.cpp b/media/libstagefright/NuCachedSource2.cpp
index 18f4b12..81ca3e7 100644
--- a/media/libstagefright/NuCachedSource2.cpp
+++ b/media/libstagefright/NuCachedSource2.cpp
@@ -256,6 +256,10 @@
return ERROR_UNSUPPORTED;
}
+void NuCachedSource2::close() {
+ disconnect();
+}
+
void NuCachedSource2::disconnect() {
if (mSource->flags() & kIsHTTPBasedSource) {
ALOGV("disconnecting HTTPBasedSource");
diff --git a/media/libstagefright/NuMediaExtractor.cpp b/media/libstagefright/NuMediaExtractor.cpp
index e42d8d0..0a4dfce 100644
--- a/media/libstagefright/NuMediaExtractor.cpp
+++ b/media/libstagefright/NuMediaExtractor.cpp
@@ -204,12 +204,6 @@
return OK;
}
-void NuMediaExtractor::disconnect() {
- if (mDataSource != NULL) {
- mDataSource->disconnect();
- }
-}
-
status_t NuMediaExtractor::updateDurationAndBitrate() {
if (mImpl->countTracks() > kMaxTrackCount) {
return ERROR_UNSUPPORTED;
diff --git a/media/libstagefright/Utils.cpp b/media/libstagefright/Utils.cpp
index ada37a6..ebc3b33 100644
--- a/media/libstagefright/Utils.cpp
+++ b/media/libstagefright/Utils.cpp
@@ -74,7 +74,7 @@
}
#endif
-static void convertMetaDataToMessageColorAspects(const sp<MetaData> &meta, sp<AMessage> &msg) {
+static void convertMetaDataToMessageColorAspects(const MetaDataBase *meta, sp<AMessage> &msg) {
// 0 values are unspecified
int32_t range = 0;
int32_t primaries = 0;
@@ -568,8 +568,14 @@
}
}
+
status_t convertMetaDataToMessage(
const sp<MetaData> &meta, sp<AMessage> *format) {
+ return convertMetaDataToMessage(meta.get(), format);
+}
+
+status_t convertMetaDataToMessage(
+ const MetaDataBase *meta, sp<AMessage> *format) {
format->clear();
diff --git a/media/libstagefright/codecs/aacdec/SoftAAC2.cpp b/media/libstagefright/codecs/aacdec/SoftAAC2.cpp
index bc0a69f..d393c7a 100644
--- a/media/libstagefright/codecs/aacdec/SoftAAC2.cpp
+++ b/media/libstagefright/codecs/aacdec/SoftAAC2.cpp
@@ -147,7 +147,7 @@
mEndOfOutput = false;
mOutputDelayCompensated = 0;
mOutputDelayRingBufferSize = 2048 * MAX_CHANNEL_COUNT * kNumDelayBlocksMax;
- mOutputDelayRingBuffer = new short[mOutputDelayRingBufferSize];
+ mOutputDelayRingBuffer = new int16_t[mOutputDelayRingBufferSize];
mOutputDelayRingBufferWritePos = 0;
mOutputDelayRingBufferReadPos = 0;
mOutputDelayRingBufferFilled = 0;
diff --git a/media/libstagefright/codecs/aacdec/SoftAAC2.h b/media/libstagefright/codecs/aacdec/SoftAAC2.h
index 73a3965..5bee710 100644
--- a/media/libstagefright/codecs/aacdec/SoftAAC2.h
+++ b/media/libstagefright/codecs/aacdec/SoftAAC2.h
@@ -81,7 +81,7 @@
bool mEndOfOutput;
int32_t mOutputDelayCompensated;
int32_t mOutputDelayRingBufferSize;
- short *mOutputDelayRingBuffer;
+ int16_t *mOutputDelayRingBuffer;
int32_t mOutputDelayRingBufferWritePos;
int32_t mOutputDelayRingBufferReadPos;
int32_t mOutputDelayRingBufferFilled;
diff --git a/media/libstagefright/codecs/amrwb/src/pvamrwbdecoder.cpp b/media/libstagefright/codecs/amrwb/src/pvamrwbdecoder.cpp
index b8cfefa..ddc818e 100644
--- a/media/libstagefright/codecs/amrwb/src/pvamrwbdecoder.cpp
+++ b/media/libstagefright/codecs/amrwb/src/pvamrwbdecoder.cpp
@@ -455,7 +455,7 @@
&exc2[i_subfr],
0,
&synth16k[i_subfr *5/4],
- (short) 1,
+ 1,
HfIsf,
nb_bits,
newDTXState,
diff --git a/media/libstagefright/codecs/common/include/voType.h b/media/libstagefright/codecs/common/include/voType.h
index da208d4..73f24d0 100644
--- a/media/libstagefright/codecs/common/include/voType.h
+++ b/media/libstagefright/codecs/common/include/voType.h
@@ -22,6 +22,8 @@
#ifndef __voType_H__
#define __voType_H__
+#include <stdint.h>
+
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
@@ -62,28 +64,28 @@
typedef void VO_VOID;
/** VO_U8 is an 8 bit unsigned quantity that is byte aligned */
-typedef unsigned char VO_U8;
+typedef uint8_t VO_U8;
/** VO_BYTE is an 8 bit unsigned quantity that is byte aligned */
-typedef unsigned char VO_BYTE;
+typedef uint8_t VO_BYTE;
/** VO_S8 is an 8 bit signed quantity that is byte aligned */
-typedef signed char VO_S8;
+typedef int8_t VO_S8;
/** VO_CHAR is an 8 bit signed quantity that is byte aligned */
-typedef char VO_CHAR;
+typedef int8_t VO_CHAR;
/** VO_U16 is a 16 bit unsigned quantity that is 16 bit word aligned */
-typedef unsigned short VO_U16;
+typedef uint16_t VO_U16;
/** VO_S16 is a 16 bit signed quantity that is 16 bit word aligned */
-typedef signed short VO_S16;
+typedef int16_t VO_S16;
/** VO_U32 is a 32 bit unsigned quantity that is 32 bit word aligned */
-typedef unsigned long VO_U32;
+typedef uint32_t VO_U32;
/** VO_S32 is a 32 bit signed quantity that is 32 bit word aligned */
-typedef signed long VO_S32;
+typedef int32_t VO_S32;
/* Users with compilers that cannot accept the "long long" designation should
define the VO_SKIP64BIT macro. It should be noted that this may cause
@@ -94,14 +96,14 @@
#ifndef VO_SKIP64BIT
#ifdef _MSC_VER
/** VO_U64 is a 64 bit unsigned quantity that is 64 bit word aligned */
-typedef unsigned __int64 VO_U64;
+typedef uint64_t VO_U64;
/** VO_S64 is a 64 bit signed quantity that is 64 bit word aligned */
-typedef signed __int64 VO_S64;
+typedef int64_t VO_S64;
#else // WIN32
/** VO_U64 is a 64 bit unsigned quantity that is 64 bit word aligned */
-typedef unsigned long long VO_U64;
+typedef uint64_t VO_U64;
/** VO_S64 is a 64 bit signed quantity that is 64 bit word aligned */
-typedef signed long long VO_S64;
+typedef int64_t VO_S64;
#endif // WIN32
#endif // VO_SKIP64BIT
diff --git a/media/libstagefright/codecs/flac/dec/SoftFlacDecoder.cpp b/media/libstagefright/codecs/flac/dec/SoftFlacDecoder.cpp
index 2c0f224..4db0060 100644
--- a/media/libstagefright/codecs/flac/dec/SoftFlacDecoder.cpp
+++ b/media/libstagefright/codecs/flac/dec/SoftFlacDecoder.cpp
@@ -305,7 +305,7 @@
while ((!inQueue.empty() || mSawInputEOS) && !outQueue.empty() && !mFinishedDecoder) {
BufferInfo *outInfo = *outQueue.begin();
OMX_BUFFERHEADERTYPE *outHeader = outInfo->mHeader;
- short *outBuffer = reinterpret_cast<short *>(outHeader->pBuffer + outHeader->nOffset);
+ int16_t *outBuffer = reinterpret_cast<int16_t *>(outHeader->pBuffer + outHeader->nOffset);
size_t outBufferSize = outHeader->nAllocLen - outHeader->nOffset;
int64_t timeStamp = 0;
diff --git a/media/libstagefright/codecs/flac/enc/Android.bp b/media/libstagefright/codecs/flac/enc/Android.bp
index 46b974d..73f0dac 100644
--- a/media/libstagefright/codecs/flac/enc/Android.bp
+++ b/media/libstagefright/codecs/flac/enc/Android.bp
@@ -30,6 +30,7 @@
"liblog",
],
+ header_libs: ["libbase_headers"],
static_libs: ["libFLAC"],
name: "libstagefright_soft_flacenc",
diff --git a/media/libstagefright/codecs/flac/enc/SoftFlacEncoder.cpp b/media/libstagefright/codecs/flac/enc/SoftFlacEncoder.cpp
index fdc8975..955f211 100644
--- a/media/libstagefright/codecs/flac/enc/SoftFlacEncoder.cpp
+++ b/media/libstagefright/codecs/flac/enc/SoftFlacEncoder.cpp
@@ -16,6 +16,7 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "SoftFlacEncoder"
+#include <android-base/macros.h>
#include <utils/Log.h>
#include "SoftFlacEncoder.h"
@@ -335,7 +336,7 @@
}
}
- // fall through
+ FALLTHROUGH_INTENDED;
}
default:
diff --git a/media/libstagefright/codecs/m4v_h263/enc/include/mp4enc_api.h b/media/libstagefright/codecs/m4v_h263/enc/include/mp4enc_api.h
index 9451479..d5a3ff1 100644
--- a/media/libstagefright/codecs/m4v_h263/enc/include/mp4enc_api.h
+++ b/media/libstagefright/codecs/m4v_h263/enc/include/mp4enc_api.h
@@ -18,16 +18,17 @@
#ifndef _MP4ENC_API_H_
#define _MP4ENC_API_H_
+#include <stdint.h>
#include <string.h>
#ifndef _PV_TYPES_
#define _PV_TYPES_
-typedef unsigned char UChar;
-typedef char Char;
+typedef uint8_t UChar;
+typedef int8_t Char;
typedef unsigned int UInt;
typedef int Int;
-typedef unsigned short UShort;
-typedef short Short;
+typedef uint16_t UShort;
+typedef int16_t Short;
typedef unsigned int Bool;
typedef uint32_t ULong;
diff --git a/media/libstagefright/codecs/m4v_h263/enc/src/mp4def.h b/media/libstagefright/codecs/m4v_h263/enc/src/mp4def.h
index 2d44482..dbd70dc 100644
--- a/media/libstagefright/codecs/m4v_h263/enc/src/mp4def.h
+++ b/media/libstagefright/codecs/m4v_h263/enc/src/mp4def.h
@@ -52,13 +52,13 @@
#ifndef _PV_TYPES_
#define _PV_TYPES_
-typedef unsigned char UChar;
-typedef char Char;
+typedef uint8_t UChar;
+typedef int8_t Char;
typedef unsigned int UInt;
typedef int Int;
-typedef unsigned short UShort;
-typedef short Short;
-typedef short int SInt;
+typedef uint16_t UShort;
+typedef int16_t Short;
+typedef int16_t SInt;
typedef unsigned int Bool;
typedef uint32_t ULong;
typedef void Void;
diff --git a/media/libstagefright/codecs/on2/enc/SoftVPXEncoder.cpp b/media/libstagefright/codecs/on2/enc/SoftVPXEncoder.cpp
index f6257b1..2dfba13 100644
--- a/media/libstagefright/codecs/on2/enc/SoftVPXEncoder.cpp
+++ b/media/libstagefright/codecs/on2/enc/SoftVPXEncoder.cpp
@@ -21,6 +21,7 @@
#include "SoftVP8Encoder.h"
#include "SoftVP9Encoder.h"
+#include <android-base/macros.h>
#include <utils/Log.h>
#include <utils/misc.h>
@@ -557,7 +558,7 @@
break;
case kTemporalUpdateGoldenWithoutDependency:
flags |= VP8_EFLAG_NO_REF_GF;
- // Deliberately no break here.
+ FALLTHROUGH_INTENDED;
case kTemporalUpdateGolden:
flags |= VP8_EFLAG_NO_REF_ARF;
flags |= VP8_EFLAG_NO_UPD_ARF;
@@ -566,14 +567,14 @@
case kTemporalUpdateAltrefWithoutDependency:
flags |= VP8_EFLAG_NO_REF_ARF;
flags |= VP8_EFLAG_NO_REF_GF;
- // Deliberately no break here.
+ FALLTHROUGH_INTENDED;
case kTemporalUpdateAltref:
flags |= VP8_EFLAG_NO_UPD_GF;
flags |= VP8_EFLAG_NO_UPD_LAST;
break;
case kTemporalUpdateNoneNoRefAltref:
flags |= VP8_EFLAG_NO_REF_ARF;
- // Deliberately no break here.
+ FALLTHROUGH_INTENDED;
case kTemporalUpdateNone:
flags |= VP8_EFLAG_NO_UPD_GF;
flags |= VP8_EFLAG_NO_UPD_ARF;
diff --git a/media/libstagefright/colorconversion/ColorConverter.cpp b/media/libstagefright/colorconversion/ColorConverter.cpp
index 862cc63..86bd9d6 100644
--- a/media/libstagefright/colorconversion/ColorConverter.cpp
+++ b/media/libstagefright/colorconversion/ColorConverter.cpp
@@ -16,6 +16,7 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "ColorConverter"
+#include <android-base/macros.h>
#include <utils/Log.h>
#include <media/stagefright/foundation/ADebug.h>
@@ -82,7 +83,7 @@
if (mDstFormat == OMX_COLOR_FormatYUV444Y410) {
return true;
}
- // fall-thru
+ FALLTHROUGH_INTENDED;
case OMX_COLOR_FormatYUV420Planar:
return mDstFormat == OMX_COLOR_Format16bitRGB565
|| mDstFormat == OMX_COLOR_Format32BitRGBA8888
diff --git a/media/libstagefright/flac/dec/FLACDecoder.cpp b/media/libstagefright/flac/dec/FLACDecoder.cpp
index a2b6ab7..dfdc41c 100644
--- a/media/libstagefright/flac/dec/FLACDecoder.cpp
+++ b/media/libstagefright/flac/dec/FLACDecoder.cpp
@@ -120,7 +120,7 @@
// Copy samples from FLAC native 32-bit non-interleaved to 16-bit interleaved.
// These are candidates for optimization if needed.
static void copyMono8(
- short *dst,
+ int16_t *dst,
const int * src[FLACDecoder::kMaxChannels],
unsigned nSamples,
unsigned /* nChannels */) {
@@ -130,7 +130,7 @@
}
static void copyStereo8(
- short *dst,
+ int16_t *dst,
const int * src[FLACDecoder::kMaxChannels],
unsigned nSamples,
unsigned /* nChannels */) {
@@ -141,7 +141,7 @@
}
static void copyMultiCh8(
- short *dst,
+ int16_t *dst,
const int * src[FLACDecoder::kMaxChannels],
unsigned nSamples,
unsigned nChannels) {
@@ -153,7 +153,7 @@
}
static void copyMono16(
- short *dst,
+ int16_t *dst,
const int * src[FLACDecoder::kMaxChannels],
unsigned nSamples,
unsigned /* nChannels */) {
@@ -163,7 +163,7 @@
}
static void copyStereo16(
- short *dst,
+ int16_t *dst,
const int * src[FLACDecoder::kMaxChannels],
unsigned nSamples,
unsigned /* nChannels */) {
@@ -174,7 +174,7 @@
}
static void copyMultiCh16(
- short *dst,
+ int16_t *dst,
const int * src[FLACDecoder::kMaxChannels],
unsigned nSamples,
unsigned nChannels) {
@@ -187,7 +187,7 @@
// TODO: 24-bit versions should do dithering or noise-shaping, here or in AudioFlinger
static void copyMono24(
- short *dst,
+ int16_t *dst,
const int * src[FLACDecoder::kMaxChannels],
unsigned nSamples,
unsigned /* nChannels */) {
@@ -197,7 +197,7 @@
}
static void copyStereo24(
- short *dst,
+ int16_t *dst,
const int * src[FLACDecoder::kMaxChannels],
unsigned nSamples,
unsigned /* nChannels */) {
@@ -208,7 +208,7 @@
}
static void copyMultiCh24(
- short *dst,
+ int16_t *dst,
const int * src[FLACDecoder::kMaxChannels],
unsigned nSamples,
unsigned nChannels) {
@@ -391,7 +391,7 @@
static const struct {
unsigned mChannels;
unsigned mBitsPerSample;
- void (*mCopy)(short *dst, const int * src[kMaxChannels],
+ void (*mCopy)(int16_t *dst, const int * src[kMaxChannels],
unsigned nSamples, unsigned nChannels);
} table[] = {
{ 1, 8, copyMono8 },
@@ -420,7 +420,7 @@
}
status_t FLACDecoder::decodeOneFrame(const uint8_t *inBuffer, size_t inBufferLen,
- short *outBuffer, size_t *outBufferLen) {
+ int16_t *outBuffer, size_t *outBufferLen) {
ALOGV("decodeOneFrame: input size(%zu)", inBufferLen);
if (!mStreamInfoValid) {
@@ -469,12 +469,12 @@
return ERROR_MALFORMED;
}
- size_t bufferSize = blocksize * getChannels() * sizeof(short);
+ size_t bufferSize = blocksize * getChannels() * sizeof(int16_t);
if (bufferSize > *outBufferLen) {
ALOGW("decodeOneFrame: output buffer holds only partial frame %zu:%zu",
*outBufferLen, bufferSize);
- blocksize = *outBufferLen / (getChannels() * sizeof(short));
- bufferSize = blocksize * getChannels() * sizeof(short);
+ blocksize = *outBufferLen / (getChannels() * sizeof(int16_t));
+ bufferSize = blocksize * getChannels() * sizeof(int16_t);
}
if (mCopy == nullptr) {
diff --git a/media/libstagefright/flac/dec/FLACDecoder.h b/media/libstagefright/flac/dec/FLACDecoder.h
index 1a33cae..af419a2 100644
--- a/media/libstagefright/flac/dec/FLACDecoder.h
+++ b/media/libstagefright/flac/dec/FLACDecoder.h
@@ -41,7 +41,7 @@
status_t parseMetadata(const uint8_t *inBuffer, size_t inBufferLen);
status_t decodeOneFrame(const uint8_t *inBuffer, size_t inBufferLen,
- short *outBuffer, size_t *outBufferLen);
+ int16_t *outBuffer, size_t *outBufferLen);
void flush();
virtual ~FLACDecoder();
@@ -89,7 +89,7 @@
// most recent error reported by libFLAC decoder
FLAC__StreamDecoderErrorStatus mErrorStatus;
- void (*mCopy)(short *dst, const int *src[kMaxChannels], unsigned nSamples, unsigned nChannels);
+ void (*mCopy)(int16_t *dst, const int *src[kMaxChannels], unsigned nSamples, unsigned nChannels);
status_t init();
diff --git a/media/libstagefright/http/ClearMediaHTTP.cpp b/media/libstagefright/http/ClearMediaHTTP.cpp
index bfbad1e..9557c8a 100644
--- a/media/libstagefright/http/ClearMediaHTTP.cpp
+++ b/media/libstagefright/http/ClearMediaHTTP.cpp
@@ -74,6 +74,10 @@
return success ? OK : UNKNOWN_ERROR;
}
+void ClearMediaHTTP::close() {
+ disconnect();
+}
+
void ClearMediaHTTP::disconnect() {
mName = String8("ClearMediaHTTP(<disconnected>)");
if (mInitCheck != OK) {
diff --git a/media/libstagefright/httplive/Android.bp b/media/libstagefright/httplive/Android.bp
index 8a77401..2f933a0 100644
--- a/media/libstagefright/httplive/Android.bp
+++ b/media/libstagefright/httplive/Android.bp
@@ -46,6 +46,10 @@
"android.hardware.cas.native@1.0",
],
+ header_libs: [
+ "libbase_headers",
+ ],
+
static_libs: [
"libstagefright_id3",
"libstagefright_metadatautils",
diff --git a/media/libstagefright/httplive/LiveSession.cpp b/media/libstagefright/httplive/LiveSession.cpp
index 7eff8eb..86872c5 100644
--- a/media/libstagefright/httplive/LiveSession.cpp
+++ b/media/libstagefright/httplive/LiveSession.cpp
@@ -445,7 +445,7 @@
return -EAGAIN;
};
(*accessUnit)->meta()->setInt32(
- "trackIndex", mPlaylist->getSelectedIndex());
+ "track-index", mPlaylist->getSelectedIndex());
(*accessUnit)->meta()->setInt64("baseUs", mRealTimeBaseUs);
} else if (stream == STREAMTYPE_METADATA) {
HLSTime mdTime((*accessUnit)->meta());
diff --git a/media/libstagefright/httplive/PlaylistFetcher.cpp b/media/libstagefright/httplive/PlaylistFetcher.cpp
index 9f39b5e..823f90e 100644
--- a/media/libstagefright/httplive/PlaylistFetcher.cpp
+++ b/media/libstagefright/httplive/PlaylistFetcher.cpp
@@ -16,6 +16,7 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "PlaylistFetcher"
+#include <android-base/macros.h>
#include <utils/Log.h>
#include <utils/misc.h>
@@ -267,7 +268,7 @@
break;
}
- // fall through
+ FALLTHROUGH_INTENDED;
}
case FIRST_UNCHANGED_RELOAD_ATTEMPT:
diff --git a/media/libstagefright/include/NuCachedSource2.h b/media/libstagefright/include/NuCachedSource2.h
index f4aab25..5591525 100644
--- a/media/libstagefright/include/NuCachedSource2.h
+++ b/media/libstagefright/include/NuCachedSource2.h
@@ -37,6 +37,8 @@
virtual ssize_t readAt(off64_t offset, void *data, size_t size);
+ virtual void close();
+
virtual void disconnect();
virtual status_t getSize(off64_t *size);
diff --git a/media/libstagefright/include/media/stagefright/ClearMediaHTTP.h b/media/libstagefright/include/media/stagefright/ClearMediaHTTP.h
index 7fe9c74..72907a9 100644
--- a/media/libstagefright/include/media/stagefright/ClearMediaHTTP.h
+++ b/media/libstagefright/include/media/stagefright/ClearMediaHTTP.h
@@ -34,6 +34,8 @@
const KeyedVector<String8, String8> *headers,
off64_t offset);
+ virtual void close();
+
virtual void disconnect();
virtual status_t initCheck() const;
diff --git a/media/libstagefright/include/media/stagefright/MediaExtractor.h b/media/libstagefright/include/media/stagefright/MediaExtractor.h
index d9456ab..71343d5 100644
--- a/media/libstagefright/include/media/stagefright/MediaExtractor.h
+++ b/media/libstagefright/include/media/stagefright/MediaExtractor.h
@@ -90,7 +90,22 @@
class MediaExtractorCUnwrapper : public MediaExtractor {
public:
- explicit MediaExtractorCUnwrapper(CMediaExtractor *wrapper);
+ MediaExtractorCUnwrapper() {};
+ virtual size_t countTracks() = 0;
+ virtual MediaTrack *getTrack(size_t index) = 0;
+ virtual status_t getTrackMetaData(MetaDataBase& meta, size_t index, uint32_t flags = 0) = 0;
+ virtual status_t getMetaData(MetaDataBase& meta) = 0;
+ virtual const char * name() = 0;
+ virtual uint32_t flags() const = 0;
+ virtual status_t setMediaCas(const uint8_t* casToken, size_t size) = 0;
+protected:
+ virtual ~MediaExtractorCUnwrapper() {};
+};
+
+
+class MediaExtractorCUnwrapperV1 : public MediaExtractorCUnwrapper {
+public:
+ explicit MediaExtractorCUnwrapperV1(CMediaExtractor *plugin);
virtual size_t countTracks();
virtual MediaTrack *getTrack(size_t index);
virtual status_t getTrackMetaData(MetaDataBase& meta, size_t index, uint32_t flags = 0);
@@ -99,11 +114,26 @@
virtual uint32_t flags() const;
virtual status_t setMediaCas(const uint8_t* casToken, size_t size);
protected:
- virtual ~MediaExtractorCUnwrapper();
+ virtual ~MediaExtractorCUnwrapperV1();
private:
- CMediaExtractor *wrapper;
+ CMediaExtractor *plugin;
};
+class MediaExtractorCUnwrapperV2 : public MediaExtractorCUnwrapper {
+public:
+ explicit MediaExtractorCUnwrapperV2(CMediaExtractorV2 *plugin);
+ virtual size_t countTracks();
+ virtual MediaTrack *getTrack(size_t index);
+ virtual status_t getTrackMetaData(MetaDataBase& meta, size_t index, uint32_t flags = 0);
+ virtual status_t getMetaData(MetaDataBase& meta);
+ virtual const char * name();
+ virtual uint32_t flags() const;
+ virtual status_t setMediaCas(const uint8_t* casToken, size_t size);
+protected:
+ virtual ~MediaExtractorCUnwrapperV2();
+private:
+ CMediaExtractorV2 *plugin;
+};
} // namespace android
diff --git a/media/libstagefright/include/media/stagefright/MediaExtractorFactory.h b/media/libstagefright/include/media/stagefright/MediaExtractorFactory.h
index e603176..ef9f7ed 100644
--- a/media/libstagefright/include/media/stagefright/MediaExtractorFactory.h
+++ b/media/libstagefright/include/media/stagefright/MediaExtractorFactory.h
@@ -49,9 +49,9 @@
static void RegisterExtractor(
const sp<ExtractorPlugin> &plugin, std::list<sp<ExtractorPlugin>> &pluginList);
- static CreatorFunc sniff(const sp<DataSource> &source,
+ static void *sniff(const sp<DataSource> &source,
float *confidence, void **meta, FreeMetaFunc *freeMeta,
- sp<ExtractorPlugin> &plugin);
+ sp<ExtractorPlugin> &plugin, uint32_t *creatorVersion);
static void UpdateExtractors(const char *newUpdateApkPath);
};
diff --git a/media/libstagefright/include/media/stagefright/NuMediaExtractor.h b/media/libstagefright/include/media/stagefright/NuMediaExtractor.h
index 54a7095..641ccfa 100644
--- a/media/libstagefright/include/media/stagefright/NuMediaExtractor.h
+++ b/media/libstagefright/include/media/stagefright/NuMediaExtractor.h
@@ -64,8 +64,6 @@
status_t setMediaCas(const HInterfaceToken &casToken);
- void disconnect();
-
size_t countTracks() const;
status_t getTrackFormat(size_t index, sp<AMessage> *format, uint32_t flags = 0) const;
diff --git a/media/libstagefright/include/media/stagefright/Utils.h b/media/libstagefright/include/media/stagefright/Utils.h
index 6a28e0b..46a419d 100644
--- a/media/libstagefright/include/media/stagefright/Utils.h
+++ b/media/libstagefright/include/media/stagefright/Utils.h
@@ -30,6 +30,8 @@
struct AMessage;
status_t convertMetaDataToMessage(
+ const MetaDataBase *meta, sp<AMessage> *format);
+status_t convertMetaDataToMessage(
const sp<MetaData> &meta, sp<AMessage> *format);
void convertMessageToMetaData(
const sp<AMessage> &format, sp<MetaData> &meta);
diff --git a/media/libstagefright/omx/Android.bp b/media/libstagefright/omx/Android.bp
index 3e6942b..6250045 100644
--- a/media/libstagefright/omx/Android.bp
+++ b/media/libstagefright/omx/Android.bp
@@ -29,6 +29,7 @@
],
header_libs: [
+ "libbase_headers",
"media_plugin_headers",
],
diff --git a/media/libstagefright/omx/OMXNodeInstance.cpp b/media/libstagefright/omx/OMXNodeInstance.cpp
index 32113c2..99762b9 100644
--- a/media/libstagefright/omx/OMXNodeInstance.cpp
+++ b/media/libstagefright/omx/OMXNodeInstance.cpp
@@ -16,6 +16,7 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "OMXNodeInstance"
+#include <android-base/macros.h>
#include <utils/Log.h>
#include <inttypes.h>
@@ -459,7 +460,7 @@
break;
}
- // fall through
+ FALLTHROUGH_INTENDED;
}
case OMX_StateIdle:
@@ -486,7 +487,7 @@
}
CHECK_EQ(err, OMX_ErrorNone);
- // fall through
+ FALLTHROUGH_INTENDED;
}
case OMX_StateLoaded:
@@ -2196,8 +2197,8 @@
// bump internal-state debug level for 2 input and output frames
Mutex::Autolock _l(mDebugLock);
bumpDebugLevel_l(2 /* numInputBuffers */, 2 /* numOutputBuffers */);
+ FALLTHROUGH_INTENDED;
}
- // fall through
default:
arg2String = portString(arg2);
}
@@ -2208,7 +2209,7 @@
break;
case OMX_EventPortSettingsChanged:
arg2String = asString((OMX_INDEXEXTTYPE)arg2);
- // fall through
+ FALLTHROUGH_INTENDED;
default:
arg1String = portString(arg1);
}
diff --git a/media/libstagefright/omx/OMXUtils.cpp b/media/libstagefright/omx/OMXUtils.cpp
index f7b569d..9ed4a99 100644
--- a/media/libstagefright/omx/OMXUtils.cpp
+++ b/media/libstagefright/omx/OMXUtils.cpp
@@ -19,6 +19,7 @@
#include <string.h>
+#include <android-base/macros.h>
#include <media/stagefright/omx/OMXUtils.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/AUtils.h>
@@ -273,6 +274,7 @@
break;
} else {
// fall through as YV12 is used for YUV420Planar by some codecs
+ FALLTHROUGH_INTENDED;
}
case OMX_COLOR_FormatYUV420Planar:
diff --git a/media/libstagefright/omx/tests/Android.bp b/media/libstagefright/omx/tests/Android.bp
index 3b521ab..ef36982 100644
--- a/media/libstagefright/omx/tests/Android.bp
+++ b/media/libstagefright/omx/tests/Android.bp
@@ -27,6 +27,10 @@
"frameworks/native/include/media/openmax",
],
+ header_libs: [
+ "libbase_headers",
+ ],
+
cflags: [
"-Werror",
"-Wall",
diff --git a/media/libstagefright/omx/tests/OMXHarness.cpp b/media/libstagefright/omx/tests/OMXHarness.cpp
index 5388ba7..c2f1072 100644
--- a/media/libstagefright/omx/tests/OMXHarness.cpp
+++ b/media/libstagefright/omx/tests/OMXHarness.cpp
@@ -17,6 +17,7 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "OMXHarness"
#include <inttypes.h>
+#include <android-base/macros.h>
#include <utils/Log.h>
#include "OMXHarness.h"
@@ -843,7 +844,7 @@
case '?':
fprintf(stderr, "\n");
- // fall through
+ FALLTHROUGH_INTENDED;
case 'h':
default:
diff --git a/media/libstagefright/xmlparser/Android.bp b/media/libstagefright/xmlparser/Android.bp
index a4fa342..5737ac2 100644
--- a/media/libstagefright/xmlparser/Android.bp
+++ b/media/libstagefright/xmlparser/Android.bp
@@ -19,6 +19,10 @@
"libstagefright_omx_utils",
],
+ header_libs: [
+ "libbase_headers",
+ ],
+
cflags: [
"-Werror",
"-Wall",
diff --git a/media/libstagefright/xmlparser/MediaCodecsXmlParser.cpp b/media/libstagefright/xmlparser/MediaCodecsXmlParser.cpp
index ffd30ea..0832944 100644
--- a/media/libstagefright/xmlparser/MediaCodecsXmlParser.cpp
+++ b/media/libstagefright/xmlparser/MediaCodecsXmlParser.cpp
@@ -19,6 +19,7 @@
#include <media/stagefright/xmlparser/MediaCodecsXmlParser.h>
+#include <android-base/macros.h>
#include <utils/Log.h>
#include <media/stagefright/MediaErrors.h>
#include <media/stagefright/omx/OMXUtils.h>
@@ -340,7 +341,7 @@
}
}
inType = false;
- // fall through
+ FALLTHROUGH_INTENDED;
case SECTION_DECODER_TYPE:
case SECTION_ENCODER_TYPE:
diff --git a/media/mtp/MtpFfsHandle.cpp b/media/mtp/MtpFfsHandle.cpp
index f25fc71..ad3c068 100644
--- a/media/mtp/MtpFfsHandle.cpp
+++ b/media/mtp/MtpFfsHandle.cpp
@@ -212,7 +212,6 @@
uint16_t value = setup->wValue;
std::vector<char> buf;
buf.resize(length);
- int ret = 0;
if (!(type & USB_DIR_IN)) {
if (::read(mControl, buf.data(), length) != length) {
@@ -225,8 +224,8 @@
case MTP_REQ_RESET:
case MTP_REQ_CANCEL:
errno = ECANCELED;
- ret = -1;
- break;
+ return -1;
+ // break;
case MTP_REQ_GET_DEVICE_STATUS:
{
if (length < sizeof(struct mtp_device_status) + 4) {
diff --git a/media/ndk/NdkMediaDataSource.cpp b/media/ndk/NdkMediaDataSource.cpp
index 9ea734b..75477b4 100644
--- a/media/ndk/NdkMediaDataSource.cpp
+++ b/media/ndk/NdkMediaDataSource.cpp
@@ -48,14 +48,18 @@
AMediaDataSourceReadAt readAt;
AMediaDataSourceGetSize getSize;
AMediaDataSourceClose close;
+ sp<DataSource> mImpl;
+ uint32_t mFlags;
};
NdkDataSource::NdkDataSource(AMediaDataSource *dataSource)
: mDataSource(AMediaDataSource_new()) {
- AMediaDataSource_setReadAt(mDataSource, dataSource->readAt);
- AMediaDataSource_setGetSize(mDataSource, dataSource->getSize);
- AMediaDataSource_setClose(mDataSource, dataSource->close);
- AMediaDataSource_setUserdata(mDataSource, dataSource->userdata);
+ AMediaDataSource_setReadAt(mDataSource, dataSource->readAt);
+ AMediaDataSource_setGetSize(mDataSource, dataSource->getSize);
+ AMediaDataSource_setClose(mDataSource, dataSource->close);
+ AMediaDataSource_setUserdata(mDataSource, dataSource->userdata);
+ mDataSource->mImpl = dataSource->mImpl;
+ mDataSource->mFlags = dataSource->mFlags;
}
NdkDataSource::~NdkDataSource() {
@@ -66,9 +70,13 @@
return OK;
}
+uint32_t NdkDataSource::flags() {
+ return mDataSource->mFlags;
+}
+
ssize_t NdkDataSource::readAt(off64_t offset, void *data, size_t size) {
Mutex::Autolock l(mLock);
- if (mDataSource->getSize == NULL || mDataSource->userdata == NULL) {
+ if (mDataSource->readAt == NULL || mDataSource->userdata == NULL) {
return -1;
}
return mDataSource->readAt(mDataSource->userdata, offset, data, size);
@@ -204,7 +212,10 @@
}
sp<DataSource> source = DataSourceFactory::CreateFromURI(service, uri, &headers);
- return convertDataSourceToAMediaDataSource(source);
+ AMediaDataSource* aSource = convertDataSourceToAMediaDataSource(source);
+ aSource->mImpl = source;
+ aSource->mFlags = source->flags();
+ return aSource;
}
EXPORT
@@ -235,5 +246,10 @@
mSource->close = close;
}
+EXPORT
+void AMediaDataSource_close(AMediaDataSource *mSource) {
+ return mSource->close(mSource->userdata);
+}
+
} // extern "C"
diff --git a/media/ndk/NdkMediaDataSourcePriv.h b/media/ndk/NdkMediaDataSourcePriv.h
index 3b0aa59..8a5423c 100644
--- a/media/ndk/NdkMediaDataSourcePriv.h
+++ b/media/ndk/NdkMediaDataSourcePriv.h
@@ -44,6 +44,7 @@
NdkDataSource(AMediaDataSource *);
virtual status_t initCheck() const;
+ virtual uint32_t flags();
virtual ssize_t readAt(off64_t offset, void *data, size_t size);
virtual status_t getSize(off64_t *);
virtual String8 toString();
diff --git a/media/ndk/NdkMediaExtractor.cpp b/media/ndk/NdkMediaExtractor.cpp
index f00a19c..60b15d4 100644
--- a/media/ndk/NdkMediaExtractor.cpp
+++ b/media/ndk/NdkMediaExtractor.cpp
@@ -464,11 +464,5 @@
return AMEDIA_OK;
}
-EXPORT
-media_status_t AMediaExtractor_disconnect(AMediaExtractor * ex) {
- ex->mImpl->disconnect();
- return AMEDIA_OK;
-}
-
} // extern "C"
diff --git a/media/ndk/NdkMediaFormat.cpp b/media/ndk/NdkMediaFormat.cpp
index a66f3b3..249c76e 100644
--- a/media/ndk/NdkMediaFormat.cpp
+++ b/media/ndk/NdkMediaFormat.cpp
@@ -35,23 +35,6 @@
extern "C" {
-// private functions for conversion to/from AMessage
-AMediaFormat* AMediaFormat_fromMsg(const void* data) {
- ALOGV("private ctor");
- AMediaFormat* mData = new AMediaFormat();
- mData->mFormat = *((sp<AMessage>*)data);
- if (mData->mFormat == NULL) {
- ALOGW("got NULL format");
- mData->mFormat = new AMessage;
- }
- return mData;
-}
-
-void AMediaFormat_getFormat(const AMediaFormat* mData, void* dest) {
- *((sp<AMessage>*)dest) = mData->mFormat;
-}
-
-
/*
* public function follow
*/
diff --git a/media/ndk/include/media/NdkMediaDataSource.h b/media/ndk/include/media/NdkMediaDataSource.h
index 021029b..297d4bc 100644
--- a/media/ndk/include/media/NdkMediaDataSource.h
+++ b/media/ndk/include/media/NdkMediaDataSource.h
@@ -43,14 +43,9 @@
/*
* AMediaDataSource's callbacks will be invoked on an implementation-defined thread
* or thread pool. No guarantees are provided about which thread(s) will be used for
- * callbacks. However, it is guaranteed that AMediaDataSource's callbacks will only
- * ever be invoked by a single thread at a time.
- *
- * There will be a thread synchronization point between each call to ensure that
- * modifications to the state of your AMediaDataSource are visible to future
- * calls. This means you don't need to do your own synchronization unless you're
- * modifying the AMediaDataSource from another thread while it's being used by the
- * framework.
+ * callbacks. For example, |close| can be invoked from a different thread than the
+ * thread invoking |readAt|. As such, the Implementations of AMediaDataSource callbacks
+ * must be threadsafe.
*/
/**
@@ -74,9 +69,19 @@
typedef ssize_t (*AMediaDataSourceGetSize)(void *userdata);
/**
- * Called to close the data source and release associated resources.
- * The NDK media framework guarantees that after |close| is called
- * no future callbacks will be invoked on the data source.
+ * Called to close the data source, unblock reads, and release associated
+ * resources.
+ *
+ * The NDK media framework guarantees that after the first |close| is
+ * called, no future callbacks will be invoked on the data source except
+ * for |close| itself.
+ *
+ * Closing a data source allows readAt calls that were blocked waiting
+ * for I/O data to return promptly.
+ *
+ * When using AMediaDataSource as input to AMediaExtractor, closing
+ * has the effect of unblocking slow reads inside of setDataSource
+ * and readSampleData.
*/
typedef void (*AMediaDataSourceClose)(void *userdata);
@@ -161,6 +166,18 @@
#endif /*__ANDROID_API__ >= 28 */
+#if __ANDROID_API__ >= 29
+
+/**
+ * Close the data source, unblock reads, and release associated resources.
+ *
+ * Please refer to the definition of AMediaDataSourceClose for
+ * additional details.
+ */
+void AMediaDataSource_close(AMediaDataSource*) __INTRODUCED_IN(29);
+
+#endif /*__ANDROID_API__ >= 29 */
+
__END_DECLS
#endif // _NDK_MEDIA_DATASOURCE_H
diff --git a/media/ndk/libmediandk.map.txt b/media/ndk/libmediandk.map.txt
index a805e87..d13edfc 100644
--- a/media/ndk/libmediandk.map.txt
+++ b/media/ndk/libmediandk.map.txt
@@ -142,6 +142,7 @@
AMediaDataSource_setReadAt; # introduced=28
AMediaDataSource_setUserdata; # introduced=28
AMediaDataSource_newUri; # introduced=29
+ AMediaDataSource_close; # introduced=29
AMediaDrm_closeSession;
AMediaDrm_createByUUID;
AMediaDrm_decrypt;
diff --git a/packages/MediaComponents/Android.mk b/packages/MediaComponents/Android.mk
index 55a5424..fff3a62 100644
--- a/packages/MediaComponents/Android.mk
+++ b/packages/MediaComponents/Android.mk
@@ -14,59 +14,57 @@
# limitations under the License.
#
-# This package is excluded from build for now since APIs using this apk became hidden.
-#
-#LOCAL_PATH := $(call my-dir)
-#ifneq ($(TARGET_BUILD_PDK),true) # Build MediaComponents only if this is not a PDK build. MediaComponents won't
-## build in PDK builds because frameworks/base/core/java is not available but
-## IMediaSession2.aidl and IMediaController2.aidl are using classes from
-## frameworks/base/core/java.
-#
-#include $(CLEAR_VARS)
-#
-#LOCAL_PACKAGE_NAME := MediaComponents
-#LOCAL_MODULE_OWNER := google
-#
-## TODO: create a separate key for this package.
-#LOCAL_CERTIFICATE := platform
-#
-## TODO: Use System SDK once public APIs are approved
-## LOCAL_SDK_VERSION := system_current
-#LOCAL_PRIVATE_PLATFORM_APIS := true
-#
-#LOCAL_SRC_FILES := \
-# $(call all-java-files-under, src) \
-# $(call all-Iaidl-files-under, src)
-#
-#LOCAL_PROGUARD_FLAG_FILES := proguard.cfg
-#
-#LOCAL_MULTILIB := first
-#
-#LOCAL_JAVA_LIBRARIES += androidx.annotation_annotation
-#
-## To embed native libraries in package, uncomment the lines below.
-##LOCAL_MODULE_TAGS := samples
-##LOCAL_JNI_SHARED_LIBRARIES := \
-## libaacextractor \
-## libamrextractor \
-## libflacextractor \
-## libmidiextractor \
-## libmkvextractor \
-## libmp3extractor \
-## libmp4extractor \
-## libmpeg2extractor \
-## liboggextractor \
-## libwavextractor \
-#
-## TODO: Remove dependency with other support libraries.
-#LOCAL_STATIC_ANDROID_LIBRARIES += \
-# androidx.legacy_legacy-support-v4 \
-# androidx.appcompat_appcompat \
-# androidx.palette_palette
-#LOCAL_USE_AAPT2 := true
-#
-#include $(BUILD_PACKAGE)
-#
-#endif # ifneq ($(TARGET_BUILD_PDK),true)
-#
-#include $(call all-makefiles-under,$(LOCAL_PATH))
+LOCAL_PATH := $(call my-dir)
+ifneq ($(TARGET_BUILD_PDK),true) # Build MediaComponents only if this is not a PDK build. MediaComponents won't
+# build in PDK builds because frameworks/base/core/java is not available but
+# IMediaSession2.aidl and IMediaController2.aidl are using classes from
+# frameworks/base/core/java.
+
+include $(CLEAR_VARS)
+
+LOCAL_PACKAGE_NAME := MediaComponents
+LOCAL_MODULE_OWNER := google
+
+# TODO: create a separate key for this package.
+LOCAL_CERTIFICATE := platform
+
+# TODO: Use System SDK once public APIs are approved
+# LOCAL_SDK_VERSION := system_current
+LOCAL_PRIVATE_PLATFORM_APIS := true
+
+LOCAL_SRC_FILES := \
+ $(call all-java-files-under, src) \
+ $(call all-Iaidl-files-under, src)
+
+LOCAL_PROGUARD_FLAG_FILES := proguard.cfg
+
+LOCAL_MULTILIB := first
+
+LOCAL_JAVA_LIBRARIES += androidx.annotation_annotation
+
+# To embed native libraries in package, uncomment the lines below.
+#LOCAL_MODULE_TAGS := samples
+#LOCAL_JNI_SHARED_LIBRARIES := \
+# libaacextractor \
+# libamrextractor \
+# libflacextractor \
+# libmidiextractor \
+# libmkvextractor \
+# libmp3extractor \
+# libmp4extractor \
+# libmpeg2extractor \
+# liboggextractor \
+# libwavextractor \
+
+# TODO: Remove dependency with other support libraries.
+LOCAL_STATIC_ANDROID_LIBRARIES += \
+ androidx.legacy_legacy-support-v4 \
+ androidx.appcompat_appcompat \
+ androidx.palette_palette
+LOCAL_USE_AAPT2 := true
+
+include $(BUILD_PACKAGE)
+
+endif # ifneq ($(TARGET_BUILD_PDK),true)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/packages/MediaComponents/src/com/android/widget/VideoView2Impl.java b/packages/MediaComponents/src/com/android/widget/VideoView2Impl.java
index ffb145a..54ef719 100644
--- a/packages/MediaComponents/src/com/android/widget/VideoView2Impl.java
+++ b/packages/MediaComponents/src/com/android/widget/VideoView2Impl.java
@@ -33,8 +33,7 @@
import android.media.MediaMetadata2;
import android.media.MediaMetadataRetriever;
import android.media.MediaPlayer2;
-import android.media.MediaPlayer2.MediaPlayer2EventCallback;
-import android.media.MediaPlayer2.OnSubtitleDataListener;
+import android.media.MediaPlayer2.EventCallback;
import android.media.MediaPlayer2Impl;
import android.media.Metadata;
import android.media.PlaybackParams;
@@ -733,12 +732,11 @@
runnable.run();
}
};
- mMediaPlayer.setMediaPlayer2EventCallback(executor, mMediaPlayer2Callback);
+ mMediaPlayer.registerEventCallback(executor, mMediaPlayer2Callback);
mCurrentBufferPercentage = -1;
mMediaPlayer.setDataSource(dsd);
mMediaPlayer.setAudioAttributes(mAudioAttributes);
- mMediaPlayer.setOnSubtitleDataListener(mSubtitleListener);
// we don't set the target state here either, but preserve the
// target state that was there before.
mCurrentState = STATE_PREPARING;
@@ -1106,10 +1104,10 @@
mInstance.addView(mMusicView, 0);
}
- OnSubtitleDataListener mSubtitleListener =
- new OnSubtitleDataListener() {
+ EventCallback mMediaPlayer2Callback =
+ new EventCallback() {
@Override
- public void onSubtitleData(MediaPlayer2 mp, SubtitleData data) {
+ public void onSubtitleData(MediaPlayer2 mp, DataSourceDesc dsd, SubtitleData data) {
if (DEBUG) {
Log.d(TAG, "onSubtitleData(): getTrackIndex: " + data.getTrackIndex()
+ ", getCurrentPosition: " + mp.getCurrentPosition()
@@ -1133,10 +1131,7 @@
}
}
}
- };
- MediaPlayer2EventCallback mMediaPlayer2Callback =
- new MediaPlayer2EventCallback() {
@Override
public void onVideoSizeChanged(
MediaPlayer2 mp, DataSourceDesc dsd, int width, int height) {
@@ -1169,7 +1164,7 @@
extractTracks();
} else if (what == MediaPlayer2.MEDIA_INFO_PREPARED) {
this.onPrepared(mp, dsd);
- } else if (what == MediaPlayer2.MEDIA_INFO_PLAYBACK_COMPLETE) {
+ } else if (what == MediaPlayer2.MEDIA_INFO_DATA_SOURCE_END) {
this.onCompletion(mp, dsd);
} else if (what == MediaPlayer2.MEDIA_INFO_BUFFERING_UPDATE) {
this.onBufferingUpdate(mp, dsd, extra);
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 62fd5f7..06975ac 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -2500,9 +2500,7 @@
if (recordThread != 0) {
ALOGV("closeInput() %d", input);
-#if 0
dumpToThreadLog_l(recordThread);
-#endif
// If we still have effect chains, it means that a client still holds a handle
// on at least one effect. We must either move the chain to an existing thread with the
@@ -2546,9 +2544,7 @@
if (mmapThread == 0) {
return BAD_VALUE;
}
-#if 0
dumpToThreadLog_l(mmapThread);
-#endif
mMmapThreads.removeItem(input);
}
const sp<AudioIoDescriptor> ioDesc = new AudioIoDescriptor();
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index d7a4451..01c5ea2 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -2794,22 +2794,18 @@
void AudioFlinger::PlaybackThread::threadLoop_removeTracks(
const Vector< sp<Track> >& tracksToRemove)
{
- size_t count = tracksToRemove.size();
- if (count > 0) {
- for (size_t i = 0 ; i < count ; i++) {
- const sp<Track>& track = tracksToRemove.itemAt(i);
- if (track->isExternalTrack()) {
- AudioSystem::stopOutput(track->portId());
+ // Miscellaneous track cleanup when removed from the active list,
+ // called without Thread lock but synchronized with threadLoop processing.
#ifdef ADD_BATTERY_DATA
- // to track the speaker usage
- addBatteryData(IMediaPlayerService::kBatteryDataAudioFlingerStop);
-#endif
- if (track->isTerminated()) {
- AudioSystem::releaseOutput(track->portId());
- }
- }
+ for (const auto& track : tracksToRemove) {
+ if (track->isExternalTrack()) {
+ // to track the speaker usage
+ addBatteryData(IMediaPlayerService::kBatteryDataAudioFlingerStop);
}
}
+#else
+ (void)tracksToRemove; // suppress unused warning
+#endif
}
void AudioFlinger::PlaybackThread::checkSilentMode_l()
@@ -3710,24 +3706,28 @@
// removeTracks_l() must be called with ThreadBase::mLock held
void AudioFlinger::PlaybackThread::removeTracks_l(const Vector< sp<Track> >& tracksToRemove)
{
- size_t count = tracksToRemove.size();
- if (count > 0) {
- for (size_t i=0 ; i<count ; i++) {
- const sp<Track>& track = tracksToRemove.itemAt(i);
- mActiveTracks.remove(track);
- ALOGV("removeTracks_l removing track on session %d", track->sessionId());
- sp<EffectChain> chain = getEffectChain_l(track->sessionId());
- if (chain != 0) {
- ALOGV("stopping track on chain %p for session Id: %d", chain.get(),
- track->sessionId());
- chain->decActiveTrackCnt();
- }
+ for (const auto& track : tracksToRemove) {
+ mActiveTracks.remove(track);
+ ALOGV("%s(%d): removing track on session %d", __func__, track->id(), track->sessionId());
+ sp<EffectChain> chain = getEffectChain_l(track->sessionId());
+ if (chain != 0) {
+ ALOGV("%s(%d): stopping track on chain %p for session Id: %d",
+ __func__, track->id(), chain.get(), track->sessionId());
+ chain->decActiveTrackCnt();
+ }
+ // If an external client track, inform APM we're no longer active, and remove if needed.
+ // We do this under lock so that the state is consistent if the Track is destroyed.
+ if (track->isExternalTrack()) {
+ AudioSystem::stopOutput(track->portId());
if (track->isTerminated()) {
- removeTrack_l(track);
+ AudioSystem::releaseOutput(track->portId());
}
}
+ if (track->isTerminated()) {
+ // remove from our tracks vector
+ removeTrack_l(track);
+ }
}
-
}
status_t AudioFlinger::PlaybackThread::getTimestamp_l(AudioTimestamp& timestamp)
@@ -4115,12 +4115,6 @@
return latency;
}
-
-void AudioFlinger::MixerThread::threadLoop_removeTracks(const Vector< sp<Track> >& tracksToRemove)
-{
- PlaybackThread::threadLoop_removeTracks(tracksToRemove);
-}
-
ssize_t AudioFlinger::MixerThread::threadLoop_write()
{
// FIXME we should only do one push per cycle; confirm this is true
@@ -6963,7 +6957,7 @@
framesIn, mSampleRate, activeTrack->mSampleRate));
if (activeTrack->isDirect()) {
- // No RecordBufferConverter used for compressed formats. Pass
+ // No RecordBufferConverter used for direct streams. Pass
// straight from RecordThread buffer to RecordTrack buffer.
AudioBufferProvider::Buffer buffer;
buffer.frameCount = framesOut;
@@ -6973,7 +6967,7 @@
"%s() read less than expected (%zu vs %zu)",
__func__, buffer.frameCount, framesOut);
framesOut = buffer.frameCount;
- memcpy(activeTrack->mSink.raw, buffer.raw, buffer.frameCount);
+ memcpy(activeTrack->mSink.raw, buffer.raw, buffer.frameCount * mFrameSize);
activeTrack->mResamplerBufferProvider->releaseBuffer(&buffer);
} else {
framesOut = 0;
diff --git a/services/audioflinger/Threads.h b/services/audioflinger/Threads.h
index 88c6ff3..61f7baf 100644
--- a/services/audioflinger/Threads.h
+++ b/services/audioflinger/Threads.h
@@ -1137,7 +1137,6 @@
virtual void threadLoop_standby();
virtual void threadLoop_mix();
virtual void threadLoop_sleepTime();
- virtual void threadLoop_removeTracks(const Vector< sp<Track> >& tracksToRemove);
virtual uint32_t correctLatency_l(uint32_t latency) const;
virtual status_t createAudioPatch_l(const struct audio_patch *patch,
diff --git a/services/audiopolicy/Android.mk b/services/audiopolicy/Android.mk
index b75e957..c577589 100644
--- a/services/audiopolicy/Android.mk
+++ b/services/audiopolicy/Android.mk
@@ -81,7 +81,7 @@
LOCAL_SHARED_LIBRARIES += libmediametrics
ifeq ($(USE_XML_AUDIO_POLICY_CONF), 1)
-LOCAL_SHARED_LIBRARIES += libicuuc libxml2
+LOCAL_SHARED_LIBRARIES += libhidlbase libicuuc libxml2
LOCAL_CFLAGS += -DUSE_XML_AUDIO_POLICY_CONF
endif #ifeq ($(USE_XML_AUDIO_POLICY_CONF), 1)
diff --git a/services/audiopolicy/common/managerdefinitions/Android.mk b/services/audiopolicy/common/managerdefinitions/Android.mk
index bacb780..3336b79 100644
--- a/services/audiopolicy/common/managerdefinitions/Android.mk
+++ b/services/audiopolicy/common/managerdefinitions/Android.mk
@@ -39,7 +39,7 @@
LOCAL_SRC_FILES += src/Serializer.cpp
-LOCAL_SHARED_LIBRARIES += libicuuc libxml2
+LOCAL_SHARED_LIBRARIES += libhidlbase libicuuc libxml2
LOCAL_C_INCLUDES += \
external/libxml2/include \
diff --git a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
index e062e4e..d5a09fe 100644
--- a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
@@ -20,6 +20,7 @@
#include <memory>
#include <string>
+#include <hidl/Status.h>
#include <libxml/parser.h>
#include <libxml/xinclude.h>
#include <media/convert.h>
@@ -34,14 +35,20 @@
namespace {
+// TODO(mnaganov): Consider finding an alternative for using HIDL code.
+using hardware::Return;
+using hardware::Status;
using utilities::convertTo;
template<typename E, typename C>
struct BaseSerializerTraits {
- typedef E Element;
- typedef sp<E> PtrElement;
+ typedef sp<E> Element;
typedef C Collection;
typedef void* PtrSerializingCtx;
+
+ static status_t addElementToCollection(const Element &element, Collection *collection) {
+ return collection->add(element) >= 0 ? NO_ERROR : BAD_VALUE;
+ }
};
struct AudioGainTraits : public BaseSerializerTraits<AudioGain, AudioGainCollection>
@@ -66,8 +73,7 @@
static constexpr const char *maxRampMs = "maxRampMs";
};
- static status_t deserialize(xmlDoc *doc, const xmlNode *root, PtrElement *element,
- PtrSerializingCtx serializingContext);
+ static Return<Element> deserialize(const xmlNode *cur, PtrSerializingCtx serializingContext);
// No children
};
@@ -85,8 +91,7 @@
static constexpr const char *channelMasks = "channelMasks";
};
- static status_t deserialize(xmlDoc *doc, const xmlNode *root, PtrElement *element,
- PtrSerializingCtx serializingContext);
+ static Return<Element> deserialize(const xmlNode *cur, PtrSerializingCtx serializingContext);
};
struct MixPortTraits : public BaseSerializerTraits<IOProfile, IOProfileCollection>
@@ -104,8 +109,7 @@
static constexpr const char *maxActiveCount = "maxActiveCount";
};
- static status_t deserialize(xmlDoc *doc, const xmlNode *root, PtrElement *element,
- PtrSerializingCtx serializingContext);
+ static Return<Element> deserialize(const xmlNode *cur, PtrSerializingCtx serializingContext);
// Children: GainTraits
};
@@ -125,8 +129,7 @@
static constexpr const char *address = "address";
};
- static status_t deserialize(xmlDoc *doc, const xmlNode *root, PtrElement *element,
- PtrSerializingCtx serializingContext);
+ static Return<Element> deserialize(const xmlNode *cur, PtrSerializingCtx serializingContext);
// Children: GainTraits (optional)
};
@@ -146,8 +149,7 @@
typedef HwModule *PtrSerializingCtx;
- static status_t deserialize(xmlDoc *doc, const xmlNode *root, PtrElement *element,
- PtrSerializingCtx ctx);
+ static Return<Element> deserialize(const xmlNode *cur, PtrSerializingCtx serializingContext);
};
struct ModuleTraits : public BaseSerializerTraits<HwModule, HwModuleCollection>
@@ -167,9 +169,7 @@
typedef AudioPolicyConfig *PtrSerializingCtx;
- static status_t deserialize(xmlDoc *doc, const xmlNode *root, PtrElement *element,
- PtrSerializingCtx serializingContext);
-
+ static Return<Element> deserialize(const xmlNode *cur, PtrSerializingCtx serializingContext);
// Children: mixPortTraits, devicePortTraits, and routeTraits
// Need to call deserialize on each child
};
@@ -201,8 +201,7 @@
static constexpr const char *referenceName = "name";
};
- static status_t deserialize(xmlDoc *doc, const xmlNode *root, PtrElement *element,
- PtrSerializingCtx serializingContext);
+ static Return<Element> deserialize(const xmlNode *cur, PtrSerializingCtx serializingContext);
// No Children
};
@@ -213,7 +212,7 @@
{
ALOGV("%s: Version=%s Root=%s", __func__, mVersion.c_str(), rootName);
}
- status_t deserialize(const char *str, AudioPolicyConfig *config);
+ status_t deserialize(const char *configFile, AudioPolicyConfig *config);
private:
static constexpr const char *rootName = "audioPolicyConfiguration";
@@ -257,10 +256,9 @@
template <class Trait>
const xmlNode* getReference(const xmlNode *cur, const std::string &refName)
{
- while (cur != NULL) {
+ for (; cur != NULL; cur = cur->next) {
if (!xmlStrcmp(cur->name, reinterpret_cast<const xmlChar*>(Trait::collectionTag))) {
- const xmlNode *child = cur->children;
- while (child != NULL) {
+ for (const xmlNode *child = cur->children; child != NULL; child = child->next) {
if ((!xmlStrcmp(child->name,
reinterpret_cast<const xmlChar*>(Trait::referenceTag)))) {
std::string name = getXmlAttribute(child, Trait::Attributes::referenceName);
@@ -268,100 +266,93 @@
return child;
}
}
- child = child->next;
}
}
- cur = cur->next;
}
return NULL;
}
template <class Trait>
-status_t deserializeCollection(xmlDoc *doc, const xmlNode *cur,
+status_t deserializeCollection(const xmlNode *cur,
typename Trait::Collection *collection,
typename Trait::PtrSerializingCtx serializingContext)
{
- cur = cur->xmlChildrenNode;
- while (cur != NULL) {
- if (xmlStrcmp(cur->name, reinterpret_cast<const xmlChar*>(Trait::collectionTag)) &&
- xmlStrcmp(cur->name, reinterpret_cast<const xmlChar*>(Trait::tag))) {
- cur = cur->next;
- continue;
+ for (cur = cur->xmlChildrenNode; cur != NULL; cur = cur->next) {
+ const xmlNode *child = NULL;
+ if (!xmlStrcmp(cur->name, reinterpret_cast<const xmlChar*>(Trait::collectionTag))) {
+ child = cur->xmlChildrenNode;
+ } else if (!xmlStrcmp(cur->name, reinterpret_cast<const xmlChar*>(Trait::tag))) {
+ child = cur;
}
- const xmlNode *child = cur;
- if (!xmlStrcmp(child->name, reinterpret_cast<const xmlChar*>(Trait::collectionTag))) {
- child = child->xmlChildrenNode;
- }
- while (child != NULL) {
+ for (; child != NULL; child = child->next) {
if (!xmlStrcmp(child->name, reinterpret_cast<const xmlChar*>(Trait::tag))) {
- typename Trait::PtrElement element;
- status_t status = Trait::deserialize(doc, child, &element, serializingContext);
- if (status != NO_ERROR) {
- return status;
- }
- if (collection->add(element) < 0) {
- ALOGE("%s: could not add element to %s collection", __func__,
- Trait::collectionTag);
+ auto element = Trait::deserialize(child, serializingContext);
+ if (element.isOk()) {
+ status_t status = Trait::addElementToCollection(element, collection);
+ if (status != NO_ERROR) {
+ ALOGE("%s: could not add element to %s collection", __func__,
+ Trait::collectionTag);
+ return status;
+ }
+ } else {
return BAD_VALUE;
}
}
- child = child->next;
}
if (!xmlStrcmp(cur->name, reinterpret_cast<const xmlChar*>(Trait::tag))) {
return NO_ERROR;
}
- cur = cur->next;
}
return NO_ERROR;
}
-status_t AudioGainTraits::deserialize(xmlDoc */*doc*/, const xmlNode *root, PtrElement *element,
- PtrSerializingCtx /*serializingContext*/)
+Return<AudioGainTraits::Element> AudioGainTraits::deserialize(const xmlNode *cur,
+ PtrSerializingCtx /*serializingContext*/)
{
static uint32_t index = 0;
- PtrElement &gain = *element = new Element(index++, true);
+ Element gain = new AudioGain(index++, true);
- std::string mode = getXmlAttribute(root, Attributes::mode);
+ std::string mode = getXmlAttribute(cur, Attributes::mode);
if (!mode.empty()) {
gain->setMode(GainModeConverter::maskFromString(mode));
}
- std::string channelsLiteral = getXmlAttribute(root, Attributes::channelMask);
+ std::string channelsLiteral = getXmlAttribute(cur, Attributes::channelMask);
if (!channelsLiteral.empty()) {
gain->setChannelMask(channelMaskFromString(channelsLiteral));
}
- std::string minValueMBLiteral = getXmlAttribute(root, Attributes::minValueMB);
+ std::string minValueMBLiteral = getXmlAttribute(cur, Attributes::minValueMB);
int32_t minValueMB;
if (!minValueMBLiteral.empty() && convertTo(minValueMBLiteral, minValueMB)) {
gain->setMinValueInMb(minValueMB);
}
- std::string maxValueMBLiteral = getXmlAttribute(root, Attributes::maxValueMB);
+ std::string maxValueMBLiteral = getXmlAttribute(cur, Attributes::maxValueMB);
int32_t maxValueMB;
if (!maxValueMBLiteral.empty() && convertTo(maxValueMBLiteral, maxValueMB)) {
gain->setMaxValueInMb(maxValueMB);
}
- std::string defaultValueMBLiteral = getXmlAttribute(root, Attributes::defaultValueMB);
+ std::string defaultValueMBLiteral = getXmlAttribute(cur, Attributes::defaultValueMB);
int32_t defaultValueMB;
if (!defaultValueMBLiteral.empty() && convertTo(defaultValueMBLiteral, defaultValueMB)) {
gain->setDefaultValueInMb(defaultValueMB);
}
- std::string stepValueMBLiteral = getXmlAttribute(root, Attributes::stepValueMB);
+ std::string stepValueMBLiteral = getXmlAttribute(cur, Attributes::stepValueMB);
uint32_t stepValueMB;
if (!stepValueMBLiteral.empty() && convertTo(stepValueMBLiteral, stepValueMB)) {
gain->setStepValueInMb(stepValueMB);
}
- std::string minRampMsLiteral = getXmlAttribute(root, Attributes::minRampMs);
+ std::string minRampMsLiteral = getXmlAttribute(cur, Attributes::minRampMs);
uint32_t minRampMs;
if (!minRampMsLiteral.empty() && convertTo(minRampMsLiteral, minRampMs)) {
gain->setMinRampInMs(minRampMs);
}
- std::string maxRampMsLiteral = getXmlAttribute(root, Attributes::maxRampMs);
+ std::string maxRampMsLiteral = getXmlAttribute(cur, Attributes::maxRampMs);
uint32_t maxRampMs;
if (!maxRampMsLiteral.empty() && convertTo(maxRampMsLiteral, maxRampMs)) {
gain->setMaxRampInMs(maxRampMs);
@@ -370,20 +361,21 @@
gain->getMode(), gain->getChannelMask(), gain->getMinValueInMb(),
gain->getMaxValueInMb());
- if (gain->getMode() == 0) {
- return BAD_VALUE;
+ if (gain->getMode() != 0) {
+ return gain;
+ } else {
+ return Status::fromStatusT(BAD_VALUE);
}
- return NO_ERROR;
}
-status_t AudioProfileTraits::deserialize(xmlDoc */*doc*/, const xmlNode *root, PtrElement *element,
- PtrSerializingCtx /*serializingContext*/)
+Return<AudioProfileTraits::Element> AudioProfileTraits::deserialize(const xmlNode *cur,
+ PtrSerializingCtx /*serializingContext*/)
{
- std::string samplingRates = getXmlAttribute(root, Attributes::samplingRates);
- std::string format = getXmlAttribute(root, Attributes::format);
- std::string channels = getXmlAttribute(root, Attributes::channelMasks);
+ std::string samplingRates = getXmlAttribute(cur, Attributes::samplingRates);
+ std::string format = getXmlAttribute(cur, Attributes::format);
+ std::string channels = getXmlAttribute(cur, Attributes::channelMasks);
- PtrElement &profile = *element = new Element(formatFromString(format, gDynamicFormat),
+ Element profile = new AudioProfile(formatFromString(format, gDynamicFormat),
channelMasksFromString(channels, ","),
samplingRatesFromString(samplingRates, ","));
@@ -391,33 +383,33 @@
profile->setDynamicChannels(profile->getChannels().isEmpty());
profile->setDynamicRate(profile->getSampleRates().isEmpty());
- return NO_ERROR;
+ return profile;
}
-status_t MixPortTraits::deserialize(xmlDoc *doc, const xmlNode *child, PtrElement *element,
- PtrSerializingCtx /*serializingContext*/)
+Return<MixPortTraits::Element> MixPortTraits::deserialize(const xmlNode *child,
+ PtrSerializingCtx /*serializingContext*/)
{
std::string name = getXmlAttribute(child, Attributes::name);
if (name.empty()) {
ALOGE("%s: No %s found", __func__, Attributes::name);
- return BAD_VALUE;
+ return Status::fromStatusT(BAD_VALUE);
}
ALOGV("%s: %s %s=%s", __func__, tag, Attributes::name, name.c_str());
std::string role = getXmlAttribute(child, Attributes::role);
if (role.empty()) {
ALOGE("%s: No %s found", __func__, Attributes::role);
- return BAD_VALUE;
+ return Status::fromStatusT(BAD_VALUE);
}
ALOGV("%s: Role=%s", __func__, role.c_str());
audio_port_role_t portRole = (role == Attributes::roleSource) ?
AUDIO_PORT_ROLE_SOURCE : AUDIO_PORT_ROLE_SINK;
- PtrElement &mixPort = *element = new Element(String8(name.c_str()), portRole);
+ Element mixPort = new IOProfile(String8(name.c_str()), portRole);
AudioProfileTraits::Collection profiles;
- status_t status = deserializeCollection<AudioProfileTraits>(doc, child, &profiles, NULL);
+ status_t status = deserializeCollection<AudioProfileTraits>(child, &profiles, NULL);
if (status != NO_ERROR) {
- return status;
+ return Status::fromStatusT(status);
}
if (profiles.isEmpty()) {
profiles.add(AudioProfile::createFullDynamic());
@@ -444,34 +436,34 @@
}
// Deserialize children
AudioGainTraits::Collection gains;
- status = deserializeCollection<AudioGainTraits>(doc, child, &gains, NULL);
+ status = deserializeCollection<AudioGainTraits>(child, &gains, NULL);
if (status != NO_ERROR) {
- return status;
+ return Status::fromStatusT(status);
}
mixPort->setGains(gains);
- return NO_ERROR;
+ return mixPort;
}
-status_t DevicePortTraits::deserialize(xmlDoc *doc, const xmlNode *root, PtrElement *element,
- PtrSerializingCtx /*serializingContext*/)
+Return<DevicePortTraits::Element> DevicePortTraits::deserialize(const xmlNode *cur,
+ PtrSerializingCtx /*serializingContext*/)
{
- std::string name = getXmlAttribute(root, Attributes::tagName);
+ std::string name = getXmlAttribute(cur, Attributes::tagName);
if (name.empty()) {
ALOGE("%s: No %s found", __func__, Attributes::tagName);
- return BAD_VALUE;
+ return Status::fromStatusT(BAD_VALUE);
}
ALOGV("%s: %s %s=%s", __func__, tag, Attributes::tagName, name.c_str());
- std::string typeName = getXmlAttribute(root, Attributes::type);
+ std::string typeName = getXmlAttribute(cur, Attributes::type);
if (typeName.empty()) {
ALOGE("%s: no type for %s", __func__, name.c_str());
- return BAD_VALUE;
+ return Status::fromStatusT(BAD_VALUE);
}
ALOGV("%s: %s %s=%s", __func__, tag, Attributes::type, typeName.c_str());
- std::string role = getXmlAttribute(root, Attributes::role);
+ std::string role = getXmlAttribute(cur, Attributes::role);
if (role.empty()) {
ALOGE("%s: No %s found", __func__, Attributes::role);
- return BAD_VALUE;
+ return Status::fromStatusT(BAD_VALUE);
}
ALOGV("%s: %s %s=%s", __func__, tag, Attributes::role, role.c_str());
audio_port_role_t portRole = (role == Attributes::roleSource) ?
@@ -482,20 +474,20 @@
(!audio_is_input_device(type) && portRole == AUDIO_PORT_ROLE_SOURCE) ||
(!audio_is_output_devices(type) && portRole == AUDIO_PORT_ROLE_SINK)) {
ALOGW("%s: bad type %08x", __func__, type);
- return BAD_VALUE;
+ return Status::fromStatusT(BAD_VALUE);
}
- PtrElement &deviceDesc = *element = new Element(type, String8(name.c_str()));
+ Element deviceDesc = new DeviceDescriptor(type, String8(name.c_str()));
- std::string address = getXmlAttribute(root, Attributes::address);
+ std::string address = getXmlAttribute(cur, Attributes::address);
if (!address.empty()) {
ALOGV("%s: address=%s for %s", __func__, address.c_str(), name.c_str());
deviceDesc->mAddress = String8(address.c_str());
}
AudioProfileTraits::Collection profiles;
- status_t status = deserializeCollection<AudioProfileTraits>(doc, root, &profiles, NULL);
+ status_t status = deserializeCollection<AudioProfileTraits>(cur, &profiles, NULL);
if (status != NO_ERROR) {
- return status;
+ return Status::fromStatusT(status);
}
if (profiles.isEmpty()) {
profiles.add(AudioProfile::createFullDynamic());
@@ -503,46 +495,45 @@
deviceDesc->setAudioProfiles(profiles);
// Deserialize AudioGain children
- status = deserializeCollection<AudioGainTraits>(doc, root, &deviceDesc->mGains, NULL);
+ status = deserializeCollection<AudioGainTraits>(cur, &deviceDesc->mGains, NULL);
if (status != NO_ERROR) {
- return status;
+ return Status::fromStatusT(status);
}
ALOGV("%s: adding device tag %s type %08x address %s", __func__,
deviceDesc->getName().string(), type, deviceDesc->mAddress.string());
- return NO_ERROR;
+ return deviceDesc;
}
-status_t RouteTraits::deserialize(xmlDoc */*doc*/, const xmlNode *root, PtrElement *element,
- PtrSerializingCtx ctx)
+Return<RouteTraits::Element> RouteTraits::deserialize(const xmlNode *cur, PtrSerializingCtx ctx)
{
- std::string type = getXmlAttribute(root, Attributes::type);
+ std::string type = getXmlAttribute(cur, Attributes::type);
if (type.empty()) {
ALOGE("%s: No %s found", __func__, Attributes::type);
- return BAD_VALUE;
+ return Status::fromStatusT(BAD_VALUE);
}
audio_route_type_t routeType = (type == Attributes::typeMix) ?
AUDIO_ROUTE_MIX : AUDIO_ROUTE_MUX;
ALOGV("%s: %s %s=%s", __func__, tag, Attributes::type, type.c_str());
- PtrElement &route = *element = new Element(routeType);
+ Element route = new AudioRoute(routeType);
- std::string sinkAttr = getXmlAttribute(root, Attributes::sink);
+ std::string sinkAttr = getXmlAttribute(cur, Attributes::sink);
if (sinkAttr.empty()) {
ALOGE("%s: No %s found", __func__, Attributes::sink);
- return BAD_VALUE;
+ return Status::fromStatusT(BAD_VALUE);
}
// Convert Sink name to port pointer
sp<AudioPort> sink = ctx->findPortByTagName(String8(sinkAttr.c_str()));
if (sink == NULL) {
ALOGE("%s: no sink found with name=%s", __func__, sinkAttr.c_str());
- return BAD_VALUE;
+ return Status::fromStatusT(BAD_VALUE);
}
route->setSink(sink);
- std::string sourcesAttr = getXmlAttribute(root, Attributes::sources);
+ std::string sourcesAttr = getXmlAttribute(cur, Attributes::sources);
if (sourcesAttr.empty()) {
ALOGE("%s: No %s found", __func__, Attributes::sources);
- return BAD_VALUE;
+ return Status::fromStatusT(BAD_VALUE);
}
// Tokenize and Convert Sources name to port pointer
AudioPortVector sources;
@@ -554,7 +545,7 @@
sp<AudioPort> source = ctx->findPortByTagName(String8(devTag));
if (source == NULL) {
ALOGE("%s: no source found with name=%s", __func__, devTag);
- return BAD_VALUE;
+ return Status::fromStatusT(BAD_VALUE);
}
sources.add(source);
}
@@ -567,19 +558,18 @@
source->addRoute(route);
}
route->setSources(sources);
- return NO_ERROR;
+ return route;
}
-status_t ModuleTraits::deserialize(xmlDocPtr doc, const xmlNode *root, PtrElement *element,
- PtrSerializingCtx ctx)
+Return<ModuleTraits::Element> ModuleTraits::deserialize(const xmlNode *cur, PtrSerializingCtx ctx)
{
- std::string name = getXmlAttribute(root, Attributes::name);
+ std::string name = getXmlAttribute(cur, Attributes::name);
if (name.empty()) {
ALOGE("%s: No %s found", __func__, Attributes::name);
- return BAD_VALUE;
+ return Status::fromStatusT(BAD_VALUE);
}
uint32_t versionMajor = 0, versionMinor = 0;
- std::string versionLiteral = getXmlAttribute(root, Attributes::version);
+ std::string versionLiteral = getXmlAttribute(cur, Attributes::version);
if (!versionLiteral.empty()) {
sscanf(versionLiteral.c_str(), "%u.%u", &versionMajor, &versionMinor);
ALOGV("%s: mHalVersion = major %u minor %u", __func__,
@@ -588,40 +578,40 @@
ALOGV("%s: %s %s=%s", __func__, tag, Attributes::name, name.c_str());
- PtrElement &module = *element = new Element(name.c_str(), versionMajor, versionMinor);
+ Element module = new HwModule(name.c_str(), versionMajor, versionMinor);
// Deserialize childrens: Audio Mix Port, Audio Device Ports (Source/Sink), Audio Routes
MixPortTraits::Collection mixPorts;
- status_t status = deserializeCollection<MixPortTraits>(doc, root, &mixPorts, NULL);
+ status_t status = deserializeCollection<MixPortTraits>(cur, &mixPorts, NULL);
if (status != NO_ERROR) {
- return status;
+ return Status::fromStatusT(status);
}
module->setProfiles(mixPorts);
DevicePortTraits::Collection devicePorts;
- status = deserializeCollection<DevicePortTraits>(doc, root, &devicePorts, NULL);
+ status = deserializeCollection<DevicePortTraits>(cur, &devicePorts, NULL);
if (status != NO_ERROR) {
- return status;
+ return Status::fromStatusT(status);
}
module->setDeclaredDevices(devicePorts);
RouteTraits::Collection routes;
- status = deserializeCollection<RouteTraits>(doc, root, &routes, module.get());
+ status = deserializeCollection<RouteTraits>(cur, &routes, module.get());
if (status != NO_ERROR) {
- return status;
+ return Status::fromStatusT(status);
}
module->setRoutes(routes);
- const xmlNode *children = root->xmlChildrenNode;
- while (children != NULL) {
+ for (const xmlNode *children = cur->xmlChildrenNode; children != NULL;
+ children = children->next) {
if (!xmlStrcmp(children->name, reinterpret_cast<const xmlChar*>(childAttachedDevicesTag))) {
ALOGV("%s: %s %s found", __func__, tag, childAttachedDevicesTag);
- const xmlNode *child = children->xmlChildrenNode;
- while (child != NULL) {
+ for (const xmlNode *child = children->xmlChildrenNode; child != NULL;
+ child = child->next) {
if (!xmlStrcmp(child->name,
reinterpret_cast<const xmlChar*>(childAttachedDeviceTag))) {
auto attachedDevice = make_xmlUnique(xmlNodeListGetString(
- doc, child->xmlChildrenNode, 1));
+ child->doc, child->xmlChildrenNode, 1));
if (attachedDevice != nullptr) {
ALOGV("%s: %s %s=%s", __func__, tag, childAttachedDeviceTag,
reinterpret_cast<const char*>(attachedDevice.get()));
@@ -631,13 +621,12 @@
ctx->addAvailableDevice(device);
}
}
- child = child->next;
}
}
if (!xmlStrcmp(children->name,
reinterpret_cast<const xmlChar*>(childDefaultOutputDeviceTag))) {
auto defaultOutputDevice = make_xmlUnique(xmlNodeListGetString(
- doc, children->xmlChildrenNode, 1));
+ children->doc, children->xmlChildrenNode, 1));
if (defaultOutputDevice != nullptr) {
ALOGV("%s: %s %s=%s", __func__, tag, childDefaultOutputDeviceTag,
reinterpret_cast<const char*>(defaultOutputDevice.get()));
@@ -650,18 +639,16 @@
}
}
}
- children = children->next;
}
- return NO_ERROR;
+ return module;
}
-status_t GlobalConfigTraits::deserialize(const xmlNode *cur, AudioPolicyConfig *config)
+status_t GlobalConfigTraits::deserialize(const xmlNode *root, AudioPolicyConfig *config)
{
- const xmlNode *root = cur->xmlChildrenNode;
- while (root != NULL) {
- if (!xmlStrcmp(root->name, reinterpret_cast<const xmlChar*>(tag))) {
+ for (const xmlNode *cur = root->xmlChildrenNode; cur != NULL; cur = cur->next) {
+ if (!xmlStrcmp(cur->name, reinterpret_cast<const xmlChar*>(tag))) {
std::string speakerDrcEnabled =
- getXmlAttribute(root, Attributes::speakerDrcEnabled);
+ getXmlAttribute(cur, Attributes::speakerDrcEnabled);
bool isSpeakerDrcEnabled;
if (!speakerDrcEnabled.empty() &&
convertTo<std::string, bool>(speakerDrcEnabled, isSpeakerDrcEnabled)) {
@@ -669,55 +656,54 @@
}
return NO_ERROR;
}
- root = root->next;
}
return NO_ERROR;
}
-status_t VolumeTraits::deserialize(xmlDoc *doc, const xmlNode *root, PtrElement *element,
- PtrSerializingCtx /*serializingContext*/)
+Return<VolumeTraits::Element> VolumeTraits::deserialize(const xmlNode *cur,
+ PtrSerializingCtx /*serializingContext*/)
{
- std::string streamTypeLiteral = getXmlAttribute(root, Attributes::stream);
+ std::string streamTypeLiteral = getXmlAttribute(cur, Attributes::stream);
if (streamTypeLiteral.empty()) {
ALOGE("%s: No %s found", __func__, Attributes::stream);
- return BAD_VALUE;
+ return Status::fromStatusT(BAD_VALUE);
}
audio_stream_type_t streamType;
if (!StreamTypeConverter::fromString(streamTypeLiteral, streamType)) {
ALOGE("%s: Invalid %s", __func__, Attributes::stream);
- return BAD_VALUE;
+ return Status::fromStatusT(BAD_VALUE);
}
- std::string deviceCategoryLiteral = getXmlAttribute(root, Attributes::deviceCategory);
+ std::string deviceCategoryLiteral = getXmlAttribute(cur, Attributes::deviceCategory);
if (deviceCategoryLiteral.empty()) {
ALOGE("%s: No %s found", __func__, Attributes::deviceCategory);
- return BAD_VALUE;
+ return Status::fromStatusT(BAD_VALUE);
}
device_category deviceCategory;
if (!DeviceCategoryConverter::fromString(deviceCategoryLiteral, deviceCategory)) {
ALOGE("%s: Invalid %s=%s", __func__, Attributes::deviceCategory,
deviceCategoryLiteral.c_str());
- return BAD_VALUE;
+ return Status::fromStatusT(BAD_VALUE);
}
- std::string referenceName = getXmlAttribute(root, Attributes::reference);
+ std::string referenceName = getXmlAttribute(cur, Attributes::reference);
const xmlNode *ref = NULL;
if (!referenceName.empty()) {
- ref = getReference<VolumeTraits>(root->parent, referenceName);
+ ref = getReference<VolumeTraits>(cur->parent, referenceName);
if (ref == NULL) {
ALOGE("%s: No reference Ptr found for %s", __func__, referenceName.c_str());
- return BAD_VALUE;
+ return Status::fromStatusT(BAD_VALUE);
}
}
- PtrElement &volCurve = *element = new Element(deviceCategory, streamType);
+ Element volCurve = new VolumeCurve(deviceCategory, streamType);
- const xmlNode *child = referenceName.empty() ? root->xmlChildrenNode : ref->xmlChildrenNode;
- while (child != NULL) {
+ for (const xmlNode *child = referenceName.empty() ? cur->xmlChildrenNode : ref->xmlChildrenNode;
+ child != NULL; child = child->next) {
if (!xmlStrcmp(child->name, reinterpret_cast<const xmlChar*>(volumePointTag))) {
auto pointDefinition = make_xmlUnique(xmlNodeListGetString(
- doc, child->xmlChildrenNode, 1));
+ child->doc, child->xmlChildrenNode, 1));
if (pointDefinition == nullptr) {
- return BAD_VALUE;
+ return Status::fromStatusT(BAD_VALUE);
}
ALOGV("%s: %s=%s",
__func__, tag, reinterpret_cast<const char*>(pointDefinition.get()));
@@ -727,13 +713,12 @@
if (point.size() != 2) {
ALOGE("%s: Invalid %s: %s", __func__, volumePointTag,
reinterpret_cast<const char*>(pointDefinition.get()));
- return BAD_VALUE;
+ return Status::fromStatusT(BAD_VALUE);
}
volCurve->add(CurvePoint(point[0], point[1]));
}
- child = child->next;
}
- return NO_ERROR;
+ return volCurve;
}
status_t PolicySerializer::deserialize(const char *configFile, AudioPolicyConfig *config)
@@ -743,8 +728,8 @@
ALOGE("%s: Could not parse %s document.", __func__, configFile);
return BAD_VALUE;
}
- xmlNodePtr cur = xmlDocGetRootElement(doc.get());
- if (cur == NULL) {
+ xmlNodePtr root = xmlDocGetRootElement(doc.get());
+ if (root == NULL) {
ALOGE("%s: Could not parse %s document: empty.", __func__, configFile);
return BAD_VALUE;
}
@@ -752,13 +737,13 @@
ALOGE("%s: libxml failed to resolve XIncludes on %s document.", __func__, configFile);
}
- if (xmlStrcmp(cur->name, reinterpret_cast<const xmlChar*>(rootName))) {
+ if (xmlStrcmp(root->name, reinterpret_cast<const xmlChar*>(rootName))) {
ALOGE("%s: No %s root element found in xml data %s.", __func__, rootName,
- reinterpret_cast<const char*>(cur->name));
+ reinterpret_cast<const char*>(root->name));
return BAD_VALUE;
}
- std::string version = getXmlAttribute(cur, versionAttribute);
+ std::string version = getXmlAttribute(root, versionAttribute);
if (version.empty()) {
ALOGE("%s: No version found in root node %s", __func__, rootName);
return BAD_VALUE;
@@ -771,7 +756,7 @@
// Lets deserialize children
// Modules
ModuleTraits::Collection modules;
- status_t status = deserializeCollection<ModuleTraits>(doc.get(), cur, &modules, config);
+ status_t status = deserializeCollection<ModuleTraits>(root, &modules, config);
if (status != NO_ERROR) {
return status;
}
@@ -779,14 +764,14 @@
// deserialize volume section
VolumeTraits::Collection volumes;
- status = deserializeCollection<VolumeTraits>(doc.get(), cur, &volumes, config);
+ status = deserializeCollection<VolumeTraits>(root, &volumes, config);
if (status != NO_ERROR) {
return status;
}
config->setVolumes(volumes);
// Global Configuration
- GlobalConfigTraits::deserialize(cur, config);
+ GlobalConfigTraits::deserialize(root, config);
return android::OK;
}
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index 600f968..380f0fb 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -2697,7 +2697,7 @@
mAudioSources.dump(fd);
if (!mSurroundFormats.empty()) {
- result = String8("\nManually Enabled Surround Formats:\n");
+ result = String8("\nEnabled Surround Formats:\n");
size_t i = 0;
for (const auto& fmt : mSurroundFormats) {
result.append(i++ == 0 ? " " : ", ");
@@ -3554,50 +3554,6 @@
return computeVolume(stream, index, device);
}
-status_t AudioPolicyManager::getSupportedFormats(audio_io_handle_t ioHandle,
- FormatVector& formats) {
- if (ioHandle == AUDIO_IO_HANDLE_NONE) {
- return BAD_VALUE;
- }
- String8 reply;
- reply = mpClientInterface->getParameters(
- ioHandle, String8(AudioParameter::keyStreamSupportedFormats));
- ALOGV("%s: supported formats %s", __FUNCTION__, reply.string());
- AudioParameter repliedParameters(reply);
- if (repliedParameters.get(
- String8(AudioParameter::keyStreamSupportedFormats), reply) != NO_ERROR) {
- ALOGE("%s: failed to retrieve format, bailing out", __FUNCTION__);
- return BAD_VALUE;
- }
- for (auto format : formatsFromString(reply.string())) {
- // Only AUDIO_FORMAT_AAC_LC will be used in Settings UI for all AAC formats.
- for (size_t i = 0; i < ARRAY_SIZE(AAC_FORMATS); i++) {
- if (format == AAC_FORMATS[i]) {
- format = AUDIO_FORMAT_AAC_LC;
- break;
- }
- }
- bool exist = false;
- for (size_t i = 0; i < formats.size(); i++) {
- if (format == formats[i]) {
- exist = true;
- break;
- }
- }
- bool isSurroundFormat = false;
- for (size_t i = 0; i < ARRAY_SIZE(SURROUND_FORMATS); i++) {
- if (SURROUND_FORMATS[i] == format) {
- isSurroundFormat = true;
- break;
- }
- }
- if (!exist && isSurroundFormat) {
- formats.add(format);
- }
- }
- return NO_ERROR;
-}
-
status_t AudioPolicyManager::getSurroundFormats(unsigned int *numSurroundFormats,
audio_format_t *surroundFormats,
bool *surroundFormatsEnabled,
@@ -3618,89 +3574,45 @@
size_t formatsWritten = 0;
size_t formatsMax = *numSurroundFormats;
*numSurroundFormats = 0;
- FormatVector formats;
+ std::unordered_set<audio_format_t> formats;
if (reported) {
- // Only get surround formats which are reported by device.
- // First list already open outputs that can be routed to this device
- audio_devices_t device = AUDIO_DEVICE_OUT_HDMI;
- SortedVector<audio_io_handle_t> outputs;
- bool reportedFormatFound = false;
- status_t status;
- sp<SwAudioOutputDescriptor> desc;
- for (size_t i = 0; i < mOutputs.size(); i++) {
- desc = mOutputs.valueAt(i);
- if (!desc->isDuplicated() && (desc->supportedDevices() & device)) {
- outputs.add(mOutputs.keyAt(i));
- }
- }
- // Open an output to query dynamic parameters.
- DeviceVector hdmiOutputDevices = mAvailableOutputDevices.getDevicesFromTypeMask(
- AUDIO_DEVICE_OUT_HDMI);
- for (size_t i = 0; i < hdmiOutputDevices.size(); i++) {
- String8 address = hdmiOutputDevices[i]->mAddress;
- for (const auto& hwModule : mHwModules) {
- for (size_t i = 0; i < hwModule->getOutputProfiles().size(); i++) {
- sp<IOProfile> profile = hwModule->getOutputProfiles()[i];
- if (profile->supportDevice(AUDIO_DEVICE_OUT_HDMI) &&
- profile->supportDeviceAddress(address)) {
- size_t j;
- for (j = 0; j < outputs.size(); j++) {
- desc = mOutputs.valueFor(outputs.itemAt(j));
- if (!desc->isDuplicated() && desc->mProfile == profile) {
- break;
- }
- }
- if (j != outputs.size()) {
- status = getSupportedFormats(outputs.itemAt(j), formats);
- reportedFormatFound |= (status == NO_ERROR);
- continue;
- }
-
- if (!profile->canOpenNewIo()) {
- ALOGW("Max Output number %u already opened for this profile %s",
- profile->maxOpenCount, profile->getTagName().c_str());
- continue;
- }
-
- ALOGV("opening output for device %08x with params %s profile %p name %s",
- device, address.string(), profile.get(), profile->getName().string());
- desc = new SwAudioOutputDescriptor(profile, mpClientInterface);
- audio_io_handle_t output = AUDIO_IO_HANDLE_NONE;
- status_t status = desc->open(nullptr, device, address,
- AUDIO_STREAM_DEFAULT, AUDIO_OUTPUT_FLAG_NONE,
- &output);
-
- if (status == NO_ERROR) {
- status = getSupportedFormats(output, formats);
- reportedFormatFound |= (status == NO_ERROR);
- desc->close();
- output = AUDIO_IO_HANDLE_NONE;
- }
- }
- }
- }
- }
-
- if (!reportedFormatFound) {
- return UNKNOWN_ERROR;
+ // Return formats from HDMI profiles, that have already been resolved by
+ // checkOutputsForDevice().
+ DeviceVector hdmiOutputDevs = mAvailableOutputDevices.getDevicesFromTypeMask(
+ AUDIO_DEVICE_OUT_HDMI);
+ for (size_t i = 0; i < hdmiOutputDevs.size(); i++) {
+ FormatVector supportedFormats =
+ hdmiOutputDevs[i]->getAudioPort()->getAudioProfiles().getSupportedFormats();
+ for (size_t j = 0; j < supportedFormats.size(); j++) {
+ if (std::find(std::begin(SURROUND_FORMATS),
+ std::end(SURROUND_FORMATS),
+ supportedFormats[j]) != std::end(SURROUND_FORMATS)) {
+ formats.insert(supportedFormats[j]);
+ } else if (std::find(std::begin(AAC_FORMATS),
+ std::end(AAC_FORMATS),
+ supportedFormats[j]) != std::end(AAC_FORMATS)) {
+ // if any format in AAC_FORMATS is reported, insert AUDIO_FORMAT_AAC_LC as this
+ // is the only AAC format used in the TvSettings UI for all AAC formats.
+ formats.insert(AUDIO_FORMAT_AAC_LC);
+ }
+ }
}
} else {
for (size_t i = 0; i < ARRAY_SIZE(SURROUND_FORMATS); i++) {
- formats.add(SURROUND_FORMATS[i]);
+ formats.insert(SURROUND_FORMATS[i]);
}
}
- for (size_t i = 0; i < formats.size(); i++) {
+ for (const auto& format: formats) {
if (formatsWritten < formatsMax) {
- surroundFormats[formatsWritten] = formats[i];
+ surroundFormats[formatsWritten] = format;
bool formatEnabled = false;
- if (formats[i] == AUDIO_FORMAT_AAC_LC) {
- for (size_t j = 0; j < ARRAY_SIZE(AAC_FORMATS); j++) {
+ if (format == AUDIO_FORMAT_AAC_LC) {
+ for (size_t j = 0; j < ARRAY_SIZE(AAC_FORMATS) && !formatEnabled; j++) {
formatEnabled =
- mSurroundFormats.find(AAC_FORMATS[i]) != mSurroundFormats.end();
- break;
+ mSurroundFormats.find(AAC_FORMATS[j]) != mSurroundFormats.end();
}
} else {
- formatEnabled = mSurroundFormats.find(formats[i]) != mSurroundFormats.end();
+ formatEnabled = mSurroundFormats.find(format) != mSurroundFormats.end();
}
surroundFormatsEnabled[formatsWritten++] = formatEnabled;
}
@@ -3744,6 +3656,7 @@
return INVALID_OPERATION;
}
+ std::unordered_set<audio_format_t> surroundFormatsBackup(mSurroundFormats);
if (enabled) {
if (audioFormat == AUDIO_FORMAT_AAC_LC) {
for (size_t i = 0; i < ARRAY_SIZE(AAC_FORMATS); i++) {
@@ -3806,23 +3719,7 @@
// Undo the surround formats change due to no audio profiles updated.
if (!profileUpdated) {
ALOGW("%s() no audio profiles updated, undoing surround formats change", __func__);
- if (enabled) {
- if (audioFormat == AUDIO_FORMAT_AAC_LC) {
- for (size_t i = 0; i < ARRAY_SIZE(AAC_FORMATS); i++) {
- mSurroundFormats.erase(AAC_FORMATS[i]);
- }
- } else {
- mSurroundFormats.erase(audioFormat);
- }
- } else {
- if (audioFormat == AUDIO_FORMAT_AAC_LC) {
- for (size_t i = 0; i < ARRAY_SIZE(AAC_FORMATS); i++) {
- mSurroundFormats.insert(AAC_FORMATS[i]);
- }
- } else {
- mSurroundFormats.insert(audioFormat);
- }
- }
+ mSurroundFormats = std::move(surroundFormatsBackup);
}
return profileUpdated ? NO_ERROR : INVALID_OPERATION;
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.h b/services/audiopolicy/managerdefault/AudioPolicyManager.h
index 6f4cce1..fcb9d25 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.h
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.h
@@ -613,8 +613,6 @@
void filterSurroundFormats(FormatVector *formatsPtr);
void filterSurroundChannelMasks(ChannelsVector *channelMasksPtr);
- status_t getSupportedFormats(audio_io_handle_t ioHandle, FormatVector& formats);
-
// Support for Multi-Stream Decoder (MSD) module
sp<DeviceDescriptor> getMsdAudioInDevice() const;
audio_devices_t getMsdAudioOutDeviceTypes() const;
diff --git a/services/audiopolicy/service/AudioPolicyService.cpp b/services/audiopolicy/service/AudioPolicyService.cpp
index 8bca221..b1ed522 100644
--- a/services/audiopolicy/service/AudioPolicyService.cpp
+++ b/services/audiopolicy/service/AudioPolicyService.cpp
@@ -677,21 +677,27 @@
VolumeData *data = (VolumeData *)command->mParam.get();
ALOGV("AudioCommandThread() processing set volume stream %d, \
volume %f, output %d", data->mStream, data->mVolume, data->mIO);
+ mLock.unlock();
command->mStatus = AudioSystem::setStreamVolume(data->mStream,
data->mVolume,
data->mIO);
+ mLock.lock();
}break;
case SET_PARAMETERS: {
ParametersData *data = (ParametersData *)command->mParam.get();
ALOGV("AudioCommandThread() processing set parameters string %s, io %d",
data->mKeyValuePairs.string(), data->mIO);
+ mLock.unlock();
command->mStatus = AudioSystem::setParameters(data->mIO, data->mKeyValuePairs);
+ mLock.lock();
}break;
case SET_VOICE_VOLUME: {
VoiceVolumeData *data = (VoiceVolumeData *)command->mParam.get();
ALOGV("AudioCommandThread() processing set voice volume volume %f",
data->mVolume);
+ mLock.unlock();
command->mStatus = AudioSystem::setVoiceVolume(data->mVolume);
+ mLock.lock();
}break;
case STOP_OUTPUT: {
StopOutputData *data = (StopOutputData *)command->mParam.get();
@@ -724,7 +730,9 @@
if (af == 0) {
command->mStatus = PERMISSION_DENIED;
} else {
+ mLock.unlock();
command->mStatus = af->createAudioPatch(&data->mPatch, &data->mHandle);
+ mLock.lock();
}
} break;
case RELEASE_AUDIO_PATCH: {
@@ -734,7 +742,9 @@
if (af == 0) {
command->mStatus = PERMISSION_DENIED;
} else {
+ mLock.unlock();
command->mStatus = af->releaseAudioPatch(data->mHandle);
+ mLock.lock();
}
} break;
case UPDATE_AUDIOPORT_LIST: {
@@ -764,7 +774,9 @@
if (af == 0) {
command->mStatus = PERMISSION_DENIED;
} else {
+ mLock.unlock();
command->mStatus = af->setAudioPortConfig(&data->mConfig);
+ mLock.lock();
}
} break;
case DYN_POLICY_MIX_STATE_UPDATE: {
diff --git a/services/camera/libcameraservice/device3/Camera3Device.cpp b/services/camera/libcameraservice/device3/Camera3Device.cpp
index 786fd7f..48e38bb 100644
--- a/services/camera/libcameraservice/device3/Camera3Device.cpp
+++ b/services/camera/libcameraservice/device3/Camera3Device.cpp
@@ -281,7 +281,6 @@
status_t Camera3Device::disconnectImpl() {
ATRACE_CALL();
Mutex::Autolock il(mInterfaceLock);
- Mutex::Autolock stLock(mTrackerLock);
ALOGI("%s: E", __FUNCTION__);
@@ -346,6 +345,7 @@
{
Mutex::Autolock l(mLock);
mRequestThread.clear();
+ Mutex::Autolock stLock(mTrackerLock);
mStatusTracker.clear();
interface = mInterface.get();
}