chore: use log_error in native library

This commit is contained in:
Siyuan Miao 2025-09-25 08:39:29 +00:00 committed by Siyuan
parent efaab7369b
commit 2e939c918f
2 changed files with 20 additions and 20 deletions

View File

@ -36,7 +36,7 @@ int get_edid(uint8_t *edid, size_t max_size)
fd = open(V4L_SUBDEV, O_RDWR);
if (fd < 0)
{
perror("Failed to open device");
log_error("Failed to open device");
return -1;
}
@ -48,7 +48,7 @@ int get_edid(uint8_t *edid, size_t max_size)
if (ioctl(fd, VIDIOC_G_EDID, &v4l2_edid) < 0)
{
perror("Failed to get EDID");
log_error("Failed to get EDID");
close(fd);
return -1;
}
@ -90,7 +90,7 @@ int set_edid(uint8_t *edid, size_t size)
fd = open(V4L_SUBDEV, O_RDWR);
if (fd < 0)
{
perror("Failed to open device");
log_error("Failed to open device");
return -1;
}
@ -104,7 +104,7 @@ int set_edid(uint8_t *edid, size_t size)
if (ioctl(fd, VIDIOC_S_EDID, &v4l2_edid) < 0)
{
perror("Failed to set EDID");
log_error("Failed to set EDID");
close(fd);
return -1;
}
@ -123,13 +123,13 @@ const char *videoc_log_status()
fd = open(V4L_SUBDEV, O_RDWR);
if (fd < 0)
{
perror("Failed to open device");
log_error("Failed to open device");
return NULL;
}
if (ioctl(fd, VIDIOC_LOG_STATUS) == -1)
{
perror("VIDIOC_LOG_STATUS failed");
log_error("VIDIOC_LOG_STATUS failed");
close(fd);
return NULL;
}
@ -166,7 +166,7 @@ const char *videoc_log_status()
buffer = strdup(p);
if (buffer == NULL)
{
perror("Failed to allocate memory for status");
log_error("Failed to allocate memory for status");
return NULL;
}
return buffer;

View File

@ -268,14 +268,14 @@ static void *venc_read_stream(void *arg)
stFrame.pstPack = malloc(sizeof(VENC_PACK_S));
while (venc_running)
{
// printf("RK_MPI_VENC_GetStream\n");
log_trace("RK_MPI_VENC_GetStream\n");
s32Ret = RK_MPI_VENC_GetStream(VENC_CHANNEL, &stFrame, 200); // blocks max 200ms
if (s32Ret == RK_SUCCESS)
{
RK_U64 nowUs = get_us();
// printf("chn:0, loopCount:%d enc->seq:%d wd:%d pts=%llu delay=%lldus\n",
// loopCount, stFrame.u32Seq, stFrame.pstPack->u32Len,
// stFrame.pstPack->u64PTS, nowUs - stFrame.pstPack->u64PTS);
log_trace("chn:0, loopCount:%d enc->seq:%d wd:%d pts=%llu delay=%lldus\n",
loopCount, stFrame.u32Seq, stFrame.pstPack->u32Len,
stFrame.pstPack->u64PTS, nowUs - stFrame.pstPack->u64PTS);
pData = RK_MPI_MB_Handle2VirAddr(stFrame.pstPack->pMbBlk);
video_send_frame(pData, (ssize_t)stFrame.pstPack->u32Len);
s32Ret = RK_MPI_VENC_ReleaseStream(VENC_CHANNEL, &stFrame);
@ -348,7 +348,7 @@ void *run_video_stream(void *arg)
if (ioctl(video_dev_fd, VIDIOC_S_FMT, &fmt) < 0)
{
perror("Set format fail");
log_error("Set format fail");
usleep(100000); // Sleep for 100 milliseconds
close(video_dev_fd);
continue;
@ -363,7 +363,7 @@ void *run_video_stream(void *arg)
if (ioctl(video_dev_fd, VIDIOC_REQBUFS, &req) < 0)
{
perror("VIDIOC_REQBUFS failed");
log_error("VIDIOC_REQBUFS failed");
return errno;
}
log_info("VIDIOC_REQBUFS successful");
@ -385,7 +385,7 @@ void *run_video_stream(void *arg)
if (-1 == ioctl(video_dev_fd, VIDIOC_QUERYBUF, &buf))
{
perror("VIDIOC_QUERYBUF failed");
log_error("VIDIOC_QUERYBUF failed");
req.count = i;
return errno;
}
@ -425,7 +425,7 @@ void *run_video_stream(void *arg)
buf.m.planes = &buffers[i].plane_buffer;
if (ioctl(video_dev_fd, VIDIOC_QBUF, &buf) < 0)
{
perror("VIDIOC_QBUF failed");
log_error("VIDIOC_QBUF failed");
return errno;
}
log_info("VIDIOC_QBUF successful for buffer %d\n", i);
@ -433,7 +433,7 @@ void *run_video_stream(void *arg)
if (ioctl(video_dev_fd, VIDIOC_STREAMON, &type) < 0)
{
perror("VIDIOC_STREAMON failed");
log_error("VIDIOC_STREAMON failed");
goto cleanup;
}
@ -486,7 +486,7 @@ void *run_video_stream(void *arg)
log_error("VIDIOC_DQBUF failed");
break;
}
// printf("got frame, bytesused = %d\n", tmp_plane.bytesused);
log_trace("got frame, bytesused = %d\n", tmp_plane.bytesused);
memset(&stFrame, 0, sizeof(VIDEO_FRAME_INFO_S));
MB_BLK blk = RK_NULL;
blk = RK_MPI_MMZ_Fd2Handle(tmp_plane.m.fd);
@ -509,9 +509,9 @@ void *run_video_stream(void *arg)
// if (pData) {
// size_t frameSize = tmp_plane.bytesused; // Use the actual size reported by the driver
// write_buffer_to_file(pData, frameSize, "/userdata/banana.raw");
// printf("Frame 100 written to /userdata/banana.raw\n");
// log_trace("Frame 100 written to /userdata/banana.raw\n");
// } else {
// printf("Failed to get virtual address for frame 100\n");
// log_trace("Failed to get virtual address for frame 100\n");
// }
// }
retry_send_frame:
@ -604,7 +604,7 @@ void video_start_streaming()
pthread_mutex_lock(&streaming_mutex);
if (streaming_thread != NULL)
{
log_info("video streaming already started");
log_warn("video streaming already started");
pthread_mutex_unlock(&streaming_mutex);
return;
}