am 5a7691f0: am e8543418: Merge change I7c0d20a7 into eclair

Merge commit '5a7691f0e13620322103d61c9f2b1eeb908fd37b' into eclair-mr2-plus-aosp

* commit '5a7691f0e13620322103d61c9f2b1eeb908fd37b':
  Run the metadataretriever at background priority. Bug 2187133.
This commit is contained in:
Dave Sparks
2009-10-28 12:44:10 -07:00
committed by Android Git Automerger
2 changed files with 37 additions and 0 deletions

View File

@@ -21,6 +21,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/resource.h>
#include <dirent.h>
#include <unistd.h>
@@ -39,6 +40,18 @@
#include "MetadataRetrieverClient.h"
#include "StagefrightMetadataRetriever.h"
/* desktop Linux needs a little help with gettid() */
#if defined(HAVE_GETTID) && !defined(HAVE_ANDROID_OS)
#define __KERNEL__
# include <linux/unistd.h>
#ifdef _syscall0
_syscall0(pid_t,gettid)
#else
pid_t gettid() { return syscall(__NR_gettid);}
#endif
#undef __KERNEL__
#endif
namespace android {
extern player_type getPlayerType(const char* url);
@@ -219,6 +232,7 @@ sp<IMemory> MetadataRetrieverClient::captureFrame()
{
LOGV("captureFrame");
Mutex::Autolock lock(mLock);
Priority priority(ANDROID_PRIORITY_BACKGROUND);
mThumbnail.clear();
mThumbnailDealer.clear();
if (mRetriever == NULL) {
@@ -260,6 +274,7 @@ sp<IMemory> MetadataRetrieverClient::extractAlbumArt()
{
LOGV("extractAlbumArt");
Mutex::Autolock lock(mLock);
Priority priority(ANDROID_PRIORITY_BACKGROUND);
mAlbumArt.clear();
mAlbumArtDealer.clear();
if (mRetriever == NULL) {
@@ -301,7 +316,19 @@ const char* MetadataRetrieverClient::extractMetadata(int keyCode)
LOGE("retriever is not initialized");
return NULL;
}
Priority priority(ANDROID_PRIORITY_BACKGROUND);
return mRetriever->extractMetadata(keyCode);
}
MetadataRetrieverClient::Priority::Priority(int newPriority)
{
mOldPriority = getpriority(PRIO_PROCESS, 0);
setpriority(PRIO_PROCESS, 0, newPriority);
}
MetadataRetrieverClient::Priority::~Priority()
{
setpriority(PRIO_PROCESS, 0, mOldPriority);
}
}; // namespace android

View File

@@ -54,6 +54,16 @@ public:
private:
friend class MediaPlayerService;
class Priority
{
public:
Priority(int newPriority);
~Priority();
private:
Priority();
int mOldPriority;
};
explicit MetadataRetrieverClient(pid_t pid);
virtual ~MetadataRetrieverClient();