Make a separate MediaPlayer2Base::NotifyCallback
This avoids the collision with notify_callback_f.
Also, this CL should fix the potential use-after-free in notify().
Test: Builds properly
Bug: 70546581
Change-Id: Ia4919522d00c94591d6f14a27cb6465a8c4efaeb
diff --git a/media/libmedia/MediaPlayer2Factory.cpp b/media/libmedia/MediaPlayer2Factory.cpp
index ca7b96f..d6aab70 100644
--- a/media/libmedia/MediaPlayer2Factory.cpp
+++ b/media/libmedia/MediaPlayer2Factory.cpp
@@ -126,8 +126,8 @@
sp<MediaPlayer2Base> MediaPlayer2Factory::createPlayer(
player2_type playerType,
- void* cookie,
- notify_callback_f notifyFunc,
+ const wp<MediaPlayer2Engine> &client,
+ MediaPlayer2Base::NotifyCallback notifyFunc,
pid_t pid) {
sp<MediaPlayer2Base> p;
IFactory* factory;
@@ -152,7 +152,7 @@
init_result = p->initCheck();
if (init_result == NO_ERROR) {
- p->setNotifyCallback(cookie, notifyFunc);
+ p->setNotifyCallback(client, notifyFunc);
} else {
ALOGE("Failed to create player object of type %d, initCheck failed"
" (res = %d)", playerType, init_result);