gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] [SCM] Gnash branch, master, updated. release_0_8_9_final-


From: Bastiaan Jacques
Subject: [Gnash-commit] [SCM] Gnash branch, master, updated. release_0_8_9_final-2054-g869f2fa
Date: Thu, 22 May 2014 22:30:48 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".

The branch, master has been updated
       via  869f2fa5be2720c9687190aa3ccc3d7fd9e1038f (commit)
      from  0ac00036d34208b0c05fbc595c5298fd43d13b41 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=869f2fa5be2720c9687190aa3ccc3d7fd9e1038f


commit 869f2fa5be2720c9687190aa3ccc3d7fd9e1038f
Author: Bastiaan Jacques <address@hidden>
Date:   Fri May 23 00:26:13 2014 +0200

    Use std::atomic to store integer and boolean types that are shared
    across threads. This obviates the need for mutex locks.

diff --git a/libcore/MovieLoader.cpp b/libcore/MovieLoader.cpp
index 2d4d2db..dbe51e3 100644
--- a/libcore/MovieLoader.cpp
+++ b/libcore/MovieLoader.cpp
@@ -64,7 +64,7 @@ MovieLoader::processRequests()
     while (1) {
 
         // check for shutdown/cancel request
-        if (killed()) {
+        if (_killed.load() == true) {
 #ifdef GNASH_DEBUG_LOADMOVIE_REQUESTS_PROCESSING
             log_debug("Loader thread killed");
 #endif
@@ -166,8 +166,6 @@ MovieLoader::clear()
         log_debug("clear: lock on kill: trying");
 #endif
 
-        std::unique_lock<std::mutex> lock(_killMutex);
-
 #ifdef GNASH_DEBUG_LOCKING
         log_debug("clear: lock on kill: obtained");
 #endif
@@ -178,8 +176,6 @@ MovieLoader::clear()
         log_debug("clear: lock on kill: release for kill");
 #endif
 
-        lock.unlock();
-
         log_debug("waking up loader thread");
 
         _wakeup.notify_all(); // in case it was sleeping
@@ -395,15 +391,6 @@ MovieLoader::processCompletedRequests()
     }
 }
 
-// private
-// runs in loader thread
-bool
-MovieLoader::killed()
-{
-    std::lock_guard<std::mutex> lock(_killMutex);
-    return _killed;
-}
-
 // public
 // runs in main thread
 void
diff --git a/libcore/MovieLoader.h b/libcore/MovieLoader.h
index d134a46..deeec50 100644
--- a/libcore/MovieLoader.h
+++ b/libcore/MovieLoader.h
@@ -19,12 +19,14 @@
 #ifndef GNASH_MOVIE_LOADER_H
 #define GNASH_MOVIE_LOADER_H
 
-#include <boost/intrusive_ptr.hpp>
+#include <atomic>
+#include <condition_variable>
 #include <string>
 #include <thread>
-#include <boost/ptr_container/ptr_list.hpp>
+
+#include <boost/intrusive_ptr.hpp>
 #include <boost/noncopyable.hpp>
-#include <condition_variable>
+#include <boost/ptr_container/ptr_list.hpp>
 
 #include "URL.h"
 #include "MovieClip.h" 
@@ -192,11 +194,7 @@ private:
     bool processCompletedRequest(const Request& r);
 
     /// Was thread kill requested ?
-    bool killed();
-
-    bool _killed;
-
-    std::mutex _killMutex;
+    std::atomic<bool> _killed;
 
     std::condition_variable _wakeup;
 
diff --git a/libcore/asobj/NetStream_as.cpp b/libcore/asobj/NetStream_as.cpp
index db3f2e1..d7e02a9 100644
--- a/libcore/asobj/NetStream_as.cpp
+++ b/libcore/asobj/NetStream_as.cpp
@@ -160,12 +160,9 @@ NetStream_as::processStatusNotifications()
     // TODO: check for System.onStatus too ! use a private
     // getStatusHandler() method for this.
     // Copy it to prevent threads changing it.
-    StatusCode code = invalidStatus;
+    StatusCode code = static_cast<StatusCode>(_statusCode.load());
 
-    {
-        std::lock_guard<std::mutex> lock(_statusMutex);
-        std::swap(code, _statusCode);
-    }
+    setStatus(invalidStatus);
 
     // Nothing to do if no more valid notifications.
     if (code == invalidStatus) return; 
@@ -180,7 +177,6 @@ void
 NetStream_as::setStatus(StatusCode status)
 {
     // Get a lock to avoid messing with statuses while processing them
-    std::lock_guard<std::mutex> lock(_statusMutex);
     _statusCode = status;
 }
 
@@ -1435,13 +1431,11 @@ NetStream_as::bytesTotal ()
 NetStream_as::DecodingState
 NetStream_as::decodingStatus(DecodingState newstate)
 {
-    std::lock_guard<std::mutex> lock(_state_mutex);
-
     if (newstate != DEC_NONE) {
         _decoding_state = newstate;
     }
 
-    return _decoding_state;
+    return static_cast<DecodingState>(_decoding_state.load());
 }
 
 //------- BufferedAudioStreamer (move in his own file)
diff --git a/libcore/asobj/NetStream_as.h b/libcore/asobj/NetStream_as.h
index 46b671a..4024e76 100644
--- a/libcore/asobj/NetStream_as.h
+++ b/libcore/asobj/NetStream_as.h
@@ -25,12 +25,14 @@
 #define __STDC_CONSTANT_MACROS
 #endif
 
-#include <boost/intrusive_ptr.hpp>
+#include <atomic>
 #include <string>
-#include <boost/ptr_container/ptr_deque.hpp>
 #include <memory>
 #include <mutex>
 
+#include <boost/intrusive_ptr.hpp>
+#include <boost/ptr_container/ptr_deque.hpp>
+
 #include "PlayHead.h" // for composition
 #include "Relay.h" // for ActiveRelay inheritance
 #include <memory>
@@ -526,12 +528,9 @@ private:
     /// The DisplayObject to invalidate on video updates
     DisplayObject* _invalidatedVideoCharacter;
 
-    DecodingState _decoding_state;
+    /// Stores DecodingState
+    std::atomic<int> _decoding_state;
 
-    // Mutex protecting _playback_state and _decoding_state
-    // (not sure a single one is appropriate)
-    std::mutex _state_mutex;
-    
     /// Video decoder
     std::unique_ptr<media::VideoDecoder> _videoDecoder;
 
@@ -567,11 +566,9 @@ private:
     BufferedAudioStreamer _audioStreamer;
 
     /// List of status messages to be processed
-    StatusCode _statusCode;
-
-    /// Mutex protecting _statusQueue
-    std::mutex _statusMutex;
-
+    //
+    /// Stores StatusCode
+    std::atomic<int> _statusCode;
 };
 
 void netstream_class_init(as_object& global, const ObjectURI& uri);
diff --git a/libcore/asobj/Sound_as.cpp b/libcore/asobj/Sound_as.cpp
index ec61955..4a6d11c 100644
--- a/libcore/asobj/Sound_as.cpp
+++ b/libcore/asobj/Sound_as.cpp
@@ -24,7 +24,6 @@
 #include "Sound_as.h"
 
 #include <string>
-#include <mutex>
 #include <cstdint>
 #include <boost/optional.hpp>
 
@@ -237,11 +236,9 @@ private:
     /// Probe audio
     void probeAudio();
 
-    bool _soundCompleted;
+    std::atomic<bool> _soundCompleted;
 
-    std::mutex _soundCompletedMutex;
-
-    /// Thread-safe setter for _soundCompleted
+    /// Setter for _soundCompleted
     void markSoundCompleted(bool completed);
 
     bool _soundLoaded;
@@ -356,7 +353,7 @@ Sound_as::probeAudio()
     if ( ! externalSound ) {
         // Only probe for sound complete
         assert(_soundHandler);
-        assert(!_soundCompleted);
+        assert(!_soundCompleted.load());
         if (!_soundHandler->isSoundPlaying(soundId)) {
             stopProbeTimer();
             // dispatch onSoundComplete 
@@ -397,8 +394,7 @@ Sound_as::probeAudio()
         log_debug("Probing audio for end");
 #endif
 
-        std::lock_guard<std::mutex> lock(_soundCompletedMutex);
-        if (_soundCompleted) {
+        if (_soundCompleted.load()) {
             // when _soundCompleted is true we're NOT attached !
             // MediaParser may be still needed,
             // if this is a non-streaming sound
@@ -459,7 +455,6 @@ Sound_as::markReachableResources() const
 void
 Sound_as::markSoundCompleted(bool completed)
 {
-    std::lock_guard<std::mutex> lock(_soundCompletedMutex);
     _soundCompleted=completed;
 }
 
diff --git a/libcore/parser/SWFMovieDefinition.cpp 
b/libcore/parser/SWFMovieDefinition.cpp
index 602d209..23cdca8 100644
--- a/libcore/parser/SWFMovieDefinition.cpp
+++ b/libcore/parser/SWFMovieDefinition.cpp
@@ -366,20 +366,20 @@ SWFMovieDefinition::completeLoad()
 bool
 SWFMovieDefinition::ensure_frame_loaded(size_t framenum) const
 {
-    std::unique_lock<std::mutex> lock(_frames_loaded_mutex);
-
 #ifndef LOAD_MOVIES_IN_A_SEPARATE_THREAD
-    return (framenum <= _frames_loaded);
+    return (framenum <= _frames_loaded.load());
 #endif
 
-    if ( framenum <= _frames_loaded ) return true;
+    if ( framenum <= _frames_loaded.load() ) return true;
 
     _waiting_for_frame = framenum;
+    std::mutex m;
+    std::unique_lock<std::mutex> lock(m);
 
     // TODO: return false on timeout
     _frame_reached_condition.wait(lock);
 
-    return ( framenum <= _frames_loaded );
+    return ( framenum <= _frames_loaded.load() );
 }
 
 Movie*
@@ -499,7 +499,6 @@ SWFMovieDefinition::read_all_swf()
                 "SHOWFRAME tags found in stream. Pretending we loaded "
                 "all advertised frames"), m_frame_count, floaded);
         );
-        std::lock_guard<std::mutex> lock(_frames_loaded_mutex);
         _frames_loaded = m_frame_count;
         // Notify any thread waiting on frame reached condition
         _frame_reached_condition.notify_all();
@@ -509,35 +508,32 @@ SWFMovieDefinition::read_all_swf()
 size_t
 SWFMovieDefinition::get_loading_frame() const
 {
-    std::lock_guard<std::mutex> lock(_frames_loaded_mutex);
-    return _frames_loaded;
+    return _frames_loaded.load();
 }
 
 void
 SWFMovieDefinition::incrementLoadedFrames()
 {
-    std::lock_guard<std::mutex> lock(_frames_loaded_mutex);
-
     ++_frames_loaded;
 
-    if ( _frames_loaded > m_frame_count )
+    if ( _frames_loaded.load() > m_frame_count )
     {
         IF_VERBOSE_MALFORMED_SWF(
             log_swferror(_("number of SHOWFRAME tags "
                 "in SWF stream '%s' (%d) exceeds "
                 "the advertised number in header (%d)."),
-                get_url(), _frames_loaded,
+                get_url(), _frames_loaded.load(),
                 m_frame_count);
         )
     }
 
 #ifdef DEBUG_FRAMES_LOAD
-    log_debug("Loaded frame %u/%u", _frames_loaded, m_frame_count);
+    log_debug("Loaded frame %u/%u", _frames_loaded.load(), m_frame_count);
 #endif
 
     // signal load of frame if anyone requested it
     // FIXME: _waiting_for_frame needs mutex ?
-    if (_waiting_for_frame && _frames_loaded >= _waiting_for_frame )
+    if (_waiting_for_frame && _frames_loaded.load() >= _waiting_for_frame )
     {
         // or should we notify_one ?
         // See: http://boost.org/doc/html/condition.html
@@ -564,9 +560,8 @@ void
 SWFMovieDefinition::add_frame_name(const std::string& n)
 {
     std::lock_guard<std::mutex> lock1(_namedFramesMutex);
-    std::lock_guard<std::mutex> lock2(_frames_loaded_mutex);
 
-    _namedFrames.insert(std::make_pair(n, _frames_loaded));
+    _namedFrames.insert(std::make_pair(n, _frames_loaded.load()));
 }
 
 bool
diff --git a/libcore/parser/SWFMovieDefinition.h 
b/libcore/parser/SWFMovieDefinition.h
index 3636f99..d4f5df7 100644
--- a/libcore/parser/SWFMovieDefinition.h
+++ b/libcore/parser/SWFMovieDefinition.h
@@ -28,6 +28,8 @@
 #endif
 
 #include <boost/intrusive_ptr.hpp>
+
+#include <atomic>
 #include <vector>
 #include <map>
 #include <set> 
@@ -213,17 +215,11 @@ public:
     /// except when parsing finishes, in which case
     /// it an index to on-past-last frame.
     ///
-    /// NOTE: this method locks _frames_loaded_mutex
-    ///
     virtual size_t get_loading_frame() const;
 
     /// Get number of bytes loaded from input stream
-    //
-    /// NOTE: this method locks _bytes_loaded_mutex
-    ///
     size_t get_bytes_loaded() const {
-        std::lock_guard<std::mutex> lock(_bytes_loaded_mutex);
-        return _bytes_loaded;
+        return _bytes_loaded.load();
     }
 
     /// Get total number of bytes as parsed from the SWF header
@@ -276,13 +272,13 @@ public:
     // See dox in movie_definition.h
     void addControlTag(boost::intrusive_ptr<SWF::ControlTag> tag) {
         assert(tag);
-        std::lock_guard<std::mutex> lock(_frames_loaded_mutex);
-        m_playlist[_frames_loaded].push_back(tag);
+        size_t frames_loaded = get_loading_frame();
+        m_playlist[frames_loaded].push_back(tag);
     }
 
     // See dox in movie_definition.h
     //
-    // locks _namedFramesMutex and _frames_loaded_mutex
+    // locks _namedFramesMutex
     //
     DSOTEXPORT void add_frame_name(const std::string& name);
 
@@ -298,8 +294,7 @@ public:
     virtual const PlayList* getPlaylist(size_t frame_number) const {
 
 #ifndef NDEBUG
-        std::lock_guard<std::mutex> lock(_frames_loaded_mutex);
-        assert(frame_number <= _frames_loaded);
+        assert(frame_number <= _frames_loaded.load());
 #endif
 
         PlayListMap::const_iterator it = m_playlist.find(frame_number);
@@ -447,14 +442,7 @@ private:
     int    m_version;
 
     /// Number of fully loaded frames
-    size_t    _frames_loaded;
-
-    /// A mutex protecting access to _frames_loaded
-    //
-    /// This is needed because the loader thread will
-    /// increment this number, while the virtual machine
-    /// thread will read it.
-    mutable std::mutex _frames_loaded_mutex;
+    std::atomic<size_t>    _frames_loaded;
 
     /// A semaphore to signal load of a specific frame
     mutable std::condition_variable _frame_reached_condition;
@@ -466,14 +454,7 @@ private:
     mutable size_t _waiting_for_frame;
 
     /// Number bytes loaded / parsed
-    unsigned long _bytes_loaded;
-
-    /// A mutex protecting access to _bytes_loaded
-    //
-    /// This is needed because the loader thread will
-    /// increment this number, while the virtual machine
-    /// thread will read it.
-    mutable std::mutex _bytes_loaded_mutex;
+    std::atomic<unsigned long> _bytes_loaded;
 
     int m_loading_sound_stream;
 
@@ -497,18 +478,11 @@ private:
     /// \brief
     /// Increment loaded frames count, signaling frame reached condition if
     /// any thread is waiting for that. See ensure_frame_loaded().
-    ///
-    /// NOTE: this method locks _frames_loaded_mutex
-    ///
-    /// @return the new value of _frames_loaded
     DSOTEXPORT virtual void incrementLoadedFrames();
 
     /// Set number of bytes loaded from input stream
-    //
-    /// NOTE: this method locks _bytes_loaded_mutex
     void setBytesLoaded(unsigned long bytes)
     {
-        std::lock_guard<std::mutex> lock(_bytes_loaded_mutex);
         _bytes_loaded=bytes;
     }
 
diff --git a/libmedia/FLVParser.cpp b/libmedia/FLVParser.cpp
index b0e17b1..2e984a0 100644
--- a/libmedia/FLVParser.cpp
+++ b/libmedia/FLVParser.cpp
@@ -338,7 +338,6 @@ FLVParser::parseNextTag(bool index_only)
                completed = true;
 
         // update bytes loaded
-        std::lock_guard<std::mutex> lock(_bytesLoadedMutex);
                _bytesLoaded = _stream->tell(); 
                return false;
        }
@@ -356,7 +355,6 @@ FLVParser::parseNextTag(bool index_only)
        }
 
        if ( position > _bytesLoaded ) {
-               std::lock_guard<std::mutex> lock(_bytesLoadedMutex);
                _bytesLoaded = position;
        }
 
@@ -508,8 +506,7 @@ FLVParser::getUInt24(std::uint8_t* in)
 std::uint64_t
 FLVParser::getBytesLoaded() const
 {
-       std::lock_guard<std::mutex> lock(_bytesLoadedMutex);
-       return _bytesLoaded;
+       return _bytesLoaded.load();
 }
 
 // would be called by parser thread
diff --git a/libmedia/MediaParser.h b/libmedia/MediaParser.h
index 01b4571..a5bacb1 100644
--- a/libmedia/MediaParser.h
+++ b/libmedia/MediaParser.h
@@ -20,6 +20,7 @@
 #ifndef GNASH_MEDIAPARSER_H
 #define GNASH_MEDIAPARSER_H
 
+#include <atomic>
 #include <thread>
 #include <mutex>
 #include <condition_variable>
@@ -484,10 +485,9 @@ public:
        DSOEXPORT bool isBufferEmpty() const;
 
        /// Return the time we want the parser thread to maintain in the buffer
-       DSOEXPORT std::uint64_t getBufferTime() const
+       DSOEXPORT std::uint_fast64_t getBufferTime() const
        {
-               std::lock_guard<std::mutex> lock(_bufferTimeMutex);
-               return _bufferTime;
+               return _bufferTime.load();
        }
 
        /// Set the time we want the parser thread to maintain in the buffer
@@ -495,9 +495,8 @@ public:
        /// @param t
        ///     Number of milliseconds to keep in the buffers.
        ///
-       DSOEXPORT void setBufferTime(std::uint64_t t)
+       DSOEXPORT void setBufferTime(std::uint_fast64_t t)
        {
-               std::lock_guard<std::mutex> lock(_bufferTimeMutex);
                _bufferTime=t;
        }
 
@@ -629,7 +628,7 @@ protected:
        bool _parsingComplete;
 
        /// Number of bytes loaded
-       std::uint64_t _bytesLoaded;
+       std::atomic<std::uint_fast64_t> _bytesLoaded;
 
        /// }@
 
@@ -681,16 +680,13 @@ protected:
 
        bool parserThreadKillRequested() const
        {
-               std::lock_guard<std::mutex> lock(_parserThreadKillRequestMutex);
-               return _parserThreadKillRequested;
+               return _parserThreadKillRequested.load();
        }
 
-       std::uint64_t _bufferTime;
-       mutable std::mutex _bufferTimeMutex;
+        std::atomic<std::uint_fast64_t> _bufferTime;
 
        std::thread _parserThread;
-       mutable std::mutex _parserThreadKillRequestMutex;
-       bool _parserThreadKillRequested;
+       std::atomic<bool> _parserThreadKillRequested;
        std::condition_variable _parserThreadWakeup;
 
        /// Wait on the _parserThreadWakeup condition if buffer is full
@@ -705,9 +701,6 @@ protected:
        /// mutex protecting access to the a/v encoded frames queues
        mutable std::mutex _qMutex;
 
-       /// Mutex protecting _bytesLoaded (read by main, set by parser)
-       mutable std::mutex _bytesLoadedMutex;
-
        /// Method to check if buffer is full w/out locking the _qMutex
        //
        ///
@@ -758,7 +751,6 @@ private:
 
        void requestParserThreadKill()
        {
-               std::lock_guard<std::mutex> lock(_parserThreadKillRequestMutex);
                _parserThreadKillRequested=true;
                _parserThreadWakeup.notify_all();
        }
diff --git a/libmedia/gst/MediaParserGst.cpp b/libmedia/gst/MediaParserGst.cpp
index db3c288..cce8f51 100644
--- a/libmedia/gst/MediaParserGst.cpp
+++ b/libmedia/gst/MediaParserGst.cpp
@@ -138,10 +138,7 @@ MediaParserGst::parseNextChunk()
 
     pushGstBuffer();
 
-    {
-        std::lock_guard<std::mutex> lock(_bytesLoadedMutex);
-        _bytesLoaded = _stream->tell();
-    }
+    _bytesLoaded = _stream->tell();
 
     emitEncodedFrames();
 
@@ -152,8 +149,7 @@ MediaParserGst::parseNextChunk()
 std::uint64_t
 MediaParserGst::getBytesLoaded() const
 {
-    std::lock_guard<std::mutex> lock(_bytesLoadedMutex);
-    return _bytesLoaded;
+    return _bytesLoaded.load();
 }
 
 bool
diff --git a/libsound/aos4/sound_handler_ahi.cpp 
b/libsound/aos4/sound_handler_ahi.cpp
index c05c8fc..70e866c 100644
--- a/libsound/aos4/sound_handler_ahi.cpp
+++ b/libsound/aos4/sound_handler_ahi.cpp
@@ -410,27 +410,6 @@ 
AOS4_sound_handler::plugInputStream(std::unique_ptr<InputStream> newStreamer)
 }
 
 void
-AOS4_sound_handler::mute()
-{
-    std::lock_guard<std::mutex> lock(_mutedMutex);
-    sound_handler::mute();
-}
-
-void
-AOS4_sound_handler::unmute()
-{
-    std::lock_guard<std::mutex> lock(_mutedMutex);
-    sound_handler::unmute();
-}
-
-bool
-AOS4_sound_handler::is_muted() const
-{
-    std::lock_guard<std::mutex> lock(_mutedMutex);
-    return sound_handler::is_muted();
-}
-
-void
 AOS4_sound_handler::pause()
 {
     //closeAudio();
diff --git a/libsound/aos4/sound_handler_ahi.h 
b/libsound/aos4/sound_handler_ahi.h
index 2e699ba..d6fc079 100644
--- a/libsound/aos4/sound_handler_ahi.h
+++ b/libsound/aos4/sound_handler_ahi.h
@@ -88,9 +88,6 @@ private:
     /// Mutex for making sure threads doesn't mess things up
     std::mutex _mutex;
 
-    /// Mutex protecting _muted (defined in base class)
-    mutable std::mutex _mutedMutex;
-
     // See dox in sound_handler.h
     void mix(std::int16_t* outSamples, std::int16_t* inSamples,
                 unsigned int nSamples, float volume);
@@ -135,18 +132,6 @@ public:
     virtual media::SoundInfo* get_sound_info(int soundHandle);
 
     // See dox in sound_handler.h
-    // overridden to serialize access to the _muted member
-    virtual void mute();
-
-    // See dox in sound_handler.h
-    // overridden to serialize access to the _muted member
-    virtual void unmute();
-
-    // See dox in sound_handler.h
-    // overridden to serialize access to the _muted member
-    virtual bool is_muted() const;
-
-    // See dox in sound_handler.h
     // overridden to close audio card
     virtual void pause();
 
diff --git a/libsound/mkit/sound_handler_mkit.cpp 
b/libsound/mkit/sound_handler_mkit.cpp
index e61cf66..ff17884 100644
--- a/libsound/mkit/sound_handler_mkit.cpp
+++ b/libsound/mkit/sound_handler_mkit.cpp
@@ -312,27 +312,6 @@ 
Mkit_sound_handler::plugInputStream(std::unique_ptr<InputStream> newStreamer)
 }
 
 void
-Mkit_sound_handler::mute()
-{
-    std::lock_guard<std::mutex> lock(_mutedMutex);
-    sound_handler::mute();
-}
-
-void
-Mkit_sound_handler::unmute()
-{
-    std::lock_guard<std::mutex> lock(_mutedMutex);
-    sound_handler::unmute();
-}
-
-bool
-Mkit_sound_handler::is_muted() const
-{
-    std::lock_guard<std::mutex> lock(_mutedMutex);
-    return sound_handler::is_muted();
-}
-
-void
 Mkit_sound_handler::pause()
 {
     log_debug(_("Mkit: Mkit_sound_handler::pause"));
diff --git a/libsound/mkit/sound_handler_mkit.h 
b/libsound/mkit/sound_handler_mkit.h
index db54cf3..f77d844 100644
--- a/libsound/mkit/sound_handler_mkit.h
+++ b/libsound/mkit/sound_handler_mkit.h
@@ -57,9 +57,6 @@ class Mkit_sound_handler : public sound_handler
     /// Mutex for making sure threads doesn't mess things up
     std::mutex _mutex;
 
-    /// Mutex protecting _muted (defined in base class)
-    mutable std::mutex _mutedMutex;
-
     // See dox in sound_handler.h
     void mix(std::int16_t* outSamples, std::int16_t* inSamples,
                 unsigned int nSamples, float volume);
@@ -103,18 +100,6 @@ public:
     virtual media::SoundInfo* get_sound_info(int soundHandle);
 
     // See dox in sound_handler.h
-    // overridden to serialize access to the _muted member
-    virtual void mute();
-
-    // See dox in sound_handler.h
-    // overridden to serialize access to the _muted member
-    virtual void unmute();
-
-    // See dox in sound_handler.h
-    // overridden to serialize access to the _muted member
-    virtual bool is_muted() const;
-
-    // See dox in sound_handler.h
     // overridden to close audio card
     virtual void pause();
 
diff --git a/libsound/sdl/sound_handler_sdl.cpp 
b/libsound/sdl/sound_handler_sdl.cpp
index 28b44fc..e46121c 100644
--- a/libsound/sdl/sound_handler_sdl.cpp
+++ b/libsound/sdl/sound_handler_sdl.cpp
@@ -312,27 +312,6 @@ 
SDL_sound_handler::plugInputStream(std::unique_ptr<InputStream> newStreamer)
 }
 
 void
-SDL_sound_handler::mute()
-{
-    std::lock_guard<std::mutex> lock(_mutedMutex);
-    sound_handler::mute();
-}
-
-void
-SDL_sound_handler::unmute()
-{
-    std::lock_guard<std::mutex> lock(_mutedMutex);
-    sound_handler::unmute();
-}
-
-bool
-SDL_sound_handler::is_muted() const
-{
-    std::lock_guard<std::mutex> lock(_mutedMutex);
-    return sound_handler::is_muted();
-}
-
-void
 SDL_sound_handler::pause() 
 {
     closeAudio();
diff --git a/libsound/sdl/sound_handler_sdl.h b/libsound/sdl/sound_handler_sdl.h
index 72293e9..0a5441e 100644
--- a/libsound/sdl/sound_handler_sdl.h
+++ b/libsound/sdl/sound_handler_sdl.h
@@ -59,9 +59,6 @@ private:
     /// Mutex for making sure threads doesn't mess things up
     mutable std::mutex _mutex;
 
-    /// Mutex protecting _muted (defined in base class)
-    mutable std::mutex _mutedMutex;
-
     // See dox in sound_handler.h
     void mix(std::int16_t* outSamples, std::int16_t* inSamples,
                 unsigned int nSamples, float volume);
@@ -129,18 +126,6 @@ public:
     virtual media::SoundInfo* get_sound_info(int soundHandle) const;
 
     // See dox in sound_handler.h
-    // overridden to serialize access to the _muted member
-    virtual void mute();
-
-    // See dox in sound_handler.h
-    // overridden to serialize access to the _muted member
-    virtual void unmute();
-
-    // See dox in sound_handler.h
-    // overridden to serialize access to the _muted member
-    virtual bool is_muted() const;
-
-    // See dox in sound_handler.h
     // overridden to close audio card
     virtual void pause();
 
diff --git a/libsound/sound_handler.cpp b/libsound/sound_handler.cpp
index 33516d3..28ea54c 100644
--- a/libsound/sound_handler.cpp
+++ b/libsound/sound_handler.cpp
@@ -736,7 +736,7 @@ bool
 sound_handler::is_muted() const
 {
     // TODO: lock a mutex ?
-    return _muted;
+    return _muted.load();
 }
 
 void
diff --git a/libsound/sound_handler.h b/libsound/sound_handler.h
index 004034d..38fddea 100644
--- a/libsound/sound_handler.h
+++ b/libsound/sound_handler.h
@@ -23,6 +23,7 @@
 #include "gnashconfig.h"
 #endif
 
+#include <atomic>
 #include <limits>
 #include <memory>
 #include <set>
@@ -312,15 +313,15 @@ public:
     virtual void reset();
         
     /// Call this to mute audio
-    virtual void mute();
+    void mute();
 
     /// Call this to unmute audio
-    virtual void unmute();
+    void unmute();
 
     /// Returns whether or not sound is muted.
     //
     /// @return true if muted, false if not
-    virtual bool is_muted() const;
+    bool is_muted() const;
 
     /// gnash calls this to pause audio
     virtual void pause() { _paused=true; }
@@ -497,7 +498,7 @@ private:
     bool _paused;
 
     /// True if sound is muted
-    bool _muted;
+    std::atomic<bool> _muted;
 
     /// Final output volume
     int _volume;

-----------------------------------------------------------------------

Summary of changes:
 libcore/MovieLoader.cpp               |   15 +----------
 libcore/MovieLoader.h                 |   14 ++++------
 libcore/asobj/NetStream_as.cpp        |   12 ++------
 libcore/asobj/NetStream_as.h          |   21 ++++++---------
 libcore/asobj/Sound_as.cpp            |   13 +++------
 libcore/parser/SWFMovieDefinition.cpp |   27 ++++++++------------
 libcore/parser/SWFMovieDefinition.h   |   44 ++++++--------------------------
 libmedia/FLVParser.cpp                |    5 +---
 libmedia/MediaParser.h                |   24 ++++++------------
 libmedia/gst/MediaParserGst.cpp       |    8 +----
 libsound/aos4/sound_handler_ahi.cpp   |   21 ---------------
 libsound/aos4/sound_handler_ahi.h     |   15 -----------
 libsound/mkit/sound_handler_mkit.cpp  |   21 ---------------
 libsound/mkit/sound_handler_mkit.h    |   15 -----------
 libsound/sdl/sound_handler_sdl.cpp    |   21 ---------------
 libsound/sdl/sound_handler_sdl.h      |   15 -----------
 libsound/sound_handler.cpp            |    2 +-
 libsound/sound_handler.h              |    9 +++---
 18 files changed, 60 insertions(+), 242 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

[Prev in Thread] Current Thread [Next in Thread]