Bug 125588 - [GStreamer] Use GMutexLocker instead of g_mutex_lock
Summary: [GStreamer] Use GMutexLocker instead of g_mutex_lock
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Brendan Long
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-12-11 11:08 PST by Brendan Long
Modified: 2013-12-14 01:00 PST (History)
8 users (show)

See Also:


Attachments
Patch (9.85 KB, patch)
2013-12-13 12:35 PST, Brendan Long
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brendan Long 2013-12-11 11:08:17 PST
This bit of code would be much simpler with GMutexLocker:

void MediaPlayerPrivateGStreamerBase::paint(GraphicsContext* context, const IntRect& rect)
{
#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
    if (client())
        return;
#endif

    if (context->paintingDisabled() || m_skipPainting)
        return;

    if (!m_player->visible())
        return;

    g_mutex_lock(m_bufferMutex);
    if (!m_buffer) {
        g_mutex_unlock(m_bufferMutex);
        return;
    }

    GRefPtr<GstCaps> caps = currentVideoSinkCaps();
    if (!caps) {
        g_mutex_unlock(m_bufferMutex);
        return;
    }

    RefPtr<ImageGStreamer> gstImage = ImageGStreamer::createImage(m_buffer, caps.get());
    if (!gstImage) {
        g_mutex_unlock(m_bufferMutex);
        return;
    }

    context->drawImage(reinterpret_cast<Image*>(gstImage->image().get()), ColorSpaceSRGB,
        rect, gstImage->rect(), CompositeCopy, ImageOrientationDescription(), false);
    g_mutex_unlock(m_bufferMutex);
}
Comment 1 Brendan Long 2013-12-13 12:35:38 PST
Created attachment 219180 [details]
Patch
Comment 2 Brendan Long 2013-12-13 12:37:19 PST
This just simplifies some code. There are two cases where it's not that much simpler, converting this:

    g_mutex_lock(...);
    something();
    g_mutex_unlock(...);

To this:

    {
        GMutexLocker lock(...);
        something();
    }

I decided to make that change anyway though, for consistency.
Comment 3 WebKit Commit Bot 2013-12-14 01:00:49 PST
Comment on attachment 219180 [details]
Patch

Clearing flags on attachment: 219180

Committed r160593: <http://trac.webkit.org/changeset/160593>
Comment 4 WebKit Commit Bot 2013-12-14 01:00:52 PST
All reviewed patches have been landed.  Closing bug.