diff options
author | Gloria Wang <gwang@google.com> | 2009-10-29 19:59:33 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2009-10-29 19:59:33 -0700 |
commit | a3763b85d4d95a0316df9718bb0d132cf458374d (patch) | |
tree | 6a515eca8e034adb6fdd45036cf59692079018a1 /media | |
parent | 894449ac461e69cd40f10e9d3644555357a5ed82 (diff) | |
parent | 9cf962809dc5d26d91fd7e9bbfeb7266867216d1 (diff) | |
download | frameworks_base-a3763b85d4d95a0316df9718bb0d132cf458374d.zip frameworks_base-a3763b85d4d95a0316df9718bb0d132cf458374d.tar.gz frameworks_base-a3763b85d4d95a0316df9718bb0d132cf458374d.tar.bz2 |
am 9cf96280: am 3a814141: Merge change Iee0486e2 into eclair
Merge commit '9cf962809dc5d26d91fd7e9bbfeb7266867216d1' into eclair-mr2-plus-aosp
* commit '9cf962809dc5d26d91fd7e9bbfeb7266867216d1':
Dump media recorder PID in dumpsys media.player, and fix minor bugs.
Diffstat (limited to 'media')
4 files changed, 33 insertions, 3 deletions
diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp index 64267de..de5b542 100644 --- a/media/libmediaplayerservice/MediaPlayerService.cpp +++ b/media/libmediaplayerservice/MediaPlayerService.cpp @@ -225,7 +225,10 @@ MediaPlayerService::~MediaPlayerService() sp<IMediaRecorder> MediaPlayerService::createMediaRecorder(pid_t pid) { #ifndef NO_OPENCORE - sp<MediaRecorderClient> recorder = new MediaRecorderClient(pid); + sp<MediaRecorderClient> recorder = new MediaRecorderClient(this, pid); + wp<MediaRecorderClient> w = recorder; + Mutex::Autolock lock(mLock); + mMediaRecorderClients.add(w); #else sp<MediaRecorderClient> recorder = NULL; #endif @@ -233,6 +236,13 @@ sp<IMediaRecorder> MediaPlayerService::createMediaRecorder(pid_t pid) return recorder; } +void MediaPlayerService::removeMediaRecorderClient(wp<MediaRecorderClient> client) +{ + Mutex::Autolock lock(mLock); + mMediaRecorderClients.remove(client); + LOGV("Delete media recorder client"); +} + sp<IMediaMetadataRetriever> MediaPlayerService::createMetadataRetriever(pid_t pid) { sp<MetadataRetrieverClient> retriever = new MetadataRetrieverClient(pid); @@ -499,6 +509,13 @@ status_t MediaPlayerService::dump(int fd, const Vector<String16>& args) sp<Client> c = mClients[i].promote(); if (c != 0) c->dump(fd, args); } + for (int i = 0, n = mMediaRecorderClients.size(); i < n; ++i) { + result.append(" MediaRecorderClient\n"); + sp<MediaRecorderClient> c = mMediaRecorderClients[i].promote(); + snprintf(buffer, 255, " pid(%d)\n\n", c->mPid); + result.append(buffer); + } + result.append(" Files opened and/or mapped:\n"); snprintf(buffer, SIZE, "/proc/%d/maps", myTid()); FILE *f = fopen(buffer, "r"); diff --git a/media/libmediaplayerservice/MediaPlayerService.h b/media/libmediaplayerservice/MediaPlayerService.h index 931667e..b00f5b7 100644 --- a/media/libmediaplayerservice/MediaPlayerService.h +++ b/media/libmediaplayerservice/MediaPlayerService.h @@ -35,6 +35,7 @@ namespace android { class IMediaRecorder; class IMediaMetadataRetriever; class IOMX; +class MediaRecorderClient; #define CALLBACK_ANTAGONIZER 0 #if CALLBACK_ANTAGONIZER @@ -175,6 +176,7 @@ public: // IMediaPlayerService interface virtual sp<IMediaRecorder> createMediaRecorder(pid_t pid); + void removeMediaRecorderClient(wp<MediaRecorderClient> client); virtual sp<IMediaMetadataRetriever> createMetadataRetriever(pid_t pid); // House keeping for media player clients @@ -280,6 +282,7 @@ private: mutable Mutex mLock; SortedVector< wp<Client> > mClients; + SortedVector< wp<MediaRecorderClient> > mMediaRecorderClients; int32_t mNextConnId; sp<IOMX> mOMX; }; diff --git a/media/libmediaplayerservice/MediaRecorderClient.cpp b/media/libmediaplayerservice/MediaRecorderClient.cpp index e54f20d..95ee3e4 100644 --- a/media/libmediaplayerservice/MediaRecorderClient.cpp +++ b/media/libmediaplayerservice/MediaRecorderClient.cpp @@ -32,7 +32,10 @@ #include <media/PVMediaRecorder.h> #include <utils/String16.h> +#include <media/AudioTrack.h> + #include "MediaRecorderClient.h" +#include "MediaPlayerService.h" namespace android { @@ -80,6 +83,7 @@ status_t MediaRecorderClient::setVideoSource(int vs) Mutex::Autolock lock(mLock); if (mRecorder == NULL) { LOGE("recorder is not initialized"); + return NO_INIT; } return mRecorder->setVideoSource((video_source)vs); } @@ -93,6 +97,7 @@ status_t MediaRecorderClient::setAudioSource(int as) Mutex::Autolock lock(mLock); if (mRecorder == NULL) { LOGE("recorder is not initialized"); + return NO_INIT; } return mRecorder->setAudioSource((audio_source)as); } @@ -271,15 +276,18 @@ status_t MediaRecorderClient::release() if (mRecorder != NULL) { delete mRecorder; mRecorder = NULL; + wp<MediaRecorderClient> client(this); + mMediaPlayerService->removeMediaRecorderClient(client); } return NO_ERROR; } -MediaRecorderClient::MediaRecorderClient(pid_t pid) +MediaRecorderClient::MediaRecorderClient(const sp<MediaPlayerService>& service, pid_t pid) { LOGV("Client constructor"); mPid = pid; mRecorder = new PVMediaRecorder(); + mMediaPlayerService = service; } MediaRecorderClient::~MediaRecorderClient() diff --git a/media/libmediaplayerservice/MediaRecorderClient.h b/media/libmediaplayerservice/MediaRecorderClient.h index 6a1c2d5..6260441 100644 --- a/media/libmediaplayerservice/MediaRecorderClient.h +++ b/media/libmediaplayerservice/MediaRecorderClient.h @@ -24,6 +24,7 @@ namespace android { class PVMediaRecorder; class ISurface; +class MediaPlayerService; class MediaRecorderClient : public BnMediaRecorder { @@ -53,12 +54,13 @@ public: private: friend class MediaPlayerService; // for accessing private constructor - MediaRecorderClient(pid_t pid); + MediaRecorderClient(const sp<MediaPlayerService>& service, pid_t pid); virtual ~MediaRecorderClient(); pid_t mPid; Mutex mLock; PVMediaRecorder *mRecorder; + sp<MediaPlayerService> mMediaPlayerService; }; }; // namespace android |