Skip to content

Commit 2cf795d

Browse files
committed
linux-v4l2: Avoid stopping capture on AVERROR(EAGAIN)
v4l2-decoder: continue sending frame to codec if avcodec_receive_frame() returns AVERROR(EAGAIN)
1 parent 059fd62 commit 2cf795d

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

frontend/OBSStudioAPI.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,9 @@ bool OBSStudioAPI::obs_frontend_replay_buffer_active()
314314
void *OBSStudioAPI::obs_frontend_add_tools_menu_qaction(const char *name)
315315
{
316316
main->ui->menuTools->setEnabled(true);
317-
return (void *)main->ui->menuTools->addAction(QT_UTF8(name));
317+
QAction *action = main->ui->menuTools->addAction(QT_UTF8(name));
318+
action->setMenuRole(QAction::NoRole);
319+
return static_cast<void *>(action);
318320
}
319321

320322
void OBSStudioAPI::obs_frontend_add_tools_menu_item(const char *name, obs_frontend_cb callback, void *private_data)
@@ -326,6 +328,7 @@ void OBSStudioAPI::obs_frontend_add_tools_menu_item(const char *name, obs_fronte
326328
};
327329

328330
QAction *action = main->ui->menuTools->addAction(QT_UTF8(name));
331+
action->setMenuRole(QAction::NoRole);
329332
QObject::connect(action, &QAction::triggered, func);
330333
}
331334

frontend/widgets/OBSBasic_Docks.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ QAction *OBSBasic::AddDockWidget(QDockWidget *dock)
210210
QAction *action = ui->menuDocks->addAction(dock->windowTitle());
211211
#endif
212212
action->setCheckable(true);
213+
action->setMenuRole(QAction::NoRole);
213214
assignDockToggle(dock, action);
214215
oldExtraDocks.push_back(dock);
215216
oldExtraDockNames.push_back(dock->objectName());

plugins/linux-v4l2/v4l2-decoder.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

1818
#include <obs-module.h>
1919
#include <linux/videodev2.h>
20+
#include <libavutil/error.h>
2021

2122
#include "v4l2-decoder.h"
2223

@@ -86,14 +87,18 @@ void v4l2_destroy_decoder(struct v4l2_decoder *decoder)
8687

8788
int v4l2_decode_frame(struct obs_source_frame *out, uint8_t *data, size_t length, struct v4l2_decoder *decoder)
8889
{
90+
int r;
8991
decoder->packet->data = data;
9092
decoder->packet->size = length;
9193
if (avcodec_send_packet(decoder->context, decoder->packet) < 0) {
9294
blog(LOG_ERROR, "failed to send frame to codec");
9395
return -1;
9496
}
95-
96-
if (avcodec_receive_frame(decoder->context, decoder->frame) < 0) {
97+
r = avcodec_receive_frame(decoder->context, decoder->frame);
98+
if (r == AVERROR(EAGAIN)) {
99+
blog(LOG_DEBUG, "failed to receive frame in this state, try to send new frame to codec");
100+
return 0;
101+
} else if (r < 0) {
97102
blog(LOG_ERROR, "failed to receive frame from codec");
98103
return -1;
99104
}

0 commit comments

Comments
 (0)