@@ -54,6 +54,7 @@ static inline int app_setup_display(const struct device *const display_dev, cons
5454 }
5555 break ;
5656 default :
57+ LOG_ERR ("Display pixel format not supported by this sample" );
5758 return - ENOTSUP ;
5859 }
5960 if (ret < 0 ) {
@@ -240,7 +241,7 @@ static int app_setup_video_frmival(const struct device *const video_dev,
240241 } else if (ret < 0 ) {
241242 LOG_ERR ("Error while getting the frame interval" );
242243 return ret ;
243- } else {
244+ } else if ( ret == 0 ) {
244245 LOG_INF ("- Default frame rate : %f fps" ,
245246 1.0 * frmival .denominator / frmival .numerator );
246247 }
@@ -357,48 +358,47 @@ int main(void)
357358
358359 ret = app_query_video_info (video_dev , & caps , & fmt );
359360 if (ret < 0 ) {
360- return 0 ;
361+ goto err ;
361362 }
362363
363364 ret = app_setup_video_selection (video_dev , & fmt );
364365 if (ret < 0 ) {
365- return 0 ;
366+ goto err ;
366367 }
367368
368369 ret = app_setup_video_format (video_dev , & fmt );
369370 if (ret < 0 ) {
370- return 0 ;
371+ goto err ;
371372 }
372373
373374 ret = app_setup_video_frmival (video_dev , & fmt );
374375 if (ret < 0 ) {
375- return 0 ;
376+ goto err ;
376377 }
377378
378379 ret = app_setup_video_controls (video_dev );
379380 if (ret < 0 ) {
380- return 0 ;
381+ goto err ;
381382 }
382383
383384#if DT_HAS_CHOSEN (zephyr_display )
384385 const struct device * const display_dev = DEVICE_DT_GET (DT_CHOSEN (zephyr_display ));
385386
386387 ret = app_setup_display (display_dev , fmt .pixelformat );
387388 if (ret < 0 ) {
388- LOG_ERR ("Unable to set up display" );
389- return 0 ;
389+ goto err ;
390390 }
391391#endif
392392
393393 ret = app_setup_video_buffers (video_dev , & caps , & fmt );
394394 if (ret < 0 ) {
395- return 0 ;
395+ goto err ;
396396 }
397397
398398 ret = video_stream_start (video_dev , VIDEO_BUF_TYPE_OUTPUT );
399399 if (ret < 0 ) {
400400 LOG_ERR ("Unable to start capture (interface)" );
401- return 0 ;
401+ goto err ;
402402 }
403403
404404 LOG_INF ("Capture started" );
@@ -408,7 +408,7 @@ int main(void)
408408 ret = video_dequeue (video_dev , & vbuf , K_FOREVER );
409409 if (ret < 0 ) {
410410 LOG_ERR ("Unable to dequeue video buf" );
411- return 0 ;
411+ goto err ;
412412 }
413413
414414 LOG_INF ("Got frame %u! size: %u; timestamp %u ms" ,
@@ -424,7 +424,11 @@ int main(void)
424424 ret = video_enqueue (video_dev , vbuf );
425425 if (ret < 0 ) {
426426 LOG_ERR ("Unable to requeue video buf" );
427- return 0 ;
427+ goto err ;
428428 }
429429 }
430+
431+ err :
432+ LOG_ERR ("Aborting sample" );
433+ return 0 ;
430434}
0 commit comments