Skip to content
Snippets Groups Projects
Commit 0b11282d authored by Andreas Traczyk's avatar Andreas Traczyk Committed by Sébastien Blin
Browse files

avmodel: hold lock when erasing renderer

Change-Id: If10ad2bf40ce05b0052016123755f4c9dca18097
parent 9a363447
No related branches found
No related tags found
No related merge requests found
......@@ -942,15 +942,12 @@ createRenderer(const QString& id, const QSize& res, const QString& shmPath = {})
void
AVModelPimpl::addRenderer(const QString& id, const QSize& res, const QString& shmPath)
{
// First remove the existing renderer.
renderers_.erase(id);
{
std::lock_guard<std::mutex> lk(renderers_mtx_);
renderers_[id] = createRenderer(id, res, shmPath);
}
// Create a new one and add it.
auto renderer = createRenderer(id, res, shmPath);
std::lock_guard<std::mutex> lk(renderers_mtx_);
auto& r = renderers_[id];
r = std::move(renderer);
renderers_mtx_.unlock();
// Listen and forward id-bound signals upwards.
connect(
......@@ -965,12 +962,14 @@ AVModelPimpl::addRenderer(const QString& id, const QSize& res, const QString& sh
this,
[this, id](const QSize& size) { Q_EMIT linked_.rendererStarted(id, size); },
Qt::DirectConnection);
#ifdef ENABLE_LIBWRAP
connect(
r.get(),
&Renderer::frameBufferRequested,
this,
[this, id](AVFrame* frame) { Q_EMIT linked_.frameBufferRequested(id, frame); },
Qt::DirectConnection);
#endif
connect(
r.get(),
&Renderer::frameUpdated,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment