/*
* Reconfigure the video interface and restart streaming if it was enabled
* before suspend.
*
* If an error occurs, disable the video queue. This will wake all pending
* buffers, making sure userspace applications are notified of the problem
* instead of waiting forever.
*/
int uvc_video_resume(struct uvc_streaming *stream)
{
int ret;
stream->frozen = 0;
ret = uvc_commit_video(stream, &stream->ctrl);
if (ret < 0) {
uvc_queue_enable(&stream->queue, 0);
return ret;
}
if (!uvc_queue_streaming(&stream->queue))
return 0;
ret = uvc_init_video(stream, GFP_NOIO);
if (ret < 0)
uvc_queue_enable(&stream->queue, 0);
return ret;
}
Y ahora voy a comentar el código para hacerlo más legible:
/**
* uvc_video_resume - Reconfigure the video interface and restart streaming if
* it was enabled before suspend.
* @stream: the stream that will be resumed
*
* If an error occurs, disable the video queue. This will wake all pending
* buffers, making sure userspace applications are notified of the problem
* instead of waiting forever.
*/
int uvc_video_resume(struct uvc_streaming *stream)
{
int ret;
// It could be interesting to compare if it was frozen before with a
// if (stream->frozen == 1)
// return "?";
stream->frozen = 0; // stream knows if it's frozen
// uvc_commit_video will overwrite controls of our stream
ret = uvc_commit_video(stream, &stream->ctrl);
if (ret < 0) {
// It will cancel the queue, put it in a IDLE state and delete
// the streaming label from queue flag
uvc_queue_enable(&stream->queue, 0);
return ret;
}
// if queue is not streaming
if (!uvc_queue_streaming(&stream->queue))
return 0;
// if queue is streaming we have to init video
// payload can be put in a packet?
ret = uvc_init_video(stream, GFP_NOIO);
if (ret < 0)
// We need to enable the queue of @stream
uvc_queue_enable(&stream->queue, 0);
return ret;
}
Además para comprender bien la continuación de la captura de vídeo hay que estudiar cómo funciona las colas (que he tenido que comentar parte de su código para entenderlo completamente), pero eso ya es un poco más difícil de entender. En otro artículo lo comentaré.
No hay comentarios:
Publicar un comentario