Handle failure of creating MediaPlayer properly
MediaPlayer::setDataSource() doesn't fail with a non-existing file. So
we should check the result of MediaPlayer::prepare() as well.
Note that MediaPlayer::disconnect() is called instead of deleting
MediaPlayer directly because the latter causes crash of CameraService.
MediaPlayer::disconnect() is called even in
CameraService::releaseSound().
Bug: 74376839
Test: tested an app using CameraService
Change-Id: Idf68837a55d14ad47dbbedff0256269bd90f9dfd
diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h
index 86a2b81..a7a9264 100644
--- a/services/camera/libcameraservice/CameraService.h
+++ b/services/camera/libcameraservice/CameraService.h
@@ -736,7 +736,7 @@
std::vector<std::string> mNormalDeviceIds;
// sounds
- MediaPlayer* newMediaPlayer(const char *file);
+ sp<MediaPlayer> newMediaPlayer(const char *file);
Mutex mSoundLock;
sp<MediaPlayer> mSoundPlayer[NUM_SOUNDS];