Changeset 201432 in webkit


Ignore:
Timestamp:
May 26, 2016, 2:57:58 PM (9 years ago)
Author:
jer.noble@apple.com
Message:

Use std::atomic<> rather than OSAtomicIncrement in CARingBuffer.cpp
https://bugs.webkit.org/show_bug.cgi?id=158129

Reviewed by Eric Carlson.

std::atomic is a more portable atomic primitive than OSAtomicIncrement.

  • platform/audio/mac/CARingBuffer.cpp:

(WebCore::CARingBuffer::setCurrentFrameBounds):
(WebCore::CARingBuffer::getCurrentFrameBounds):
(WebCore::CARingBuffer::currentStartFrame):
(WebCore::CARingBuffer::currentEndFrame):

  • platform/audio/mac/CARingBuffer.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r201429 r201432  
     12016-05-26  Jer Noble  <jer.noble@apple.com>
     2
     3        Use std::atomic<> rather than OSAtomicIncrement in CARingBuffer.cpp
     4        https://bugs.webkit.org/show_bug.cgi?id=158129
     5
     6        Reviewed by Eric Carlson.
     7
     8        std::atomic is a more portable atomic primitive than OSAtomicIncrement.
     9
     10        * platform/audio/mac/CARingBuffer.cpp:
     11        (WebCore::CARingBuffer::setCurrentFrameBounds):
     12        (WebCore::CARingBuffer::getCurrentFrameBounds):
     13        (WebCore::CARingBuffer::currentStartFrame):
     14        (WebCore::CARingBuffer::currentEndFrame):
     15        * platform/audio/mac/CARingBuffer.h:
     16
    1172016-05-26  Ryan Haddad  <ryanhaddad@apple.com>
    218
  • trunk/Source/WebCore/platform/audio/mac/CARingBuffer.cpp

    r188169 r201432  
    3030
    3131#include <CoreAudio/CoreAudioTypes.h>
    32 #include <libkern/OSAtomic.h>
    3332#include <wtf/MathExtras.h>
    3433
     
    202201{
    203202    LockHolder locker(m_currentFrameBoundsLock);
    204     uint32_t nextPtr = m_timeBoundsQueuePtr + 1;
     203    uint32_t nextPtr = m_timeBoundsQueuePtr.load() + 1;
    205204    uint32_t index = nextPtr & kGeneralRingTimeBoundsQueueMask;
    206205
     
    208207    m_timeBoundsQueue[index].m_endFrame = endTime;
    209208    m_timeBoundsQueue[index].m_updateCounter = nextPtr;
    210     OSAtomicIncrement32Barrier(static_cast<int32_t*>(&m_timeBoundsQueuePtr));
     209    m_timeBoundsQueuePtr++;
    211210}
    212211
     
    214213{
    215214    LockHolder locker(m_currentFrameBoundsLock);
    216     uint32_t curPtr = m_timeBoundsQueuePtr;
     215    uint32_t curPtr = m_timeBoundsQueuePtr.load();
    217216    uint32_t index = curPtr & kGeneralRingTimeBoundsQueueMask;
    218217    CARingBuffer::TimeBounds& bounds = m_timeBoundsQueue[index];
     
    241240uint64_t CARingBuffer::currentStartFrame() const
    242241{
    243     uint32_t index = m_timeBoundsQueuePtr & kGeneralRingTimeBoundsQueueMask;
     242    uint32_t index = m_timeBoundsQueuePtr.load() & kGeneralRingTimeBoundsQueueMask;
    244243    return m_timeBoundsQueue[index].m_startFrame;
    245244}
     
    247246uint64_t CARingBuffer::currentEndFrame() const
    248247{
    249     uint32_t index = m_timeBoundsQueuePtr & kGeneralRingTimeBoundsQueueMask;
     248    uint32_t index = m_timeBoundsQueuePtr.load() & kGeneralRingTimeBoundsQueueMask;
    250249    return m_timeBoundsQueue[index].m_endFrame;
    251250}
  • trunk/Source/WebCore/platform/audio/mac/CARingBuffer.h

    r188169 r201432  
    8686    Vector<TimeBounds> m_timeBoundsQueue;
    8787    Lock m_currentFrameBoundsLock;
    88     int32_t m_timeBoundsQueuePtr;
     88    std::atomic<int32_t> m_timeBoundsQueuePtr;
    8989};
    9090
Note: See TracChangeset for help on using the changeset viewer.