diff --git a/chrome/updater/configurator.h b/chrome/updater/configurator.h index b2a432234687..9478dc709ec5 100644 --- a/chrome/updater/configurator.h +++ b/chrome/updater/configurator.h @@ -19,7 +19,6 @@ #include "cobalt/network/network_module.h" #include "components/update_client/configurator.h" #include "components/update_client/persisted_data.h" -#include "starboard/common/atomic.h" class GURL; class PrefService; diff --git a/starboard/android/shared/android_main.cc b/starboard/android/shared/android_main.cc index 68f2ed249715..62485c6d5e41 100644 --- a/starboard/android/shared/android_main.cc +++ b/starboard/android/shared/android_main.cc @@ -14,13 +14,13 @@ #include #include +#include #include "game-activity/GameActivity.h" #include "starboard/android/shared/application_android.h" #include "starboard/android/shared/jni_env_ext.h" #include "starboard/android/shared/jni_utils.h" #include "starboard/android/shared/log_internal.h" -#include "starboard/common/atomic.h" #include "starboard/common/file.h" #include "starboard/common/semaphore.h" #include "starboard/common/string.h" @@ -40,7 +40,7 @@ namespace starboard { namespace android { namespace shared { -atomic_bool g_block_swapbuffers; +std::atomic_bool g_block_swapbuffers; namespace { @@ -54,7 +54,7 @@ Semaphore* g_app_created_semaphore = nullptr; // Safeguard to avoid sending AndroidCommands either when there is no instance // of the Starboard application, or after the run loop has exited and the // ALooper receiving the commands is no longer being polled. -atomic_bool g_app_running; +std::atomic_bool g_app_running; std::vector GetArgs() { std::vector args; diff --git a/starboard/android/shared/application_android.h b/starboard/android/shared/application_android.h index 3abb860892dc..f241778ea7f9 100644 --- a/starboard/android/shared/application_android.h +++ b/starboard/android/shared/application_android.h @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -26,7 +27,6 @@ #include "starboard/android/shared/input_events_generator.h" #include "starboard/android/shared/jni_env_ext.h" #include "starboard/atomic.h" -#include "starboard/common/atomic.h" #include "starboard/common/condition_variable.h" #include "starboard/common/mutex.h" #include "starboard/configuration.h" @@ -133,7 +133,7 @@ class ApplicationAndroid // In certain situations, the Starboard thread should not try to process new // system events (e.g. while one is being processed). - atomic_bool handle_system_events_; + std::atomic_bool handle_system_events_; // Synchronization for commands that change availability of Android resources // such as the input and/or native_window_. @@ -145,7 +145,7 @@ class ApplicationAndroid SbAtomic32 android_stop_count_ = 0; // Set to true in the destructor to ensure other threads stop waiting. - atomic_bool application_destroying_; + std::atomic_bool application_destroying_; // The last Activity lifecycle state command received. AndroidCommand::CommandType activity_state_; diff --git a/starboard/android/shared/audio_renderer_passthrough.h b/starboard/android/shared/audio_renderer_passthrough.h index a8b25974b55d..2287e1756bb2 100644 --- a/starboard/android/shared/audio_renderer_passthrough.h +++ b/starboard/android/shared/audio_renderer_passthrough.h @@ -116,9 +116,9 @@ class AudioRendererPassthrough EndedCB ended_cb_; int frames_per_input_buffer_ = 0; // Set once before all uses. - atomic_bool can_accept_more_data_{true}; - atomic_bool prerolled_; - atomic_bool end_of_stream_played_; + std::atomic_bool can_accept_more_data_{true}; + std::atomic_bool prerolled_; + std::atomic_bool end_of_stream_played_; bool end_of_stream_written_ = false; // Only accessed on PlayerWorker thread. diff --git a/starboard/android/shared/drm_system.cc b/starboard/android/shared/drm_system.cc index 7897d3b95f78..156155566bf7 100644 --- a/starboard/android/shared/drm_system.cc +++ b/starboard/android/shared/drm_system.cc @@ -20,7 +20,6 @@ #include "starboard/android/shared/jni_env_ext.h" #include "starboard/android/shared/jni_utils.h" #include "starboard/android/shared/media_common.h" -#include "starboard/common/atomic.h" #include "starboard/common/instance_counter.h" #include "starboard/common/thread.h" diff --git a/starboard/android/shared/drm_system.h b/starboard/android/shared/drm_system.h index 56065a47c39f..23c37671d750 100644 --- a/starboard/android/shared/drm_system.h +++ b/starboard/android/shared/drm_system.h @@ -20,13 +20,13 @@ #include #include +#include #include #include #include #include "starboard/android/shared/jni_utils.h" #include "starboard/android/shared/media_common.h" -#include "starboard/common/atomic.h" #include "starboard/common/log.h" #include "starboard/common/mutex.h" #include "starboard/common/thread.h" @@ -128,7 +128,7 @@ class DrmSystem : public ::SbDrmSystemPrivate, private Thread { Mutex mutex_; std::unordered_map> cached_drm_key_ids_; bool hdcp_lost_; - atomic_bool created_media_crypto_session_; + std::atomic_bool created_media_crypto_session_; std::vector metrics_; }; diff --git a/starboard/android/shared/egl_swap_buffers.cc b/starboard/android/shared/egl_swap_buffers.cc index 8cc824127f3b..6c36a5604577 100644 --- a/starboard/android/shared/egl_swap_buffers.cc +++ b/starboard/android/shared/egl_swap_buffers.cc @@ -15,14 +15,15 @@ #include #include +#include + #include "starboard/android/shared/video_window.h" -#include "starboard/common/atomic.h" #include "starboard/shared/gles/gl_call.h" namespace starboard { namespace android { namespace shared { -extern atomic_bool g_block_swapbuffers; +extern std::atomic_bool g_block_swapbuffers; } // namespace shared } // namespace android } // namespace starboard diff --git a/starboard/android/shared/media_codec_bridge_eradicator.h b/starboard/android/shared/media_codec_bridge_eradicator.h index 5681dd9046b5..19fd776a9d6f 100644 --- a/starboard/android/shared/media_codec_bridge_eradicator.h +++ b/starboard/android/shared/media_codec_bridge_eradicator.h @@ -16,10 +16,10 @@ #define STARBOARD_ANDROID_SHARED_MEDIA_CODEC_BRIDGE_ERADICATOR_H_ #include +#include #include #include "starboard/android/shared/jni_env_ext.h" -#include "starboard/common/atomic.h" #include "starboard/common/condition_variable.h" #include "starboard/common/mutex.h" @@ -52,7 +52,7 @@ class MediaCodecBridgeEradicator { private: static void* DestroyMediaCodecBridge(void* context); - atomic_bool is_enabled_{false}; + std::atomic_bool is_enabled_{false}; // Maximum wait time when creating a new MediaCodecBridge if the background // cleanup thread (MediaCodecBridgeEradicator::DestroyMediaCodecBridge) is // unresponsive. diff --git a/starboard/android/shared/media_decoder.cc b/starboard/android/shared/media_decoder.cc index c2f36735bb38..e1ea3dc1bd87 100644 --- a/starboard/android/shared/media_decoder.cc +++ b/starboard/android/shared/media_decoder.cc @@ -102,7 +102,7 @@ MediaDecoder::MediaDecoder(Host* host, if (audio_stream_info.codec != kSbMediaAudioCodecOpus && !audio_stream_info.audio_specific_config.empty()) { pending_tasks_.push_back(Event(audio_stream_info.audio_specific_config)); - number_of_pending_tasks_.increment(); + ++number_of_pending_tasks_; } } @@ -207,7 +207,7 @@ void MediaDecoder::WriteInputBuffers(const InputBuffers& input_buffers) { bool need_signal = pending_tasks_.empty(); for (const auto& input_buffer : input_buffers) { pending_tasks_.push_back(Event(input_buffer)); - number_of_pending_tasks_.increment(); + ++number_of_pending_tasks_; } if (need_signal) { condition_variable_.Signal(); @@ -220,7 +220,7 @@ void MediaDecoder::WriteEndOfStream() { stream_ended_.store(true); ScopedLock scoped_lock(mutex_); pending_tasks_.push_back(Event(Event::kWriteEndOfStream)); - number_of_pending_tasks_.increment(); + ++number_of_pending_tasks_; if (pending_tasks_.size() == 1) { condition_variable_.Signal(); } @@ -431,7 +431,7 @@ bool MediaDecoder::ProcessOneInputBuffer( input_buffer_indices->erase(input_buffer_indices->begin()); event = pending_tasks->front(); pending_tasks->pop_front(); - number_of_pending_tasks_.decrement(); + --number_of_pending_tasks_; } SB_DCHECK(event.type == Event::kWriteCodecConfig || diff --git a/starboard/android/shared/media_decoder.h b/starboard/android/shared/media_decoder.h index 1805966b3c92..92d4b90852c8 100644 --- a/starboard/android/shared/media_decoder.h +++ b/starboard/android/shared/media_decoder.h @@ -17,6 +17,7 @@ #include +#include #include #include #include @@ -24,7 +25,6 @@ #include "starboard/android/shared/drm_system.h" #include "starboard/android/shared/media_codec_bridge.h" -#include "starboard/common/atomic.h" #include "starboard/common/condition_variable.h" #include "starboard/common/mutex.h" #include "starboard/common/optional.h" @@ -188,13 +188,13 @@ class MediaDecoder final SbPlayerError error_; std::string error_message_; - atomic_bool stream_ended_; + std::atomic_bool stream_ended_; - atomic_bool destroying_; + std::atomic_bool destroying_; optional pending_queue_input_buffer_task_; - atomic_int32_t number_of_pending_tasks_; + std::atomic number_of_pending_tasks_; Mutex mutex_; ConditionVariable condition_variable_; diff --git a/starboard/android/shared/player_components_factory.h b/starboard/android/shared/player_components_factory.h index d6060d8406e4..db9d66dcecd4 100644 --- a/starboard/android/shared/player_components_factory.h +++ b/starboard/android/shared/player_components_factory.h @@ -15,6 +15,7 @@ #ifndef STARBOARD_ANDROID_SHARED_PLAYER_COMPONENTS_FACTORY_H_ #define STARBOARD_ANDROID_SHARED_PLAYER_COMPONENTS_FACTORY_H_ +#include #include #include #include @@ -150,7 +151,7 @@ class AudioRendererSinkCallbackStub error_occurred_.store(true); } - atomic_bool error_occurred_; + std::atomic_bool error_occurred_; }; class PlayerComponentsPassthrough diff --git a/starboard/android/shared/video_decoder.h b/starboard/android/shared/video_decoder.h index 5241bbb1f9fe..fb864042205b 100644 --- a/starboard/android/shared/video_decoder.h +++ b/starboard/android/shared/video_decoder.h @@ -166,8 +166,8 @@ class VideoDecoder std::unique_ptr video_frame_tracker_; // Preroll in tunnel mode is handled in this class instead of in the renderer. - atomic_bool tunnel_mode_prerolling_{true}; - atomic_bool tunnel_mode_frame_rendered_; + std::atomic_bool tunnel_mode_prerolling_{true}; + std::atomic_bool tunnel_mode_frame_rendered_; // If decode-to-texture is enabled, then we store the decode target texture // inside of this |decode_target_| member. @@ -193,14 +193,14 @@ class VideoDecoder std::unique_ptr media_decoder_; - atomic_int32_t number_of_frames_being_decoded_; + std::atomic number_of_frames_being_decoded_; scoped_refptr sink_; int input_buffer_written_ = 0; bool first_texture_received_ = false; bool end_of_stream_written_ = false; volatile int64_t first_buffer_timestamp_; // microseconds - atomic_bool has_new_texture_available_; + std::atomic_bool has_new_texture_available_; // Use |owns_video_surface_| only on decoder thread, to avoid unnecessary // invocation of ReleaseVideoSurface(), though ReleaseVideoSurface() would diff --git a/starboard/common/thread.cc b/starboard/common/thread.cc index 95a15c7a13a6..891e52b4048b 100644 --- a/starboard/common/thread.cc +++ b/starboard/common/thread.cc @@ -18,8 +18,8 @@ #include #include +#include -#include "starboard/common/atomic.h" #include "starboard/common/log.h" #include "starboard/common/mutex.h" #include "starboard/common/optional.h" @@ -30,14 +30,16 @@ namespace starboard { struct Thread::Data { std::string name_; pthread_t thread_ = 0; - atomic_bool started_; - atomic_bool join_called_; + std::atomic_bool started_; + std::atomic_bool join_called_; Semaphore join_sema_; }; Thread::Thread(const std::string& name) { d_.reset(new Thread::Data); d_->name_ = name; + d_->started_.store(false); + d_->join_called_.store(false); } Thread::~Thread() { @@ -74,7 +76,7 @@ starboard::Semaphore* Thread::join_sema() { return &d_->join_sema_; } -starboard::atomic_bool* Thread::joined_bool() { +std::atomic_bool* Thread::joined_bool() { return &d_->join_called_; } diff --git a/starboard/common/thread.h b/starboard/common/thread.h index 1ac5a19d47c3..9e0af365ec78 100644 --- a/starboard/common/thread.h +++ b/starboard/common/thread.h @@ -17,6 +17,7 @@ #ifndef STARBOARD_COMMON_THREAD_H_ #define STARBOARD_COMMON_THREAD_H_ +#include #include #include #include @@ -28,7 +29,6 @@ namespace starboard { class Semaphore; -class atomic_bool; class Thread { public: @@ -64,7 +64,7 @@ class Thread { // Join() was called then return |true|, else |false|. bool WaitForJoin(int64_t timeout); Semaphore* join_sema(); - atomic_bool* joined_bool(); + std::atomic_bool* joined_bool(); struct Data; std::unique_ptr d_; diff --git a/starboard/nplb/player_test_util.cc b/starboard/nplb/player_test_util.cc index b02038ff1bc2..0c38b9b6c56a 100644 --- a/starboard/nplb/player_test_util.cc +++ b/starboard/nplb/player_test_util.cc @@ -14,10 +14,10 @@ #include "starboard/nplb/player_test_util.h" +#include #include #include "starboard/audio_sink.h" -#include "starboard/common/atomic.h" #include "starboard/common/string.h" #include "starboard/extension/enhanced_audio.h" #include "starboard/nplb/drm_helpers.h" @@ -81,7 +81,7 @@ void ErrorFunc(SbPlayer player, void* context, SbPlayerError error, const char* message) { - atomic_bool* error_occurred = static_cast(context); + std::atomic_bool* error_occurred = static_cast(context); error_occurred->exchange(true); } diff --git a/starboard/nplb/thread_sampler_test.cc b/starboard/nplb/thread_sampler_test.cc index 0693e9858baa..d57248c29f58 100644 --- a/starboard/nplb/thread_sampler_test.cc +++ b/starboard/nplb/thread_sampler_test.cc @@ -14,8 +14,8 @@ #include #include +#include -#include "starboard/common/atomic.h" #include "starboard/common/log.h" #include "starboard/common/time.h" @@ -41,7 +41,7 @@ class CountingThread : public posix::AbstractTestThread { void Run() override { while (!stop_.load()) { - counter_.increment(); + ++counter_; usleep(1000); } } @@ -65,8 +65,8 @@ class CountingThread : public posix::AbstractTestThread { } private: - atomic_bool stop_; - atomic_int32_t counter_; + std::atomic_bool stop_; + std::atomic_int counter_; }; TEST(ThreadSamplerTest, RainyDayCreateSamplerInvalidThread) { diff --git a/starboard/nplb/thread_test.cc b/starboard/nplb/thread_test.cc index b2cb4e79b9e9..ee75b48d0e1d 100644 --- a/starboard/nplb/thread_test.cc +++ b/starboard/nplb/thread_test.cc @@ -14,9 +14,9 @@ #include +#include #include -#include "starboard/common/atomic.h" #include "starboard/common/semaphore.h" #include "starboard/common/thread.h" #include "testing/gtest/include/gtest/gtest.h" @@ -34,7 +34,7 @@ class TestRunThread : public Thread { } finished_.store(true); } - atomic_bool finished_; + std::atomic_bool finished_; }; // Tests the expectation that a thread subclass will have the expected diff --git a/starboard/shared/pulse/pulse_audio_sink_type.cc b/starboard/shared/pulse/pulse_audio_sink_type.cc index c5eacadf1082..eb091fc508e3 100644 --- a/starboard/shared/pulse/pulse_audio_sink_type.cc +++ b/starboard/shared/pulse/pulse_audio_sink_type.cc @@ -18,13 +18,13 @@ #include #include +#include #include #include #include #include "starboard/audio_sink.h" -#include "starboard/common/atomic.h" #include "starboard/common/log.h" #include "starboard/common/mutex.h" #include "starboard/common/time.h" @@ -117,9 +117,9 @@ class PulseAudioSink : public SbAudioSinkPrivate { size_t last_request_size_ = 0; int64_t total_frames_played_ = 0; int64_t total_frames_written_ = 0; - atomic_double volume_{1.0}; - atomic_bool volume_updated_{true}; - atomic_bool is_paused_{false}; + std::atomic volume_{1.0}; + std::atomic_bool volume_updated_{true}; + std::atomic_bool is_paused_{false}; }; class PulseAudioSinkType : public SbAudioSinkPrivate::Type { diff --git a/starboard/shared/starboard/link_receiver.cc b/starboard/shared/starboard/link_receiver.cc index dcc9a3f41cea..79eb432c51d9 100644 --- a/starboard/shared/starboard/link_receiver.cc +++ b/starboard/shared/starboard/link_receiver.cc @@ -14,12 +14,12 @@ #include "starboard/shared/starboard/link_receiver.h" +#include #include #include #include #include -#include "starboard/common/atomic.h" #include "starboard/common/file.h" #include "starboard/common/log.h" #include "starboard/common/semaphore.h" @@ -218,7 +218,7 @@ class LinkReceiver::Impl { pthread_t thread_; // An atomic flag that indicates whether to quit to the server thread. - atomic_bool quit_; + std::atomic_bool quit_; // The waiter to register sockets with and block on. SbSocketWaiter waiter_; diff --git a/starboard/shared/starboard/net_log.cc b/starboard/shared/starboard/net_log.cc index 632fdc847221..cb0fbf9c6818 100644 --- a/starboard/shared/starboard/net_log.cc +++ b/starboard/shared/starboard/net_log.cc @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -26,7 +27,6 @@ #include #include -#include "starboard/common/atomic.h" #include "starboard/common/log.h" #include "starboard/common/mutex.h" #include "starboard/common/once.h" @@ -197,7 +197,7 @@ class BufferedSocketWriter { SbSocketError err = SbSocketGetLastError(dest_socket); SbSocketClearLastError(dest_socket); if (err == kSbSocketPending) { - blocked_counts_.increment(); + ++blocked_counts_; WaitUntilWritableOrConnectionReset(dest_socket); continue; } else if (IsConnectionReset(err)) { @@ -251,7 +251,7 @@ class BufferedSocketWriter { int chunk_size_; Mutex log_mutex_; std::deque log_; - atomic_int32_t blocked_counts_; + std::atomic blocked_counts_; }; // This class will listen to the provided socket for a client @@ -383,7 +383,7 @@ class NetLogServer { std::unique_ptr socket_listener_; std::unique_ptr writer_thread_; Semaphore writer_thread_sema_; - atomic_bool is_joined_; + std::atomic_bool is_joined_; BufferedSocketWriter buffered_socket_writer_; }; diff --git a/starboard/shared/starboard/player/filter/audio_renderer_internal_pcm.cc b/starboard/shared/starboard/player/filter/audio_renderer_internal_pcm.cc index 67614ac7a271..011063eab0a7 100644 --- a/starboard/shared/starboard/player/filter/audio_renderer_internal_pcm.cc +++ b/starboard/shared/starboard/player/filter/audio_renderer_internal_pcm.cc @@ -370,7 +370,7 @@ void AudioRendererPcm::GetSourceStatus(int* frames_in_buffer, bool* is_playing, bool* is_eos_reached) { #if SB_PLAYER_FILTER_ENABLE_STATE_CHECK - sink_callbacks_since_last_check_.increment(); + ++sink_callbacks_since_last_check_; #endif // SB_PLAYER_FILTER_ENABLE_STATE_CHECK { @@ -425,7 +425,7 @@ void AudioRendererPcm::GetSourceStatus(int* frames_in_buffer, void AudioRendererPcm::ConsumeFrames(int frames_consumed, int64_t frames_consumed_at) { #if SB_PLAYER_FILTER_ENABLE_STATE_CHECK - sink_callbacks_since_last_check_.increment(); + ++sink_callbacks_since_last_check_; #endif // SB_PLAYER_FILTER_ENABLE_STATE_CHECK // Note that occasionally thread context switch may cause that the time diff --git a/starboard/shared/starboard/player/filter/audio_renderer_internal_pcm.h b/starboard/shared/starboard/player/filter/audio_renderer_internal_pcm.h index 6a424b4c20f7..e157ee2c5e8b 100644 --- a/starboard/shared/starboard/player/filter/audio_renderer_internal_pcm.h +++ b/starboard/shared/starboard/player/filter/audio_renderer_internal_pcm.h @@ -15,12 +15,12 @@ #ifndef STARBOARD_SHARED_STARBOARD_PLAYER_FILTER_AUDIO_RENDERER_INTERNAL_PCM_H_ #define STARBOARD_SHARED_STARBOARD_PLAYER_FILTER_AUDIO_RENDERER_INTERNAL_PCM_H_ +#include #include #include #include #include -#include "starboard/common/atomic.h" #include "starboard/common/log.h" #include "starboard/common/mutex.h" #include "starboard/common/optional.h" @@ -206,7 +206,7 @@ class AudioRendererPcm : public AudioRenderer, static const int64_t kCheckAudioSinkStatusInterval = 1'000'000; // 1 second void CheckAudioSinkStatus(); - atomic_int32_t sink_callbacks_since_last_check_; + std::atomic sink_callbacks_since_last_check_; #endif // SB_PLAYER_FILTER_ENABLE_STATE_CHECK }; diff --git a/starboard/shared/starboard/player/filter/punchout_video_renderer_sink.h b/starboard/shared/starboard/player/filter/punchout_video_renderer_sink.h index dc4d3ed47775..a9c2a3f75158 100644 --- a/starboard/shared/starboard/player/filter/punchout_video_renderer_sink.h +++ b/starboard/shared/starboard/player/filter/punchout_video_renderer_sink.h @@ -16,8 +16,8 @@ #define STARBOARD_SHARED_STARBOARD_PLAYER_FILTER_PUNCHOUT_VIDEO_RENDERER_SINK_H_ #include +#include -#include "starboard/common/atomic.h" #include "starboard/common/mutex.h" #include "starboard/media.h" #include "starboard/player.h" @@ -50,7 +50,7 @@ class PunchoutVideoRendererSink : public VideoRendererSink { int64_t render_interval_; // microseconds RenderCB render_cb_; pthread_t thread_; - atomic_bool stop_requested_; + std::atomic_bool stop_requested_; Mutex mutex_; int z_index_; diff --git a/starboard/shared/starboard/player/filter/video_renderer_internal_impl.cc b/starboard/shared/starboard/player/filter/video_renderer_internal_impl.cc index 2b7c6410ac6b..d13a5c481bb2 100644 --- a/starboard/shared/starboard/player/filter/video_renderer_internal_impl.cc +++ b/starboard/shared/starboard/player/filter/video_renderer_internal_impl.cc @@ -284,7 +284,7 @@ void VideoRendererImpl::OnDecoderStatus( if (decoder_frames_.empty() || frame->is_end_of_stream() || frame->timestamp() > decoder_frames_.back()->timestamp()) { decoder_frames_.push_back(frame); - number_of_frames_.increment(); + ++number_of_frames_; } } diff --git a/starboard/shared/starboard/player/filter/video_renderer_internal_impl.h b/starboard/shared/starboard/player/filter/video_renderer_internal_impl.h index 36b310e64abe..3f50727b649c 100644 --- a/starboard/shared/starboard/player/filter/video_renderer_internal_impl.h +++ b/starboard/shared/starboard/player/filter/video_renderer_internal_impl.h @@ -15,10 +15,10 @@ #ifndef STARBOARD_SHARED_STARBOARD_PLAYER_FILTER_VIDEO_RENDERER_INTERNAL_IMPL_H_ #define STARBOARD_SHARED_STARBOARD_PLAYER_FILTER_VIDEO_RENDERER_INTERNAL_IMPL_H_ +#include #include #include -#include "starboard/common/atomic.h" #include "starboard/common/log.h" #include "starboard/common/mutex.h" #include "starboard/common/ref_counted.h" @@ -97,16 +97,16 @@ class VideoRendererImpl : public VideoRenderer, private JobQueue::JobOwner { // performance by keeping track of whether we already have a fresh decoder, // and can thus avoid doing a full reset. bool first_input_written_ = false; - atomic_bool end_of_stream_written_; - atomic_bool end_of_stream_decoded_; - atomic_bool ended_cb_called_; + std::atomic_bool end_of_stream_written_; + std::atomic_bool end_of_stream_decoded_; + std::atomic_bool ended_cb_called_; - atomic_bool need_more_input_; - atomic_bool seeking_; + std::atomic_bool need_more_input_; + std::atomic_bool seeking_; int64_t seeking_to_time_ = 0; // microseconds // |number_of_frames_| = decoder_frames_.size() + sink_frames_.size() - atomic_int32_t number_of_frames_; + std::atomic number_of_frames_; // |sink_frames_| is locked inside VideoRenderer::Render() when calling // algorithm_->Render(). So OnDecoderStatus() won't try to lock and append // the decoded frames to |sink_frames_| directly to avoid being blocked. It diff --git a/starboard/shared/starboard/queue_application.cc b/starboard/shared/starboard/queue_application.cc index bb4a186821ab..f4b408d14390 100644 --- a/starboard/shared/starboard/queue_application.cc +++ b/starboard/shared/starboard/queue_application.cc @@ -14,7 +14,8 @@ #include "starboard/shared/starboard/queue_application.h" -#include "starboard/common/atomic.h" +#include + #include "starboard/common/condition_variable.h" #include "starboard/common/log.h" #include "starboard/common/time.h" @@ -92,11 +93,11 @@ void QueueApplication::CancelTimedEvent(SbEventId event_id) { void QueueApplication::InjectAndProcess(SbEventType type, bool checkSystemEvents) { - atomic_bool event_processed; + std::atomic_bool event_processed; Event* flagged_event = new Event( - type, const_cast(&event_processed), [](void* flag) { + type, const_cast(&event_processed), [](void* flag) { auto* bool_flag = - const_cast(static_cast(flag)); + const_cast(static_cast(flag)); bool_flag->store(true); }); Inject(flagged_event); diff --git a/starboard/shared/uwp/audio_renderer_passthrough.h b/starboard/shared/uwp/audio_renderer_passthrough.h index 53f0447cdb6d..8c8c1f1a183d 100644 --- a/starboard/shared/uwp/audio_renderer_passthrough.h +++ b/starboard/shared/uwp/audio_renderer_passthrough.h @@ -107,12 +107,12 @@ class AudioRendererPassthrough : public AudioRenderer, double playback_rate_ = 1.0; int64_t seeking_to_time_ = 0; - atomic_bool end_of_stream_written_{false}; - atomic_bool end_of_stream_played_{false}; + std::atomic_bool end_of_stream_written_{false}; + std::atomic_bool end_of_stream_played_{false}; // Use DecodedAudio to store decrypted and formatted encoded audio data. std::queue> pending_inputs_; - atomic_bool can_accept_more_data_; + std::atomic_bool can_accept_more_data_; JobQueue::JobToken process_audio_buffers_job_token_; std::function process_audio_buffers_job_; diff --git a/starboard/shared/uwp/extended_resources_manager.h b/starboard/shared/uwp/extended_resources_manager.h index 78d3fee1d9c8..7df52acd7449 100644 --- a/starboard/shared/uwp/extended_resources_manager.h +++ b/starboard/shared/uwp/extended_resources_manager.h @@ -20,7 +20,6 @@ #include -#include "starboard/common/atomic.h" #include "starboard/common/mutex.h" #include "starboard/common/queue.h" #include "starboard/configuration.h" @@ -85,7 +84,7 @@ class ExtendedResourcesManager { shared::starboard::ThreadChecker thread_checker_; Mutex mutex_; - atomic_bool is_extended_resources_acquired_; + std::atomic_bool is_extended_resources_acquired_; std::atomic_bool is_av1_shader_compiled_ = {false}; std::atomic_bool is_vp9_shader_compiled_ = {false}; @@ -99,7 +98,7 @@ class ExtendedResourcesManager { // This is set to true when a release of extended resources is requested. // Anything delaying the release should be expedited when this is set. - atomic_bool pending_extended_resources_release_; + std::atomic_bool pending_extended_resources_release_; // This condition variable is used to synchronize changes to // is_extended_resources_acquired_. diff --git a/starboard/shared/uwp/microphone_impl.cc b/starboard/shared/uwp/microphone_impl.cc index 8b5eb24588f9..bf3f2751ee48 100644 --- a/starboard/shared/uwp/microphone_impl.cc +++ b/starboard/shared/uwp/microphone_impl.cc @@ -21,13 +21,13 @@ // C++ headers. #include +#include #include #include #include #include #include -#include "starboard/common/atomic.h" #include "starboard/common/log.h" #include "starboard/common/mutex.h" #include "starboard/common/semaphore.h" @@ -492,7 +492,7 @@ class MicrophoneImpl : public SbMicrophonePrivate { // Singleton access is required by the microphone interface as specified by // nplb. const SbMicrophoneId kSingletonId = reinterpret_cast(0x1); -starboard::atomic_pointer s_singleton_pointer; +std::atomic s_singleton_pointer; } // namespace. diff --git a/starboard/shared/uwp/wasapi_audio.cc b/starboard/shared/uwp/wasapi_audio.cc index 149da359d01d..679aacc4a47c 100644 --- a/starboard/shared/uwp/wasapi_audio.cc +++ b/starboard/shared/uwp/wasapi_audio.cc @@ -15,8 +15,8 @@ #include "starboard/shared/uwp/wasapi_audio.h" #include +#include -#include "starboard/common/atomic.h" #include "starboard/common/log.h" #include "starboard/common/mutex.h" #include "starboard/common/once.h" @@ -97,7 +97,7 @@ class DefaultAudioRenderParams { } private: - atomic_bool is_dirty_{true}; + std::atomic_bool is_dirty_{true}; Mutex mutex_; int cached_bitrate_ = 0; int cached_channels_ = 0; diff --git a/starboard/shared/uwp/wasapi_audio_sink.h b/starboard/shared/uwp/wasapi_audio_sink.h index 0755a12d1757..c846f3476deb 100644 --- a/starboard/shared/uwp/wasapi_audio_sink.h +++ b/starboard/shared/uwp/wasapi_audio_sink.h @@ -19,11 +19,11 @@ #include #include +#include #include #include #include -#include "starboard/common/atomic.h" #include "starboard/common/log.h" #include "starboard/common/mutex.h" #include "starboard/common/ref_counted.h" @@ -156,9 +156,9 @@ class WASAPIAudioSink { const int kAc3BufferSizeInFrames = 1536; const int kEac3BufferSizeInFrames = 6144; - atomic_bool paused_{false}; - atomic_double playback_rate_{0.0}; - atomic_double volume_{0.0}; + std::atomic_bool paused_{false}; + std::atomic playback_rate_{0.0}; + std::atomic volume_{0.0}; double current_volume_ = 0.0; bool was_playing_ = false; diff --git a/starboard/shared/widevine/drm_system_widevine.h b/starboard/shared/widevine/drm_system_widevine.h index 146557313e2b..257de6558cf0 100644 --- a/starboard/shared/widevine/drm_system_widevine.h +++ b/starboard/shared/widevine/drm_system_widevine.h @@ -15,13 +15,14 @@ #ifndef STARBOARD_SHARED_WIDEVINE_DRM_SYSTEM_WIDEVINE_H_ #define STARBOARD_SHARED_WIDEVINE_DRM_SYSTEM_WIDEVINE_H_ +#include #include #include #include #include #include -#include "starboard/common/atomic.h" +#include "starboard/common/mutex.h" #include "starboard/common/optional.h" #include "starboard/mutex.h" #include "starboard/shared/starboard/drm/drm_system_internal.h" @@ -199,7 +200,7 @@ class DrmSystemWidevine : public SbDrmSystemPrivate, int maximum_number_of_session_updates_ = std::numeric_limits::max(); #endif // !defined(COBALT_BUILD_TYPE_GOLD) - atomic_bool first_update_session_received_{false}; + std::atomic_bool first_update_session_received_{false}; }; } // namespace widevine diff --git a/starboard/shared/win32/audio_decoder_thread.cc b/starboard/shared/win32/audio_decoder_thread.cc index f1bd9497fd6b..15e77d620bd0 100644 --- a/starboard/shared/win32/audio_decoder_thread.cc +++ b/starboard/shared/win32/audio_decoder_thread.cc @@ -75,7 +75,7 @@ bool AudioDecoderThread::QueueInput(const scoped_refptr& buffer) { } // increment() returns the previous value. - size_t element_count = processing_elements_.increment() + 1; + size_t element_count = processing_elements_++ + 1; semaphore_.Put(); return element_count < kMaxProcessingElements; } diff --git a/starboard/shared/win32/audio_decoder_thread.h b/starboard/shared/win32/audio_decoder_thread.h index 34567135a2e6..af6582740d22 100644 --- a/starboard/shared/win32/audio_decoder_thread.h +++ b/starboard/shared/win32/audio_decoder_thread.h @@ -15,10 +15,10 @@ #ifndef STARBOARD_SHARED_WIN32_AUDIO_DECODER_THREAD_H_ #define STARBOARD_SHARED_WIN32_AUDIO_DECODER_THREAD_H_ +#include #include #include -#include "starboard/common/atomic.h" #include "starboard/common/ref_counted.h" #include "starboard/common/semaphore.h" #include "starboard/common/thread.h" @@ -60,7 +60,7 @@ class AudioDecoderThread : private Thread { std::deque > input_buffer_queue_; ::starboard::Mutex input_buffer_queue_mutex_; - atomic_int32_t processing_elements_; + std::atomic processing_elements_; Semaphore semaphore_; }; diff --git a/starboard/shared/win32/socket_internal.h b/starboard/shared/win32/socket_internal.h index c51eed06411b..bec0ab90357d 100644 --- a/starboard/shared/win32/socket_internal.h +++ b/starboard/shared/win32/socket_internal.h @@ -17,8 +17,8 @@ #include #include +#include -#include "starboard/common/atomic.h" #include "starboard/common/socket.h" #include "starboard/shared/internal_only.h" #include "starboard/shared/win32/auto_event_handle.h" @@ -69,7 +69,7 @@ struct SbSocketPrivate { // edge-triggered, unlike other events. // // See MSDN documentation for WSAEventSelect FD_WRITE for more info. - starboard::atomic_bool writable; + std::atomic_bool writable; // The last error that occurred on this socket, or kSbSocketOk. SbSocketError error; diff --git a/starboard/shared/win32/win32_audio_decoder.cc b/starboard/shared/win32/win32_audio_decoder.cc index 4c297841c4d3..ba9766a6d393 100644 --- a/starboard/shared/win32/win32_audio_decoder.cc +++ b/starboard/shared/win32/win32_audio_decoder.cc @@ -234,7 +234,7 @@ class AbstractWin32AudioDecoderImpl : public AbstractWin32AudioDecoder { std::unique_ptr impl_; std::queue output_queue_; uint16_t number_of_channels_; - atomic_bool heaac_detected_; + std::atomic_bool heaac_detected_; int samples_per_second_; const size_t expected_buffer_size_; }; diff --git a/starboard/xb1/shared/gpu_base_video_decoder.h b/starboard/xb1/shared/gpu_base_video_decoder.h index 3bd9c7a31650..5ef5210ff80b 100644 --- a/starboard/xb1/shared/gpu_base_video_decoder.h +++ b/starboard/xb1/shared/gpu_base_video_decoder.h @@ -25,7 +25,6 @@ #include #include -#include "starboard/common/atomic.h" #include "starboard/common/mutex.h" #include "starboard/common/ref_counted.h" #include "starboard/shared/starboard/decode_target/decode_target_context_runner.h" @@ -205,7 +204,7 @@ class GpuVideoDecoderBase const bool is_10x3_preferred_; int frame_width_; int frame_height_; - atomic_integral decoder_behavior_{kDecodingStopped}; + std::atomic decoder_behavior_{kDecodingStopped}; std::atomic_bool error_occured_ = {false}; // These are platform-specific objects required to create and use a codec.