OSDN Git Service

Player Driver and Author Driver crash fix, if InitializeThread fails
authorSahil Sachdeva <sahils@google.com>
Fri, 22 May 2009 22:16:04 +0000 (15:16 -0700)
committerSahil Sachdeva <sahils@google.com>
Fri, 22 May 2009 22:16:04 +0000 (15:16 -0700)
android/author/authordriver.cpp
android/playerdriver.cpp

index fd3c357..71835d6 100644 (file)
@@ -151,6 +151,9 @@ author_command *AuthorDriver::dequeueCommand()
 
 status_t AuthorDriver::enqueueCommand(author_command *ac, media_completion_f comp, void *cookie)
 {
+    if (mAuthor == NULL) {
+        return NO_INIT;
+    }
     // If the user didn't specify a completion callback, we
     // are running in synchronous mode.
     if (comp == NULL) {
index b817bb0..64ba67c 100644 (file)
@@ -390,7 +390,8 @@ PlayerCommand* PlayerDriver::dequeueCommand()
 status_t PlayerDriver::enqueueCommand(PlayerCommand* command)
 {
     if (mPlayer == NULL) {
-        delete command;
+        // Only commands which can come in this use-case is PLAYER_SETUP and PLAYER_QUIT
+        // The calling function should take responsibility to delete the command and cleanup
         return NO_INIT;
     }
 
@@ -1330,7 +1331,11 @@ PVPlayer::PVPlayer()
     LOGV("construct PlayerDriver");
     mPlayerDriver = new PlayerDriver(this);
     LOGV("send PLAYER_SETUP");
-    mInit = mPlayerDriver->enqueueCommand(new PlayerSetup(0,0));
+    PlayerSetup* setup = new PlayerSetup(0,0);
+    mInit = mPlayerDriver->enqueueCommand(setup);
+    if (mInit == NO_INIT) {
+        delete setup;
+    }
 }
 
 status_t PVPlayer::initCheck()