Adding clang-tidy and refactoring src/packet/hello.c
This commit is contained in:
parent
c8ea2f847b
commit
97db819b1e
9
.clang-tidy
Normal file
9
.clang-tidy
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
Checks: '-*,readability-identifier-naming'
|
||||||
|
CheckOptions:
|
||||||
|
- { key: readability-identifier-naming.NamespaceCase, value: lower_case }
|
||||||
|
- { key: readability-identifier-naming.ClassCase, value: CamelCase }
|
||||||
|
- { key: readability-identifier-naming.PrivateMemberPrefix, value: _ }
|
||||||
|
- { key: readability-identifier-naming.StructCase, value: CamelCase }
|
||||||
|
- { key: readability-identifier-naming.FunctionCase, value: camelBack }
|
||||||
|
- { key: readability-identifier-naming.VariableCase, value: camelBack }
|
||||||
|
- { key: readability-identifier-naming.GlobalConstantCase, value: UPPER_CASE }
|
@ -45,12 +45,12 @@ msThreadCallbackSetFrame(struct mCoreThread *threadContext) {
|
|||||||
unsigned width, height;
|
unsigned width, height;
|
||||||
unsigned char *rawData = NULL;
|
unsigned char *rawData = NULL;
|
||||||
size_t rawDataLen = 0;
|
size_t rawDataLen = 0;
|
||||||
struct msPacketSendFrame *send_frame = NULL;
|
struct msPacketSendFrame *sendFrame = NULL;
|
||||||
struct msPacket *packet = NULL;
|
struct msPacket *packet = NULL;
|
||||||
struct timespec current_date;
|
struct timespec currentDate;
|
||||||
timespec_get(¤t_date, TIME_UTC);
|
timespec_get(¤tDate, TIME_UTC);
|
||||||
uint64_t nano_current = SEC_TO_NANO(current_date.tv_sec % 1000) + current_date.tv_nsec;
|
uint64_t nanoCurrent = SEC_TO_NANO(currentDate.tv_sec % 1000) + currentDate.tv_nsec;
|
||||||
uint64_t nano_last = SEC_TO_NANO(data->lastFrameDate->tv_sec % 1000) + data->lastFrameDate->tv_nsec + (SEC_TO_NANO(1) / 60);
|
uint64_t nanoLast = SEC_TO_NANO(data->lastFrameDate->tv_sec % 1000) + data->lastFrameDate->tv_nsec + (SEC_TO_NANO(1) / 60);
|
||||||
|
|
||||||
if (!data || !data->coreController) {
|
if (!data || !data->coreController) {
|
||||||
goto return_ms_thread_callback_set_frame;
|
goto return_ms_thread_callback_set_frame;
|
||||||
@ -58,17 +58,17 @@ msThreadCallbackSetFrame(struct mCoreThread *threadContext) {
|
|||||||
stride = data->coreController->stride;
|
stride = data->coreController->stride;
|
||||||
outputBuffer = data->coreController->outputBuffer;
|
outputBuffer = data->coreController->outputBuffer;
|
||||||
|
|
||||||
while (nano_current < nano_last && nano_last != 0 && nano_last - nano_current < SEC_TO_NANO(10)) {
|
while (nanoCurrent < nanoLast && nanoLast != 0 && nanoLast - nanoCurrent < SEC_TO_NANO(10)) {
|
||||||
usleep(500);
|
usleep(500);
|
||||||
timespec_get(¤t_date, TIME_UTC);
|
timespec_get(¤tDate, TIME_UTC);
|
||||||
nano_current = SEC_TO_NANO(current_date.tv_sec % 1000) + current_date.tv_nsec;
|
nanoCurrent = SEC_TO_NANO(currentDate.tv_sec % 1000) + currentDate.tv_nsec;
|
||||||
}
|
}
|
||||||
*data->lastFrameDate = current_date;
|
*data->lastFrameDate = currentDate;
|
||||||
|
|
||||||
data->coreController->threadContext.core->desiredVideoDimensions(data->coreController->threadContext.core, &width, &height);
|
data->coreController->threadContext.core->desiredVideoDimensions(data->coreController->threadContext.core, &width, &height);
|
||||||
|
|
||||||
send_frame = msPacketSendFrameNew(stride, width * height, outputBuffer);
|
sendFrame = msPacketSendFrameNew(stride, width * height, outputBuffer);
|
||||||
rawData = msPacketSendFrameSerialize(send_frame, &rawDataLen);
|
rawData = msPacketSendFrameSerialize(sendFrame, &rawDataLen);
|
||||||
if (!rawData) {
|
if (!rawData) {
|
||||||
goto return_ms_thread_callback_set_frame;
|
goto return_ms_thread_callback_set_frame;
|
||||||
}
|
}
|
||||||
@ -77,8 +77,8 @@ msThreadCallbackSetFrame(struct mCoreThread *threadContext) {
|
|||||||
msPacketSend(packet, data);
|
msPacketSend(packet, data);
|
||||||
|
|
||||||
return_ms_thread_callback_set_frame:
|
return_ms_thread_callback_set_frame:
|
||||||
if (send_frame) {
|
if (sendFrame) {
|
||||||
msPacketSendFrameDestroy(&send_frame);
|
msPacketSendFrameDestroy(&sendFrame);
|
||||||
}
|
}
|
||||||
if (packet) {
|
if (packet) {
|
||||||
msPacketDestroy(&packet);
|
msPacketDestroy(&packet);
|
||||||
@ -119,7 +119,7 @@ msPacketHelloGet(const struct msPacket *packet, int client_fd,
|
|||||||
size_t sizeRom = 0;
|
size_t sizeRom = 0;
|
||||||
size_t sizeSavestate = 0;
|
size_t sizeSavestate = 0;
|
||||||
size_t reads[4] = { 0,0,0,0 };
|
size_t reads[4] = { 0,0,0,0 };
|
||||||
size_t total_read = 0;
|
size_t totalRead = 0;
|
||||||
size_t to_read_size;
|
size_t to_read_size;
|
||||||
|
|
||||||
#define FREAD(target, size, count, fp, n, goto_to) \
|
#define FREAD(target, size, count, fp, n, goto_to) \
|
||||||
@ -145,10 +145,10 @@ msPacketHelloGet(const struct msPacket *packet, int client_fd,
|
|||||||
FREAD(savestate, sizeof *savestate, sizeSavestate, fp, 3, return_get_packet_hello);
|
FREAD(savestate, sizeof *savestate, sizeSavestate, fp, 3, return_get_packet_hello);
|
||||||
|
|
||||||
for (int i = 0; i<4; i++) {
|
for (int i = 0; i<4; i++) {
|
||||||
total_read += reads[i];
|
totalRead += reads[i];
|
||||||
}
|
}
|
||||||
if (total_read != packet->size) {
|
if (totalRead != packet->size) {
|
||||||
fprintf (stderr, "Total read (%lu) != packet->size (%lu)\n", total_read, packet->size);
|
fprintf (stderr, "Total read (%lu) != packet->size (%lu)\n", totalRead, packet->size);
|
||||||
goto return_get_packet_hello;
|
goto return_get_packet_hello;
|
||||||
}
|
}
|
||||||
hello = calloc(1, sizeof *hello);
|
hello = calloc(1, sizeof *hello);
|
||||||
|
Loading…
Reference in New Issue
Block a user