audio: Check result from oneway calls
As oneway HIDL calls generate methods that return 'Result<void>', the returned value must be checked to avoid triggering an assertion if the result was an error (e.g. due to the client death). Bug: 151900655 Test: N/A Change-Id: I4721240b5959d6f11cb4447b30928bf4c83da058
This commit is contained in:
parent
b7eaa14fe6
commit
2adec4f116
1 changed files with 8 additions and 4 deletions
|
@ -455,20 +455,22 @@ int StreamOut::asyncCallback(stream_callback_event_t event, void*, void* cookie)
|
|||
sp<IStreamOutCallback> callback = self->mCallback;
|
||||
if (callback.get() == nullptr) return 0;
|
||||
ALOGV("asyncCallback() event %d", event);
|
||||
Return<void> result;
|
||||
switch (event) {
|
||||
case STREAM_CBK_EVENT_WRITE_READY:
|
||||
callback->onWriteReady();
|
||||
result = callback->onWriteReady();
|
||||
break;
|
||||
case STREAM_CBK_EVENT_DRAIN_READY:
|
||||
callback->onDrainReady();
|
||||
result = callback->onDrainReady();
|
||||
break;
|
||||
case STREAM_CBK_EVENT_ERROR:
|
||||
callback->onError();
|
||||
result = callback->onError();
|
||||
break;
|
||||
default:
|
||||
ALOGW("asyncCallback() unknown event %d", event);
|
||||
break;
|
||||
}
|
||||
ALOGW_IF(!result.isOk(), "Client callback failed: %s", result.description().c_str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -629,16 +631,18 @@ int StreamOut::asyncEventCallback(stream_event_callback_type_t event, void* para
|
|||
sp<IStreamOutEventCallback> eventCallback = self->mEventCallback;
|
||||
if (eventCallback.get() == nullptr) return 0;
|
||||
ALOGV("%s event %d", __func__, event);
|
||||
Return<void> result;
|
||||
switch (event) {
|
||||
case STREAM_EVENT_CBK_TYPE_CODEC_FORMAT_CHANGED: {
|
||||
hidl_vec<uint8_t> audioMetadata;
|
||||
audioMetadata.setToExternal((uint8_t*)param, strlen((char*)param));
|
||||
eventCallback->onCodecFormatChanged(audioMetadata);
|
||||
result = eventCallback->onCodecFormatChanged(audioMetadata);
|
||||
} break;
|
||||
default:
|
||||
ALOGW("%s unknown event %d", __func__, event);
|
||||
break;
|
||||
}
|
||||
ALOGW_IF(!result.isOk(), "Client callback failed: %s", result.description().c_str());
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue