mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-10-24 12:03:14 +08:00
linux-v4l2: Avoid stopping capture on AVERROR(EAGAIN)
v4l2-decoder: continue sending frame to codec if avcodec_receive_frame() returns AVERROR(EAGAIN)
This commit is contained in:
@@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <obs-module.h>
|
||||
#include <linux/videodev2.h>
|
||||
#include <libavutil/error.h>
|
||||
|
||||
#include "v4l2-decoder.h"
|
||||
|
||||
@@ -86,14 +87,18 @@ void v4l2_destroy_decoder(struct v4l2_decoder *decoder)
|
||||
|
||||
int v4l2_decode_frame(struct obs_source_frame *out, uint8_t *data, size_t length, struct v4l2_decoder *decoder)
|
||||
{
|
||||
int r;
|
||||
decoder->packet->data = data;
|
||||
decoder->packet->size = length;
|
||||
if (avcodec_send_packet(decoder->context, decoder->packet) < 0) {
|
||||
blog(LOG_ERROR, "failed to send frame to codec");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (avcodec_receive_frame(decoder->context, decoder->frame) < 0) {
|
||||
r = avcodec_receive_frame(decoder->context, decoder->frame);
|
||||
if (r == AVERROR(EAGAIN)) {
|
||||
blog(LOG_DEBUG, "failed to receive frame in this state, try to send new frame to codec");
|
||||
return 0;
|
||||
} else if (r < 0) {
|
||||
blog(LOG_ERROR, "failed to receive frame from codec");
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user