buffer_producer: convert Binder error codes to Result values

This commit is contained in:
fincs 2018-08-31 14:00:37 +02:00
parent a62fae427b
commit c8ebe8a3b5
2 changed files with 9 additions and 27 deletions

View File

@ -58,11 +58,7 @@ Result bqRequestBuffer(Binder *b, s32 bufferIdx, BqGraphicBuffer *buf)
memcpy(buf, tmp_ptr, sizeof(BqGraphicBuffer)); memcpy(buf, tmp_ptr, sizeof(BqGraphicBuffer));
} }
int status = parcelReadInt32(&parcel_reply); rc = binderConvertErrorCode(parcelReadInt32(&parcel_reply));
if (status != 0) {
rc = MAKERESULT(Module_Libnx, LibnxError_BufferProducerError);
}
} }
return rc; return rc;
@ -101,9 +97,7 @@ Result bqDequeueBuffer(Binder *b, bool async, u32 width, u32 height, s32 format,
memcpy(fence, tmp_ptr, sizeof(NvMultiFence)); memcpy(fence, tmp_ptr, sizeof(NvMultiFence));
} }
int result = parcelReadInt32(&parcel_reply); rc = binderConvertErrorCode(parcelReadInt32(&parcel_reply));
if (result != 0)
rc = MAKERESULT(Module_Libnx, LibnxError_BufferProducerError);
} }
return rc; return rc;
@ -123,7 +117,7 @@ Result bqDetachBuffer(Binder *b, s32 slot)
rc = parcelTransact(b, DETACH_BUFFER, &parcel, &parcel_reply); rc = parcelTransact(b, DETACH_BUFFER, &parcel, &parcel_reply);
if (R_SUCCEEDED(rc)) { if (R_SUCCEEDED(rc)) {
//TODO: parse reply rc = binderConvertErrorCode(parcelReadInt32(&parcel_reply));
} }
return rc; return rc;
@ -147,9 +141,7 @@ Result bqQueueBuffer(Binder *b, s32 buf, BqQueueBufferInput *input, BqQueueBuffe
if (parcelReadData(&parcel_reply, output, sizeof(*output)) == NULL) if (parcelReadData(&parcel_reply, output, sizeof(*output)) == NULL)
return MAKERESULT(Module_Libnx, LibnxError_BadInput); return MAKERESULT(Module_Libnx, LibnxError_BadInput);
int result = parcelReadInt32(&parcel_reply); rc = binderConvertErrorCode(parcelReadInt32(&parcel_reply));
if (result != 0)
rc = MAKERESULT(Module_Libnx, LibnxError_BufferProducerError);
} }
return rc; return rc;
@ -171,9 +163,7 @@ Result bqQuery(Binder *b, s32 what, s32* value)
if (R_SUCCEEDED(rc)) { if (R_SUCCEEDED(rc)) {
*value = parcelReadInt32(&parcel_reply); *value = parcelReadInt32(&parcel_reply);
int result = parcelReadInt32(&parcel_reply); rc = binderConvertErrorCode(parcelReadInt32(&parcel_reply));
if (result != 0)
rc = MAKERESULT(Module_Libnx, LibnxError_BufferProducerError);
} }
return rc; return rc;
@ -200,9 +190,7 @@ Result bqConnect(Binder *b, s32 api, bool producerControlledByApp, BqQueueBuffer
if (parcelReadData(&parcel_reply, output, sizeof(*output)) == NULL) if (parcelReadData(&parcel_reply, output, sizeof(*output)) == NULL)
return MAKERESULT(Module_Libnx, LibnxError_BadInput); return MAKERESULT(Module_Libnx, LibnxError_BadInput);
int result = parcelReadInt32(&parcel_reply); rc = binderConvertErrorCode(parcelReadInt32(&parcel_reply));
if (result != 0)
rc = MAKERESULT(Module_Libnx, LibnxError_BufferProducerError);
} }
return rc; return rc;
@ -222,7 +210,7 @@ Result bqDisconnect(Binder *b, s32 api)
rc = parcelTransact(b, DISCONNECT, &parcel, &parcel_reply); rc = parcelTransact(b, DISCONNECT, &parcel, &parcel_reply);
if (R_SUCCEEDED(rc)) { if (R_SUCCEEDED(rc)) {
// TODO: parse reply rc = binderConvertErrorCode(parcelReadInt32(&parcel_reply));
} }
return rc; return rc;
@ -248,13 +236,7 @@ Result bqSetPreallocatedBuffer(Binder *b, s32 buf, BqGraphicBuffer *input)
parcelWriteFlattenedObject(&parcel, input, sizeof(BqGraphicBuffer)); parcelWriteFlattenedObject(&parcel, input, sizeof(BqGraphicBuffer));
rc = parcelTransact(b, SET_PREALLOCATED_BUFFER, &parcel, &parcel_reply); rc = parcelTransact(b, SET_PREALLOCATED_BUFFER, &parcel, &parcel_reply);
// Reply parcel has no content
if (R_SUCCEEDED(rc)) {
int result = parcelReadInt32(&parcel_reply);
if (result != 0)
rc = MAKERESULT(Module_Libnx, LibnxError_BufferProducerError);
}
return rc; return rc;
} }

View File

@ -109,7 +109,7 @@ static Result _gfxDequeueBuffer(void) {
do { do {
eventWait(&g_gfxBinderEvent, U64_MAX); eventWait(&g_gfxBinderEvent, U64_MAX);
rc = bqDequeueBuffer(&g_gfxBinderSession, true, g_gfx_framebuf_width, g_gfx_framebuf_height, 0, 0x300, &slot, &fence); rc = bqDequeueBuffer(&g_gfxBinderSession, true, g_gfx_framebuf_width, g_gfx_framebuf_height, 0, 0x300, &slot, &fence);
} while (rc == MAKERESULT(Module_Libnx, LibnxError_BufferProducerError)); // todo: check for error -11 } while (rc == MAKERESULT(Module_LibnxBinder, LibnxBinderError_WouldBlock));
} }
else else
rc = bqDequeueBuffer(&g_gfxBinderSession, false, g_gfx_framebuf_width, g_gfx_framebuf_height, 0, 0x300, &slot, &fence); rc = bqDequeueBuffer(&g_gfxBinderSession, false, g_gfx_framebuf_width, g_gfx_framebuf_height, 0, 0x300, &slot, &fence);