Merge change I7c0d20a7 into eclair
* changes: Run the metadataretriever at background priority. Bug 2187133.
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/resource.h>
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@@ -38,6 +39,18 @@
|
||||
#include "MidiMetadataRetriever.h"
|
||||
#include "MetadataRetrieverClient.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);
|
||||
@@ -212,6 +225,7 @@ sp<IMemory> MetadataRetrieverClient::captureFrame()
|
||||
{
|
||||
LOGV("captureFrame");
|
||||
Mutex::Autolock lock(mLock);
|
||||
Priority priority(ANDROID_PRIORITY_BACKGROUND);
|
||||
mThumbnail.clear();
|
||||
mThumbnailDealer.clear();
|
||||
if (mRetriever == NULL) {
|
||||
@@ -253,6 +267,7 @@ sp<IMemory> MetadataRetrieverClient::extractAlbumArt()
|
||||
{
|
||||
LOGV("extractAlbumArt");
|
||||
Mutex::Autolock lock(mLock);
|
||||
Priority priority(ANDROID_PRIORITY_BACKGROUND);
|
||||
mAlbumArt.clear();
|
||||
mAlbumArtDealer.clear();
|
||||
if (mRetriever == NULL) {
|
||||
@@ -294,7 +309,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
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user