Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a17a1347 authored by Dave Sparks's avatar Dave Sparks
Browse files

Use local lock for most MediaMetadataRetriever methods. Bug 2560834.

MediaMetadataRetriever uses a single static lock for all operations.
This effectively serializes all metadata retrieval operations in a
single process. This patch uses the object level lock for all normal
operations and only uses the static lock to serialize calls to
release.

Change-Id: I81c9f234c2f0007a26d18e1398c709b41a4dbbd7
parent 71662fe8
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -95,6 +95,7 @@ void MediaMetadataRetriever::disconnect()
status_t MediaMetadataRetriever::setDataSource(const char* srcUrl)
{
    LOGV("setDataSource");
    Mutex::Autolock _l(mLock);
    if (mRetriever == 0) {
        LOGE("retriever is not initialized");
        return INVALID_OPERATION;
@@ -110,6 +111,7 @@ status_t MediaMetadataRetriever::setDataSource(const char* srcUrl)
status_t MediaMetadataRetriever::setDataSource(int fd, int64_t offset, int64_t length)
{
    LOGV("setDataSource(%d, %lld, %lld)", fd, offset, length);
    Mutex::Autolock _l(mLock);
    if (mRetriever == 0) {
        LOGE("retriever is not initialized");
        return INVALID_OPERATION;
@@ -124,6 +126,7 @@ status_t MediaMetadataRetriever::setDataSource(int fd, int64_t offset, int64_t l
status_t MediaMetadataRetriever::setMode(int mode)
{
    LOGV("setMode(%d)", mode);
    Mutex::Autolock _l(mLock);
    if (mRetriever == 0) {
        LOGE("retriever is not initialized");
        return INVALID_OPERATION;
@@ -134,6 +137,7 @@ status_t MediaMetadataRetriever::setMode(int mode)
status_t MediaMetadataRetriever::getMode(int* mode)
{
    LOGV("getMode");
    Mutex::Autolock _l(mLock);
    if (mRetriever == 0) {
        LOGE("retriever is not initialized");
        return INVALID_OPERATION;
@@ -144,6 +148,7 @@ status_t MediaMetadataRetriever::getMode(int* mode)
sp<IMemory> MediaMetadataRetriever::captureFrame()
{
    LOGV("captureFrame");
    Mutex::Autolock _l(mLock);
    if (mRetriever == 0) {
        LOGE("retriever is not initialized");
        return NULL;
@@ -154,6 +159,7 @@ sp<IMemory> MediaMetadataRetriever::captureFrame()
const char* MediaMetadataRetriever::extractMetadata(int keyCode)
{
    LOGV("extractMetadata(%d)", keyCode);
    Mutex::Autolock _l(mLock);
    if (mRetriever == 0) {
        LOGE("retriever is not initialized");
        return NULL;
@@ -164,6 +170,7 @@ const char* MediaMetadataRetriever::extractMetadata(int keyCode)
sp<IMemory> MediaMetadataRetriever::extractAlbumArt()
{
    LOGV("extractAlbumArt");
    Mutex::Autolock _l(mLock);
    if (mRetriever == 0) {
        LOGE("retriever is not initialized");
        return NULL;