@@ -614,15 +614,15 @@ int rk_video_snapshot_grab(char index, hal_jpegdata *jpeg)
614614{
615615 int ret ;
616616
617- if (ret = rk_channel_bind (index )) {
618- HAL_DANGER ("rk_venc" , "Binding the encoder channel "
617+ unsigned int count = 1 ;
618+ if (rk_venc .fnStartReceivingEx (index , & count )) {
619+ HAL_DANGER ("rk_venc" , "Requesting one frame "
619620 "%d failed with %#x!\n" , index , ret );
620621 goto abort ;
621622 }
622623
623- unsigned int count = 1 ;
624- if (rk_venc .fnStartReceivingEx (index , & count )) {
625- HAL_DANGER ("rk_venc" , "Requesting one frame "
624+ if (ret = rk_channel_bind (index )) {
625+ HAL_DANGER ("rk_venc" , "Binding the encoder channel "
626626 "%d failed with %#x!\n" , index , ret );
627627 goto abort ;
628628 }
@@ -644,7 +644,7 @@ int rk_video_snapshot_grab(char index, hal_jpegdata *jpeg)
644644
645645 if (FD_ISSET (fd , & readFds )) {
646646 rk_venc_stat stat ;
647- if (rk_venc .fnQuery (index , & stat )) {
647+ /* if (rk_venc.fnQuery(index, &stat)) {
648648 HAL_DANGER("rk_venc", "Querying the encoder channel "
649649 "%d failed with %#x!\n", index, ret);
650650 goto abort;
@@ -653,7 +653,7 @@ int rk_video_snapshot_grab(char index, hal_jpegdata *jpeg)
653653 if (!stat.curPacks) {
654654 HAL_DANGER("rk_venc", "Current frame is empty, skipping it!\n");
655655 goto abort;
656- }
656+ }*/ stat . curPacks = 1 ;
657657
658658 rk_venc_strm strm ;
659659 memset (& strm , 0 , sizeof (strm ));
@@ -667,8 +667,6 @@ int rk_video_snapshot_grab(char index, hal_jpegdata *jpeg)
667667 if (ret = rk_venc .fnGetStream (index , & strm , 40 )) {
668668 HAL_DANGER ("rk_venc" , "Getting the stream on "
669669 "channel %d failed with %#x!\n" , index , ret );
670- free (strm .packet );
671- strm .packet = NULL ;
672670 goto abort ;
673671 }
674672
@@ -689,16 +687,20 @@ int rk_video_snapshot_grab(char index, hal_jpegdata *jpeg)
689687 }
690688 }
691689
692- abort :
693690 rk_venc .fnFreeStream (index , & strm );
691+ abort :
692+ if (strm .packet ) {
693+ free (strm .packet );
694+ strm .packet = NULL ;
695+ }
694696 }
695697
696698 rk_venc .fnFreeDescriptor (index );
697699
698- rk_venc .fnStopReceiving (index );
699-
700700 rk_channel_unbind (index );
701701
702+ rk_venc .fnStopReceiving (index );
703+
702704 return ret ;
703705}
704706
@@ -823,8 +825,10 @@ void *rk_video_thread(void)
823825 "channel %d failed with %#x!\n" , i , ret );
824826 }
825827free :
826- free (stream .packet );
827- stream .packet = NULL ;
828+ if (stream .packet ) {
829+ free (stream .packet );
830+ stream .packet = NULL ;
831+ }
828832 }
829833 }
830834 }
0 commit comments