void MediaResourceManagerService::binderDied(const wp<IBinder>& who)
{
  if (who != NULL) {
    sp<IBinder> binder = who.promote();
    if (binder != NULL) {
      cancelClientLocked(binder);
    }
  }
}
status_t MediaResourceManagerService::cancelClient(const sp<IMediaResourceManagerClient>& client)
{
  {
    Mutex::Autolock autoLock(mLock);
    sp<IBinder> binder = client->asBinder();
    cancelClientLocked(binder);
  }

  sp<AMessage> notify =
            new AMessage(kNotifyRequest, mReflector->id());
  // Post AMessage to MediaResourceManagerService via ALooper.
  notify->post();

  return NO_ERROR;
}
status_t MediaResourceManagerService::cancelClient(const sp<IMediaResourceManagerClient>& client,
                                                   int resourceType)
{
  Mutex::Autolock autoLock(mLock);

  sp<IBinder> binder = client->asBinder();
  cancelClientLocked(binder, static_cast<ResourceType>(resourceType));

  sp<AMessage> notify = new AMessage(kNotifyRequest, mReflector->id());
  notify->setInt32(kMsgKeyResourceType, resourceType);
  // Next!
  // Note: since we held the lock while releasing and then posting, if there is
  // a queue, no willWait==false entries can jump into the queue thinking they'll
  // get the resource.
  notify->post();

  return NO_ERROR;
}