Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit af7d8189 authored by John Grossman's avatar John Grossman
Browse files

Enhance Visualizer behavior in the case of mediaserver death.

Bring the Visualizer class into line with the SDK documentation by
returning ERROR_DEAD_OBJECT instead of ERROR_INVALID_OPERATION when
the Visualizer loses its binder connection to the mediaserver because
of a mediaserver restart.

Also add a new callback interface to allow clients to be
asynchronously notified in the case of server death.  Right now, the
interface definition and the registration method are flagged as hidden
pending API council review/approval.

See http://b/issue?id=5717519

 for details.

Change-Id: Ic15856f27ed5a950a583ac11ca81f79bd7e9b1a0
Signed-off-by: default avatarJohn Grossman <johngro@google.com>
parent 4ff14bae
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -202,7 +202,7 @@ bool AudioEffect::getEnabled() const
status_t AudioEffect::setEnabled(bool enabled)
{
    if (mStatus != NO_ERROR) {
        return INVALID_OPERATION;
        return (mStatus == ALREADY_EXISTS) ? INVALID_OPERATION : mStatus;
    }

    status_t status = NO_ERROR;
@@ -231,7 +231,7 @@ status_t AudioEffect::command(uint32_t cmdCode,
{
    if (mStatus != NO_ERROR && mStatus != ALREADY_EXISTS) {
        ALOGV("command() bad status %d", mStatus);
        return INVALID_OPERATION;
        return mStatus;
    }

    if (cmdCode == EFFECT_CMD_ENABLE || cmdCode == EFFECT_CMD_DISABLE) {
@@ -263,7 +263,7 @@ status_t AudioEffect::command(uint32_t cmdCode,
status_t AudioEffect::setParameter(effect_param_t *param)
{
    if (mStatus != NO_ERROR) {
        return INVALID_OPERATION;
        return (mStatus == ALREADY_EXISTS) ? INVALID_OPERATION : mStatus;
    }

    if (param == NULL || param->psize == 0 || param->vsize == 0) {
@@ -281,7 +281,7 @@ status_t AudioEffect::setParameter(effect_param_t *param)
status_t AudioEffect::setParameterDeferred(effect_param_t *param)
{
    if (mStatus != NO_ERROR) {
        return INVALID_OPERATION;
        return (mStatus == ALREADY_EXISTS) ? INVALID_OPERATION : mStatus;
    }

    if (param == NULL || param->psize == 0 || param->vsize == 0) {
@@ -307,7 +307,7 @@ status_t AudioEffect::setParameterDeferred(effect_param_t *param)
status_t AudioEffect::setParameterCommit()
{
    if (mStatus != NO_ERROR) {
        return INVALID_OPERATION;
        return (mStatus == ALREADY_EXISTS) ? INVALID_OPERATION : mStatus;
    }

    Mutex::Autolock _l(mCblk->lock);
@@ -321,7 +321,7 @@ status_t AudioEffect::setParameterCommit()
status_t AudioEffect::getParameter(effect_param_t *param)
{
    if (mStatus != NO_ERROR && mStatus != ALREADY_EXISTS) {
        return INVALID_OPERATION;
        return mStatus;
    }

    if (param == NULL || param->psize == 0 || param->vsize == 0) {
@@ -341,7 +341,7 @@ status_t AudioEffect::getParameter(effect_param_t *param)
void AudioEffect::binderDied()
{
    ALOGW("IEffect died");
    mStatus = NO_INIT;
    mStatus = DEAD_OBJECT;
    if (mCbf != NULL) {
        status_t status = DEAD_OBJECT;
        mCbf(EVENT_ERROR, mUserData, &status);
+9 −2
Original line number Diff line number Diff line
@@ -83,8 +83,15 @@ public:
            size = *pReplySize;
        }
        data.writeInt32(size);
        remote()->transact(COMMAND, data, &reply);
        status_t status = reply.readInt32();

        status_t status = remote()->transact(COMMAND, data, &reply);
        if (status != NO_ERROR) {
            if (pReplySize != NULL)
                *pReplySize = 0;
            return status;
        }

        status = reply.readInt32();
        size = reply.readInt32();
        if (size != 0 && pReplyData != NULL && pReplySize != NULL) {
            reply.read(pReplyData, size);
+1 −1
Original line number Diff line number Diff line
@@ -168,7 +168,7 @@ status_t Visualizer::getWaveForm(uint8_t *waveform)
        uint32_t replySize = mCaptureSize;
        status = command(VISUALIZER_CMD_CAPTURE, 0, NULL, &replySize, waveform);
        ALOGV("getWaveForm() command returned %d", status);
        if (replySize == 0) {
        if ((status == NO_ERROR) && (replySize == 0)) {
            status = NOT_ENOUGH_DATA;
        }
    } else {