[Webkit-unassigned] [Bug 150888] [GStreamer] Do not use GThreadSafeMainLoopSource to send notifications to the main thread in MediaPlayerPrivateGStreamer
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Fri Nov 6 00:55:45 PST 2015
https://bugs.webkit.org/show_bug.cgi?id=150888
--- Comment #5 from Zan Dobersek <zan at falconsigh.net> ---
(In reply to comment #4)
> (In reply to comment #3)
> > > Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:615
> > > + if (isMainThread())
> > > + player->notifyPlayerOfVideo();
> > > + else
> > > + player->m_notifier.notify(MainThreadNotification::VideoChanged, [player] { player->notifyPlayerOfVideo(); });
> >
> > This isMainThread() check and the conditional immediate execution could be
> > rolled up into the notifier class. Would save some lines.
> >
> > MainThreadNotifier::notify() would accept a templated functor as the second
> > parameter, invoke it immediately if on the main thread, or wrap it in
> > std::function<> and dispatch it onto the main thread via RunLoop otherwise.
>
> I thought about that, but decided to do it in callers to avoid the function
> creation just to invoke a member method. But I'm not sure if creating the
> function would have any real impact in the end, what do you think?
You wouldn't create a std::function<> object until you know you're not on the main thread and have to use the RunLoop dispatch instead.
template<typename F>
void notify(T notificationType, const F& callbackFunctor)
{
if (!addPendingNotitifation(notificationType))
return;
if (!isMainThread()) {
auto weakThis = m_weakPtrFactory.createWeakPtr();
std::function<void ()> callback(callbackFunctor);
RunLoop::main().dispatch([weakThis, notificationType, callback] {
if (weakThis && weakThis->removePendingNotitifation(notificationType))
callback();
});
} else
callbackFunctor();
}
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20151106/98901974/attachment-0001.html>
More information about the webkit-unassigned
mailing list