From 39a47ca5c168d2c29021ce4acd4eadd661c55895 Mon Sep 17 00:00:00 2001 From: Alexander Bobrovnik Date: Tue, 13 Feb 2024 14:32:01 +0100 Subject: [PATCH] Switch from scoped_ptr to std::unique_ptr in shared code b/291356560 --- starboard/common/murmurhash2.cc | 2 +- starboard/common/murmurhash2.h | 2 +- starboard/common/scoped_ptr.h | 12 ++++ starboard/common/thread.h | 3 +- starboard/shared/starboard/application.cc | 5 +- starboard/shared/starboard/application.h | 3 +- starboard/shared/starboard/net_args.cc | 21 ++++--- starboard/shared/starboard/net_log.cc | 35 ++++++----- .../filter/adaptive_audio_decoder_internal.h | 8 +-- .../filter/audio_channel_layout_mixer.h | 3 +- .../filter/audio_channel_layout_mixer_impl.cc | 4 +- .../player/filter/audio_frame_tracker.cc | 1 - .../filter/audio_renderer_internal_pcm.cc | 9 +-- .../filter/audio_renderer_internal_pcm.h | 11 ++-- .../starboard/player/filter/audio_resampler.h | 4 +- .../player/filter/audio_resampler_impl.cc | 4 +- .../player/filter/audio_time_stretcher.h | 4 +- .../starboard/player/filter/cpu_video_frame.h | 3 +- .../filter_based_player_worker_handler.cc | 6 +- .../filter_based_player_worker_handler.h | 3 +- .../filter/interleaved_sinc_resampler.h | 8 ++- .../player/filter/media_time_provider_impl.cc | 6 +- .../player/filter/media_time_provider_impl.h | 6 +- .../player/filter/player_components.cc | 63 ++++++++++--------- .../player/filter/player_components.h | 21 ++++--- .../player/filter/stub_audio_decoder.h | 2 +- .../filter/stub_player_components_factory.cc | 4 +- .../filter/stub_player_components_factory.h | 10 +-- .../player/filter/stub_video_decoder.h | 2 +- .../filter/video_renderer_internal_impl.cc | 9 +-- .../filter/video_renderer_internal_impl.h | 9 +-- .../starboard/player/filter/wsola_internal.cc | 9 ++- .../shared/starboard/player/job_thread.h | 2 +- .../shared/starboard/player/player_create.cc | 5 +- .../starboard/player/player_internal.cc | 10 +-- .../shared/starboard/player/player_internal.h | 6 +- .../shared/starboard/player/player_worker.cc | 9 +-- .../shared/starboard/player/player_worker.h | 8 +-- 38 files changed, 182 insertions(+), 150 deletions(-) diff --git a/starboard/common/murmurhash2.cc b/starboard/common/murmurhash2.cc index b38d0f97ce67..b733cddf8fec 100644 --- a/starboard/common/murmurhash2.cc +++ b/starboard/common/murmurhash2.cc @@ -30,7 +30,7 @@ uint32_t MurmurHash2_32(const void* src, uint32_t size, uint32_t prev_hash) { memcpy(aligned_src, src, size); return MurmurHash2_32_Aligned(aligned_src, size, prev_hash); } else { - scoped_array aligned_src(new char[size]); + std::unique_ptr aligned_src(new char[size]); memcpy(aligned_src.get(), src, size); return MurmurHash2_32_Aligned(aligned_src.get(), size, prev_hash); } diff --git a/starboard/common/murmurhash2.h b/starboard/common/murmurhash2.h index b520efd71e6a..58c2e35a54ee 100644 --- a/starboard/common/murmurhash2.h +++ b/starboard/common/murmurhash2.h @@ -15,7 +15,7 @@ #ifndef STARBOARD_COMMON_MURMURHASH2_H_ #define STARBOARD_COMMON_MURMURHASH2_H_ -#include "starboard/common/scoped_ptr.h" +#include #include "starboard/types.h" namespace starboard { diff --git a/starboard/common/scoped_ptr.h b/starboard/common/scoped_ptr.h index 35e29088b869..de6dd1c2b4b4 100644 --- a/starboard/common/scoped_ptr.h +++ b/starboard/common/scoped_ptr.h @@ -93,6 +93,7 @@ // scoped_array, scoped_ptr_malloc. #include +#include #include #include "starboard/common/log.h" @@ -134,6 +135,9 @@ class scoped_ptr { : ptr_(other.release()) {} #endif + scoped_ptr(scoped_ptr&& other) + : ptr_(other.release()) {} + // Constructor. Move constructor for C++03 move emulation of this type. scoped_ptr(RValue rvalue) // NOLINT(runtime/explicit) : ptr_(rvalue.object->release()) {} @@ -497,6 +501,14 @@ scoped_ptr make_scoped_ptr(T* ptr) { return scoped_ptr(ptr); } +#ifdef DEPRECATED_SCOPED_PTR +template +using unique_ptr_alias = std::unique_ptr; +#else +template +using unique_ptr_alias = scoped_ptr; +#endif + } // namespace starboard #endif // STARBOARD_COMMON_SCOPED_PTR_H_ diff --git a/starboard/common/thread.h b/starboard/common/thread.h index 15316e9b66aa..74c144bc4f64 100644 --- a/starboard/common/thread.h +++ b/starboard/common/thread.h @@ -18,6 +18,7 @@ #define STARBOARD_COMMON_THREAD_H_ #include +#include #include #include "starboard/common/scoped_ptr.h" @@ -74,7 +75,7 @@ class Thread { atomic_bool* joined_bool(); struct Data; - scoped_ptr d_; + std::unique_ptr d_; Thread(const Thread&) = delete; void operator=(const Thread&) = delete; diff --git a/starboard/shared/starboard/application.cc b/starboard/shared/starboard/application.cc index b85194b0de28..c11680145d7e 100644 --- a/starboard/shared/starboard/application.cc +++ b/starboard/shared/starboard/application.cc @@ -19,7 +19,6 @@ #include "starboard/atomic.h" #include "starboard/common/condition_variable.h" #include "starboard/common/log.h" -#include "starboard/common/scoped_ptr.h" #include "starboard/common/string.h" #include "starboard/configuration.h" #include "starboard/event.h" @@ -249,7 +248,7 @@ bool Application::DispatchAndDelete(Application::Event* event) { } // Ensure the event is deleted unless it is released. - scoped_ptr scoped_event(event); + std::unique_ptr scoped_event(event); // Ensure that we go through the the appropriate lifecycle events based on // the current state. If intermediate events need to be processed, use @@ -409,7 +408,7 @@ bool Application::DispatchAndDelete(Application::Event* event) { bool Application::HandleEventAndUpdateState(Application::Event* event) { // Ensure the event is deleted unless it is released. - scoped_ptr scoped_event(event); + std::unique_ptr scoped_event(event); // Call OnSuspend() and OnResume() before the event as needed. if (scoped_event->event->type == kSbEventTypeUnfreeze && diff --git a/starboard/shared/starboard/application.h b/starboard/shared/starboard/application.h index 3f4f219fcd25..7482ccafb0a5 100644 --- a/starboard/shared/starboard/application.h +++ b/starboard/shared/starboard/application.h @@ -18,6 +18,7 @@ #ifndef STARBOARD_SHARED_STARBOARD_APPLICATION_H_ #define STARBOARD_SHARED_STARBOARD_APPLICATION_H_ +#include #include #include "starboard/atomic.h" @@ -441,7 +442,7 @@ class Application { SbThread thread_; // CommandLine instance initialized in |Run|. - scoped_ptr command_line_; + std::unique_ptr command_line_; // The deep link included in the Start event sent to Cobalt. Initially NULL, // derived classes may set it during initialization using |SetStartLink|. diff --git a/starboard/shared/starboard/net_args.cc b/starboard/shared/starboard/net_args.cc index 860b1b7b0575..0e2440f99dd8 100644 --- a/starboard/shared/starboard/net_args.cc +++ b/starboard/shared/starboard/net_args.cc @@ -14,10 +14,11 @@ #include "starboard/shared/starboard/net_args.h" +#include #include #include -#include "starboard/common/scoped_ptr.h" +#include "starboard/common/log.h" #include "starboard/common/socket.h" #include "starboard/common/time.h" #include "starboard/socket_waiter.h" @@ -37,8 +38,8 @@ namespace shared { namespace starboard { namespace { -scoped_ptr CreateListenSocket() { - scoped_ptr socket( +std::unique_ptr CreateListenSocket() { + std::unique_ptr socket( new Socket(NET_ARGS_IP_VERSION, kSbSocketProtocolTcp)); socket->SetReuseAddress(true); SbSocketAddress sock_addr; @@ -56,7 +57,7 @@ scoped_ptr CreateListenSocket() { if (sock_err != kSbSocketOk) { SbLogRawFormatF(kErrFmt, sock_err); } - return socket.Pass(); + return socket; } void WaitUntilReadableOrConnectionReset(SbSocket sock) { @@ -76,18 +77,18 @@ void WaitUntilReadableOrConnectionReset(SbSocket sock) { SbSocketWaiterDestroy(waiter); } -scoped_ptr WaitForClientConnection(Socket* listen_sock, +std::unique_ptr WaitForClientConnection(Socket* listen_sock, int64_t timeout) { int64_t expire_time = (timeout >= 0) && (timeout < kSbInt64Max) ? CurrentMonotonicTime() + timeout : kSbInt64Max; while (true) { - scoped_ptr client_connection(listen_sock->Accept()); + std::unique_ptr client_connection(listen_sock->Accept()); if (client_connection) { - return client_connection.Pass(); + return client_connection; } if (CurrentMonotonicTime() > expire_time) { - return scoped_ptr(); + return std::unique_ptr(); } SbThreadSleep(1000); } @@ -112,8 +113,8 @@ std::vector SplitStringByLines(const std::string& string_buff) { const char kNetArgsCommandSwitchWait[] = "net_args_wait_for_connection"; std::vector NetArgsWaitForPayload(int64_t timeout) { - scoped_ptr listen = CreateListenSocket(); - scoped_ptr client_connection = + std::unique_ptr listen = CreateListenSocket(); + std::unique_ptr client_connection = WaitForClientConnection(listen.get(), timeout); if (!client_connection) { SB_LOG(ERROR) << "Timed out waiting for net args."; diff --git a/starboard/shared/starboard/net_log.cc b/starboard/shared/starboard/net_log.cc index 147a70a3bfa3..e8b39d920bec 100644 --- a/starboard/shared/starboard/net_log.cc +++ b/starboard/shared/starboard/net_log.cc @@ -21,6 +21,7 @@ #include #include #include +#include #include "starboard/common/atomic.h" #include "starboard/common/log.h" @@ -67,10 +68,10 @@ using RunFunction = std::function; class FunctionThread : public Thread { public: - static scoped_ptr Create(const std::string& thread_name, + static std::unique_ptr Create(const std::string& thread_name, RunFunction run_function) { - scoped_ptr out(new FunctionThread(thread_name, run_function)); - return out.Pass(); + std::unique_ptr out(new FunctionThread(thread_name, run_function)); + return out; } FunctionThread(const std::string& name, RunFunction run_function) @@ -104,8 +105,8 @@ std::string ToString(SbSocketError error) { return ss.str(); } -scoped_ptr CreateListenSocket() { - scoped_ptr socket( +std::unique_ptr CreateListenSocket() { + std::unique_ptr socket( new Socket(NET_LOG_IP_VERSION, kSbSocketProtocolTcp)); socket->SetReuseAddress(true); SbSocketAddress sock_addr; @@ -127,7 +128,7 @@ scoped_ptr CreateListenSocket() { if (sock_err != kSbSocketOk) { SbLogRawFormatF(kErrFmt, sock_err); } - return socket.Pass(); + return socket; } class BufferedSocketWriter { @@ -255,7 +256,7 @@ class BufferedSocketWriter { // callback will be invoked. class SocketListener { public: - typedef std::function)> Callback; + typedef std::function)> Callback; SocketListener(Socket* listen_socket, Callback cb) : listen_socket_(listen_socket), callback_(cb) { @@ -269,10 +270,10 @@ class SocketListener { private: void Run(Semaphore* joined_sema) { while (!joined_sema->TakeWait(100'000)) { - scoped_ptr client_connection(listen_socket_->Accept()); + std::unique_ptr client_connection(listen_socket_->Accept()); if (client_connection) { - callback_(client_connection.Pass()); + callback_(std::move(client_connection)); break; } } @@ -280,7 +281,7 @@ class SocketListener { Socket* listen_socket_; Callback callback_; - scoped_ptr thread_; + std::unique_ptr thread_; }; class NetLogServer { @@ -311,9 +312,9 @@ class NetLogServer { socket_listener_.reset(new SocketListener(listen_socket_.get(), cb)); } - void OnClientConnect(scoped_ptr client_socket) { + void OnClientConnect(std::unique_ptr client_socket) { ScopedLock lock(socket_mutex_); - client_socket_ = client_socket.Pass(); + client_socket_ = std::move(client_socket); client_socket_->SetSendBufferSize(NET_LOG_SOCKET_BUFFER_SIZE); client_socket_->SetTcpKeepAlive(true, 1'000'000); } @@ -321,7 +322,7 @@ class NetLogServer { // Has a client ever connected? bool HasClientConnected() { ScopedLock lock(socket_mutex_); - return client_socket_; + return client_socket_.get() != nullptr; } void OnLog(const char* msg) { @@ -372,12 +373,12 @@ class NetLogServer { } } - scoped_ptr listen_socket_; - scoped_ptr client_socket_; + std::unique_ptr listen_socket_; + std::unique_ptr client_socket_; Mutex socket_mutex_; - scoped_ptr socket_listener_; - scoped_ptr writer_thread_; + std::unique_ptr socket_listener_; + std::unique_ptr writer_thread_; Semaphore writer_thread_sema_; atomic_bool is_joined_; diff --git a/starboard/shared/starboard/player/filter/adaptive_audio_decoder_internal.h b/starboard/shared/starboard/player/filter/adaptive_audio_decoder_internal.h index 2fc9964f1d50..3b603791fbaf 100644 --- a/starboard/shared/starboard/player/filter/adaptive_audio_decoder_internal.h +++ b/starboard/shared/starboard/player/filter/adaptive_audio_decoder_internal.h @@ -36,7 +36,7 @@ namespace filter { class AdaptiveAudioDecoder : public AudioDecoder, private JobQueue::JobOwner { public: - typedef std::function( + typedef std::function( const media::AudioStreamInfo& audio_stream_info, SbDrmSystem drm_system)> AudioDecoderCreator; @@ -79,9 +79,9 @@ class AdaptiveAudioDecoder : public AudioDecoder, private JobQueue::JobOwner { OutputCB output_cb_ = nullptr; ErrorCB error_cb_ = nullptr; - scoped_ptr audio_decoder_; - scoped_ptr resampler_; - scoped_ptr channel_mixer_; + unique_ptr_alias audio_decoder_; + std::unique_ptr resampler_; + std::unique_ptr channel_mixer_; InputBuffers pending_input_buffers_; ConsumedCB pending_consumed_cb_; std::queue> decoded_audios_; diff --git a/starboard/shared/starboard/player/filter/audio_channel_layout_mixer.h b/starboard/shared/starboard/player/filter/audio_channel_layout_mixer.h index 31da031d97f6..bd75d64fb5f4 100644 --- a/starboard/shared/starboard/player/filter/audio_channel_layout_mixer.h +++ b/starboard/shared/starboard/player/filter/audio_channel_layout_mixer.h @@ -15,6 +15,7 @@ #ifndef STARBOARD_SHARED_STARBOARD_PLAYER_FILTER_AUDIO_CHANNEL_LAYOUT_MIXER_H_ #define STARBOARD_SHARED_STARBOARD_PLAYER_FILTER_AUDIO_CHANNEL_LAYOUT_MIXER_H_ +#include #include #include "starboard/common/ref_counted.h" @@ -38,7 +39,7 @@ class AudioChannelLayoutMixer { virtual scoped_refptr Mix( const scoped_refptr& audio_data) = 0; - static scoped_ptr Create( + static std::unique_ptr Create( SbMediaAudioSampleType sample_type, SbMediaAudioFrameStorageType storage_type, int output_channels); diff --git a/starboard/shared/starboard/player/filter/audio_channel_layout_mixer_impl.cc b/starboard/shared/starboard/player/filter/audio_channel_layout_mixer_impl.cc index f37772035057..032425448e14 100644 --- a/starboard/shared/starboard/player/filter/audio_channel_layout_mixer_impl.cc +++ b/starboard/shared/starboard/player/filter/audio_channel_layout_mixer_impl.cc @@ -388,11 +388,11 @@ AudioChannelLayoutMixerImpl::MixMonoToStereoOptimized( } // namespace // static -scoped_ptr AudioChannelLayoutMixer::Create( +std::unique_ptr AudioChannelLayoutMixer::Create( SbMediaAudioSampleType sample_type, SbMediaAudioFrameStorageType storage_type, int output_channels) { - return scoped_ptr(new AudioChannelLayoutMixerImpl( + return std::unique_ptr(new AudioChannelLayoutMixerImpl( sample_type, storage_type, output_channels)); } diff --git a/starboard/shared/starboard/player/filter/audio_frame_tracker.cc b/starboard/shared/starboard/player/filter/audio_frame_tracker.cc index badce2651d66..da2f58643402 100644 --- a/starboard/shared/starboard/player/filter/audio_frame_tracker.cc +++ b/starboard/shared/starboard/player/filter/audio_frame_tracker.cc @@ -18,7 +18,6 @@ #include "starboard/common/log.h" #include "starboard/common/mutex.h" -#include "starboard/common/scoped_ptr.h" #include "starboard/media.h" #include "starboard/shared/starboard/thread_checker.h" 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 676aad853e97..4b99d91765e7 100644 --- a/starboard/shared/starboard/player/filter/audio_renderer_internal_pcm.cc +++ b/starboard/shared/starboard/player/filter/audio_renderer_internal_pcm.cc @@ -16,6 +16,7 @@ #include #include +#include #include "starboard/common/time.h" #include "starboard/memory.h" @@ -67,8 +68,8 @@ SbMediaAudioSampleType GetSinkAudioSampleType( } // namespace AudioRendererPcm::AudioRendererPcm( - scoped_ptr decoder, - scoped_ptr audio_renderer_sink, + unique_ptr_alias decoder, + unique_ptr_alias audio_renderer_sink, const media::AudioStreamInfo& audio_stream_info, int max_cached_frames, int min_frames_per_append) @@ -79,10 +80,10 @@ AudioRendererPcm::AudioRendererPcm( bytes_per_frame_(media::GetBytesPerSample(sink_sample_type_) * channels_), frame_buffer_(max_cached_frames_ * bytes_per_frame_), frames_consumed_set_at_(CurrentMonotonicTime()), - decoder_(decoder.Pass()), + decoder_(std::move(decoder)), process_audio_data_job_( std::bind(&AudioRendererPcm::ProcessAudioData, this)), - audio_renderer_sink_(audio_renderer_sink.Pass()) { + audio_renderer_sink_(std::move(audio_renderer_sink)) { SB_DLOG(INFO) << "Creating AudioRendererPcm with " << channels_ << " channels, " << bytes_per_frame_ << " bytes per frame, " << max_cached_frames_ << " max cached frames, and " 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 2af3cc1787f4..6d881264de0a 100644 --- a/starboard/shared/starboard/player/filter/audio_renderer_internal_pcm.h +++ b/starboard/shared/starboard/player/filter/audio_renderer_internal_pcm.h @@ -16,6 +16,7 @@ #define STARBOARD_SHARED_STARBOARD_PLAYER_FILTER_AUDIO_RENDERER_INTERNAL_PCM_H_ #include +#include #include #include @@ -66,8 +67,8 @@ class AudioRendererPcm : public AudioRenderer, // longer accept more data. // |min_frames_per_append| is the min number of frames that the audio renderer // tries to append to the sink buffer at once. - AudioRendererPcm(scoped_ptr decoder, - scoped_ptr audio_renderer_sink, + AudioRendererPcm(unique_ptr_alias decoder, + unique_ptr_alias audio_renderer_sink, const media::AudioStreamInfo& audio_stream_info, int max_cached_frames, int min_frames_per_append); @@ -128,7 +129,7 @@ class AudioRendererPcm : public AudioRenderer, int64_t total_frames_consumed_by_sink_ = 0; int32_t frames_consumed_by_sink_since_last_get_current_time_; - scoped_ptr decoder_; + unique_ptr_alias decoder_; int64_t frames_consumed_set_at_; double playback_rate_ = 1.0; @@ -161,7 +162,7 @@ class AudioRendererPcm : public AudioRenderer, const SbMediaAudioSampleType sink_sample_type_; const int bytes_per_frame_; - scoped_ptr resampler_; + std::unique_ptr resampler_; optional decoder_sample_rate_; AudioTimeStretcher time_stretcher_; @@ -181,7 +182,7 @@ class AudioRendererPcm : public AudioRenderer, // and can thus avoid doing a full reset. bool first_input_written_ = false; - scoped_ptr audio_renderer_sink_; + unique_ptr_alias audio_renderer_sink_; bool is_eos_reached_on_sink_thread_ = false; bool is_playing_on_sink_thread_ = false; int64_t frames_in_buffer_on_sink_thread_ = 0; diff --git a/starboard/shared/starboard/player/filter/audio_resampler.h b/starboard/shared/starboard/player/filter/audio_resampler.h index 3aeaa4f7657f..3dded5a9791a 100644 --- a/starboard/shared/starboard/player/filter/audio_resampler.h +++ b/starboard/shared/starboard/player/filter/audio_resampler.h @@ -15,6 +15,8 @@ #ifndef STARBOARD_SHARED_STARBOARD_PLAYER_FILTER_AUDIO_RESAMPLER_H_ #define STARBOARD_SHARED_STARBOARD_PLAYER_FILTER_AUDIO_RESAMPLER_H_ +#include + #include "starboard/common/ref_counted.h" #include "starboard/common/scoped_ptr.h" #include "starboard/media.h" @@ -57,7 +59,7 @@ class AudioResampler { // The |output_cb| will be called whenever there is resampled data ready. It // is always called asynchronously on |job_queue| and then the user of // AudioResampler can call Read() to read the next chunk of resampled data. - static scoped_ptr Create( + static std::unique_ptr Create( SbMediaAudioSampleType source_sample_type, SbMediaAudioFrameStorageType source_storage_type, int source_sample_rate, diff --git a/starboard/shared/starboard/player/filter/audio_resampler_impl.cc b/starboard/shared/starboard/player/filter/audio_resampler_impl.cc index b0fa87466bd6..5592b78629e8 100644 --- a/starboard/shared/starboard/player/filter/audio_resampler_impl.cc +++ b/starboard/shared/starboard/player/filter/audio_resampler_impl.cc @@ -71,7 +71,7 @@ class AudioResamplerImpl : public AudioResampler { } // namespace // static -scoped_ptr AudioResampler::Create( +std::unique_ptr AudioResampler::Create( SbMediaAudioSampleType source_sample_type, SbMediaAudioFrameStorageType source_storage_type, int source_sample_rate, @@ -79,7 +79,7 @@ scoped_ptr AudioResampler::Create( SbMediaAudioFrameStorageType destination_storage_type, int destination_sample_rate, int channels) { - return scoped_ptr(new AudioResamplerImpl( + return std::unique_ptr(new AudioResamplerImpl( source_sample_type, source_storage_type, source_sample_rate, destination_sample_type, destination_storage_type, destination_sample_rate, channels)); diff --git a/starboard/shared/starboard/player/filter/audio_time_stretcher.h b/starboard/shared/starboard/player/filter/audio_time_stretcher.h index 67472062f470..d42053ddc357 100644 --- a/starboard/shared/starboard/player/filter/audio_time_stretcher.h +++ b/starboard/shared/starboard/player/filter/audio_time_stretcher.h @@ -193,11 +193,11 @@ class AudioTimeStretcher { scoped_refptr wsola_output_; // Overlap-and-add window. - scoped_array ola_window_; + std::unique_ptr ola_window_; // Transition window, used to update |optimal_block_| by a weighted sum of // |optimal_block_| and |target_block_|. - scoped_array transition_window_; + std::unique_ptr transition_window_; // Auxiliary variables to avoid allocation in every iteration. diff --git a/starboard/shared/starboard/player/filter/cpu_video_frame.h b/starboard/shared/starboard/player/filter/cpu_video_frame.h index 7da0ee1a7ded..b31f9068d03a 100644 --- a/starboard/shared/starboard/player/filter/cpu_video_frame.h +++ b/starboard/shared/starboard/player/filter/cpu_video_frame.h @@ -15,6 +15,7 @@ #ifndef STARBOARD_SHARED_STARBOARD_PLAYER_FILTER_CPU_VIDEO_FRAME_H_ #define STARBOARD_SHARED_STARBOARD_PLAYER_FILTER_CPU_VIDEO_FRAME_H_ +#include #include #include "starboard/common/ref_counted.h" @@ -84,7 +85,7 @@ class CpuVideoFrame : public VideoFrame { // The following two variables are valid when the frame contains pixel data. std::vector planes_; - scoped_array pixel_buffer_; + std::unique_ptr pixel_buffer_; }; } // namespace filter diff --git a/starboard/shared/starboard/player/filter/filter_based_player_worker_handler.cc b/starboard/shared/starboard/player/filter/filter_based_player_worker_handler.cc index 7273598cb5b1..0ce8116a1d78 100644 --- a/starboard/shared/starboard/player/filter/filter_based_player_worker_handler.cc +++ b/starboard/shared/starboard/player/filter/filter_based_player_worker_handler.cc @@ -115,7 +115,7 @@ HandlerResult FilterBasedPlayerWorkerHandler::Init( update_player_state_cb_ = update_player_state_cb; update_player_error_cb_ = update_player_error_cb; - scoped_ptr factory = + unique_ptr_alias factory = PlayerComponents::Factory::Create(); SB_DCHECK(factory); @@ -518,14 +518,14 @@ void FilterBasedPlayerWorkerHandler::Stop() { RemoveJobByToken(update_job_token_); - scoped_ptr player_components; + unique_ptr_alias player_components; { // Set |player_components_| to null with the lock, but we actually destroy // it outside of the lock. This is because the VideoRenderer destructor // may post a task to destroy the SbDecodeTarget to the same thread that // might call GetCurrentDecodeTarget(), which would try to take this lock. ::starboard::ScopedLock lock(player_components_existence_mutex_); - player_components = player_components_.Pass(); + player_components = std::move(player_components_); media_time_provider_ = nullptr; audio_renderer_ = nullptr; video_renderer_ = nullptr; diff --git a/starboard/shared/starboard/player/filter/filter_based_player_worker_handler.h b/starboard/shared/starboard/player/filter/filter_based_player_worker_handler.h index 4b9df34a5c86..2021d7deee54 100644 --- a/starboard/shared/starboard/player/filter/filter_based_player_worker_handler.h +++ b/starboard/shared/starboard/player/filter/filter_based_player_worker_handler.h @@ -16,6 +16,7 @@ #define STARBOARD_SHARED_STARBOARD_PLAYER_FILTER_FILTER_BASED_PLAYER_WORKER_HANDLER_H_ #include +#include #include #include "starboard/common/scoped_ptr.h" @@ -91,7 +92,7 @@ class FilterBasedPlayerWorkerHandler : public PlayerWorker::Handler, // other accesses are happening from the same thread. Mutex player_components_existence_mutex_; - scoped_ptr player_components_; + unique_ptr_alias player_components_; // The following three variables cache the return values of member functions // of |player_components_|. Their lifetime is tied to |player_components_|. MediaTimeProvider* media_time_provider_ = nullptr; diff --git a/starboard/shared/starboard/player/filter/interleaved_sinc_resampler.h b/starboard/shared/starboard/player/filter/interleaved_sinc_resampler.h index c5cc5bf18d03..edd005602bc5 100644 --- a/starboard/shared/starboard/player/filter/interleaved_sinc_resampler.h +++ b/starboard/shared/starboard/player/filter/interleaved_sinc_resampler.h @@ -20,9 +20,11 @@ #define STARBOARD_SHARED_STARBOARD_PLAYER_FILTER_INTERLEAVED_SINC_RESAMPLER_H_ #include +#include #include #include #include +#include #include "starboard/common/ref_counted.h" #include "starboard/common/scoped_ptr.h" @@ -73,8 +75,8 @@ class InterleavedSincResampler { data_.reset(new float[frames * channel_count]); memcpy(data_.get(), data, frames * channel_count * sizeof(float)); } - Buffer(scoped_array data, int frames) - : data_(data.Pass()), frames_(frames) {} + Buffer(std::unique_ptr data, int frames) + : data_(std::move(data)), frames_(frames) {} const float* GetData() const { return data_.get(); } @@ -84,7 +86,7 @@ class InterleavedSincResampler { private: friend class ::starboard::RefCountedThreadSafe; - scoped_array data_; + std::unique_ptr data_; int frames_ = 0; Buffer(const Buffer&) = delete; diff --git a/starboard/shared/starboard/player/filter/media_time_provider_impl.cc b/starboard/shared/starboard/player/filter/media_time_provider_impl.cc index f9df61a8bf88..fc935d909b7f 100644 --- a/starboard/shared/starboard/player/filter/media_time_provider_impl.cc +++ b/starboard/shared/starboard/player/filter/media_time_provider_impl.cc @@ -14,6 +14,8 @@ #include "starboard/shared/starboard/player/filter/media_time_provider_impl.h" +#include + #include "starboard/common/log.h" namespace starboard { @@ -23,8 +25,8 @@ namespace player { namespace filter { MediaTimeProviderImpl::MediaTimeProviderImpl( - scoped_ptr system_time_provider) - : system_time_provider_(system_time_provider.Pass()) { + std::unique_ptr system_time_provider) + : system_time_provider_(std::move(system_time_provider)) { SB_DCHECK(system_time_provider_); } diff --git a/starboard/shared/starboard/player/filter/media_time_provider_impl.h b/starboard/shared/starboard/player/filter/media_time_provider_impl.h index f783a573b2cc..c800c7edf5c6 100644 --- a/starboard/shared/starboard/player/filter/media_time_provider_impl.h +++ b/starboard/shared/starboard/player/filter/media_time_provider_impl.h @@ -15,6 +15,8 @@ #ifndef STARBOARD_SHARED_STARBOARD_PLAYER_FILTER_MEDIA_TIME_PROVIDER_IMPL_H_ #define STARBOARD_SHARED_STARBOARD_PLAYER_FILTER_MEDIA_TIME_PROVIDER_IMPL_H_ +#include + #include "starboard/common/mutex.h" #include "starboard/common/scoped_ptr.h" #include "starboard/common/time.h" @@ -40,7 +42,7 @@ class MediaTimeProviderImpl : public MediaTimeProvider, }; explicit MediaTimeProviderImpl( - scoped_ptr system_time_provider); + std::unique_ptr system_time_provider); void Play() override; void Pause() override; @@ -58,7 +60,7 @@ class MediaTimeProviderImpl : public MediaTimeProvider, // should handle this properly. int64_t GetCurrentMediaTime_Locked(int64_t* current_time = NULL); - scoped_ptr system_time_provider_; + std::unique_ptr system_time_provider_; Mutex mutex_; diff --git a/starboard/shared/starboard/player/filter/player_components.cc b/starboard/shared/starboard/player/filter/player_components.cc index 3a2fdd8903f9..628adc3b6f83 100644 --- a/starboard/shared/starboard/player/filter/player_components.cc +++ b/starboard/shared/starboard/player/filter/player_components.cc @@ -14,7 +14,8 @@ #include "starboard/shared/starboard/player/filter/player_components.h" -#include "starboard/common/scoped_ptr.h" +#include + #include "starboard/common/time.h" #include "starboard/shared/starboard/application.h" #include "starboard/shared/starboard/command_line.h" @@ -50,12 +51,12 @@ class MonotonicSystemTimeProviderImpl : public MonotonicSystemTimeProvider { class PlayerComponentsImpl : public PlayerComponents { public: - PlayerComponentsImpl(scoped_ptr media_time_provider, - scoped_ptr audio_renderer, - scoped_ptr video_renderer) - : media_time_provider_(media_time_provider.Pass()), - audio_renderer_(audio_renderer.Pass()), - video_renderer_(video_renderer.Pass()) { + PlayerComponentsImpl(std::unique_ptr media_time_provider, + unique_ptr_alias audio_renderer, + unique_ptr_alias video_renderer) + : media_time_provider_(std::move(media_time_provider)), + audio_renderer_(std::move(audio_renderer)), + video_renderer_(std::move(video_renderer)) { SB_DCHECK(media_time_provider_ || audio_renderer_); SB_DCHECK(audio_renderer_ || video_renderer_); } @@ -70,9 +71,9 @@ class PlayerComponentsImpl : public PlayerComponents { private: // |media_time_provider_| will only be used when |audio_renderer_| is nullptr. - scoped_ptr media_time_provider_; - scoped_ptr audio_renderer_; - scoped_ptr video_renderer_; + std::unique_ptr media_time_provider_; + unique_ptr_alias audio_renderer_; + unique_ptr_alias video_renderer_; }; int AlignUp(int value, int alignment) { @@ -141,17 +142,17 @@ PlayerComponents::Factory::CreationParameters::CreationParameters( this->drm_system_ = that.drm_system_; } -scoped_ptr PlayerComponents::Factory::CreateComponents( +unique_ptr_alias PlayerComponents::Factory::CreateComponents( const CreationParameters& creation_parameters, std::string* error_message) { SB_DCHECK(creation_parameters.audio_codec() != kSbMediaAudioCodecNone || creation_parameters.video_codec() != kSbMediaVideoCodecNone); SB_DCHECK(error_message); - scoped_ptr audio_decoder; - scoped_ptr audio_renderer_sink; - scoped_ptr video_decoder; - scoped_ptr video_render_algorithm; + unique_ptr_alias audio_decoder; + unique_ptr_alias audio_renderer_sink; + unique_ptr_alias video_decoder; + unique_ptr_alias video_render_algorithm; scoped_refptr video_renderer_sink; auto command_line = shared::starboard::Application::Get()->GetCommandLine(); @@ -176,7 +177,7 @@ scoped_ptr PlayerComponents::Factory::CreateComponents( &audio_renderer_sink, &video_decoder, &video_render_algorithm, &video_renderer_sink, error_message)) { - return scoped_ptr(); + return unique_ptr_alias(); } if (use_stub_audio_decoder) { SB_DCHECK(!audio_decoder); @@ -192,9 +193,9 @@ scoped_ptr PlayerComponents::Factory::CreateComponents( } } - scoped_ptr media_time_provider_impl; - scoped_ptr audio_renderer; - scoped_ptr video_renderer; + std::unique_ptr media_time_provider_impl; + unique_ptr_alias audio_renderer; + unique_ptr_alias video_renderer; if (creation_parameters.audio_codec() != kSbMediaAudioCodecNone) { SB_DCHECK(audio_decoder); @@ -205,7 +206,7 @@ scoped_ptr PlayerComponents::Factory::CreateComponents( &min_frames_per_append); audio_renderer.reset( - new AudioRendererPcm(audio_decoder.Pass(), audio_renderer_sink.Pass(), + new AudioRendererPcm(std::move(audio_decoder), std::move(audio_renderer_sink), creation_parameters.audio_stream_info(), max_cached_frames, min_frames_per_append)); } @@ -219,31 +220,31 @@ scoped_ptr PlayerComponents::Factory::CreateComponents( media_time_provider = audio_renderer.get(); } else { media_time_provider_impl.reset( - new MediaTimeProviderImpl(scoped_ptr( + new MediaTimeProviderImpl(std::unique_ptr( new MonotonicSystemTimeProviderImpl))); media_time_provider = media_time_provider_impl.get(); } video_renderer.reset(new VideoRendererImpl( - video_decoder.Pass(), media_time_provider, - video_render_algorithm.Pass(), video_renderer_sink)); + std::move(video_decoder), media_time_provider, + std::move(video_render_algorithm), video_renderer_sink)); } SB_DCHECK(audio_renderer || video_renderer); - return scoped_ptr( - new PlayerComponentsImpl(media_time_provider_impl.Pass(), - audio_renderer.Pass(), video_renderer.Pass())); + return unique_ptr_alias( + new PlayerComponentsImpl(std::move(media_time_provider_impl), + std::move(audio_renderer), std::move(video_renderer))); } void PlayerComponents::Factory::CreateStubAudioComponents( const CreationParameters& creation_parameters, - scoped_ptr* audio_decoder, - scoped_ptr* audio_renderer_sink) { + unique_ptr_alias* audio_decoder, + unique_ptr_alias* audio_renderer_sink) { SB_DCHECK(audio_decoder); SB_DCHECK(audio_renderer_sink); auto decoder_creator = [](const media::AudioStreamInfo& audio_stream_info, SbDrmSystem drm_system) { - return scoped_ptr(new StubAudioDecoder(audio_stream_info)); + return unique_ptr_alias(new StubAudioDecoder(audio_stream_info)); }; audio_decoder->reset(new AdaptiveAudioDecoder( creation_parameters.audio_stream_info(), creation_parameters.drm_system(), @@ -253,8 +254,8 @@ void PlayerComponents::Factory::CreateStubAudioComponents( void PlayerComponents::Factory::CreateStubVideoComponents( const CreationParameters& creation_parameters, - scoped_ptr* video_decoder, - scoped_ptr* video_render_algorithm, + unique_ptr_alias* video_decoder, + unique_ptr_alias* video_render_algorithm, scoped_refptr* video_renderer_sink) { const int64_t kVideoSinkRenderIntervalUsec = 10'000; // 10ms diff --git a/starboard/shared/starboard/player/filter/player_components.h b/starboard/shared/starboard/player/filter/player_components.h index 4990ec47bd03..1c3e9133f872 100644 --- a/starboard/shared/starboard/player/filter/player_components.h +++ b/starboard/shared/starboard/player/filter/player_components.h @@ -15,6 +15,7 @@ #ifndef STARBOARD_SHARED_STARBOARD_PLAYER_FILTER_PLAYER_COMPONENTS_H_ #define STARBOARD_SHARED_STARBOARD_PLAYER_FILTER_PLAYER_COMPONENTS_H_ +#include #include #include @@ -154,7 +155,7 @@ class PlayerComponents { // TODO: Consider making it return Factory*. // Individual platform should implement this function to allow the creation // of a Factory instance. - static scoped_ptr Create(); + static unique_ptr_alias Create(); // Individual implementations must implement this function to indicate which // output modes they support. @@ -162,7 +163,7 @@ class PlayerComponents { SbMediaVideoCodec codec, SbDrmSystem drm_system); - virtual scoped_ptr CreateComponents( + virtual unique_ptr_alias CreateComponents( const CreationParameters& creation_parameters, std::string* error_message); @@ -174,10 +175,10 @@ class PlayerComponents { // unit tests to run. virtual bool CreateSubComponents( const CreationParameters& creation_parameters, - scoped_ptr* audio_decoder, - scoped_ptr* audio_renderer_sink, - scoped_ptr* video_decoder, - scoped_ptr* video_render_algorithm, + unique_ptr_alias* audio_decoder, + unique_ptr_alias* audio_renderer_sink, + unique_ptr_alias* video_decoder, + unique_ptr_alias* video_render_algorithm, scoped_refptr* video_renderer_sink, std::string* error_message) = 0; @@ -186,13 +187,13 @@ class PlayerComponents { void CreateStubAudioComponents( const CreationParameters& creation_parameters, - scoped_ptr* audio_decoder, - scoped_ptr* audio_renderer_sink); + unique_ptr_alias* audio_decoder, + unique_ptr_alias* audio_renderer_sink); void CreateStubVideoComponents( const CreationParameters& creation_parameters, - scoped_ptr* video_decoder, - scoped_ptr* video_render_algorithm, + unique_ptr_alias* video_decoder, + unique_ptr_alias* video_render_algorithm, scoped_refptr* video_renderer_sink); // Check AudioRenderer ctor for more details on the parameters. diff --git a/starboard/shared/starboard/player/filter/stub_audio_decoder.h b/starboard/shared/starboard/player/filter/stub_audio_decoder.h index 347c23ed5e5a..b43121d04efa 100644 --- a/starboard/shared/starboard/player/filter/stub_audio_decoder.h +++ b/starboard/shared/starboard/player/filter/stub_audio_decoder.h @@ -58,7 +58,7 @@ class StubAudioDecoder : public AudioDecoder, private JobQueue::JobOwner { OutputCB output_cb_; ErrorCB error_cb_; - scoped_ptr decoder_thread_; + std::unique_ptr decoder_thread_; Mutex decoded_audios_mutex_; std::queue > decoded_audios_; scoped_refptr last_input_buffer_; diff --git a/starboard/shared/starboard/player/filter/stub_player_components_factory.cc b/starboard/shared/starboard/player/filter/stub_player_components_factory.cc index f916ac44eac1..93f0ee5a5f8c 100644 --- a/starboard/shared/starboard/player/filter/stub_player_components_factory.cc +++ b/starboard/shared/starboard/player/filter/stub_player_components_factory.cc @@ -23,8 +23,8 @@ namespace player { namespace filter { // static -scoped_ptr StubPlayerComponentsFactory::Create() { - return make_scoped_ptr( +unique_ptr_alias StubPlayerComponentsFactory::Create() { + return unique_ptr_alias( new StubPlayerComponentsFactory); } diff --git a/starboard/shared/starboard/player/filter/stub_player_components_factory.h b/starboard/shared/starboard/player/filter/stub_player_components_factory.h index 5753f273cdb3..f662ae8df6d3 100644 --- a/starboard/shared/starboard/player/filter/stub_player_components_factory.h +++ b/starboard/shared/starboard/player/filter/stub_player_components_factory.h @@ -28,14 +28,14 @@ namespace filter { class StubPlayerComponentsFactory : public PlayerComponents::Factory { public: - static scoped_ptr Create(); + static unique_ptr_alias Create(); bool CreateSubComponents( const CreationParameters& creation_parameters, - scoped_ptr* audio_decoder, - scoped_ptr* audio_renderer_sink, - scoped_ptr* video_decoder, - scoped_ptr* video_render_algorithm, + unique_ptr_alias* audio_decoder, + unique_ptr_alias* audio_renderer_sink, + unique_ptr_alias* video_decoder, + unique_ptr_alias* video_render_algorithm, scoped_refptr* video_renderer_sink, std::string* error_message) override { SB_DCHECK(error_message); diff --git a/starboard/shared/starboard/player/filter/stub_video_decoder.h b/starboard/shared/starboard/player/filter/stub_video_decoder.h index 513a49ec6942..f5833ff430ad 100644 --- a/starboard/shared/starboard/player/filter/stub_video_decoder.h +++ b/starboard/shared/starboard/player/filter/stub_video_decoder.h @@ -55,7 +55,7 @@ class StubVideoDecoder : public VideoDecoder, private JobQueue::JobOwner { DecoderStatusCB decoder_status_cb_; media::VideoStreamInfo video_stream_info_; - scoped_ptr decoder_thread_; + std::unique_ptr decoder_thread_; // std::set<> keeps frame timestamps sorted in ascending order. std::set output_frame_timestamps_; // Used to determine when to send kBufferFull in DecodeOneBuffer(). 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 fd31dc6f80be..3be9b8535800 100644 --- a/starboard/shared/starboard/player/filter/video_renderer_internal_impl.cc +++ b/starboard/shared/starboard/player/filter/video_renderer_internal_impl.cc @@ -16,6 +16,7 @@ #include #include +#include #include "starboard/common/time.h" @@ -34,14 +35,14 @@ const int64_t kSeekTimeoutRetryInterval = 25'000; // 25ms } // namespace -VideoRendererImpl::VideoRendererImpl(scoped_ptr decoder, +VideoRendererImpl::VideoRendererImpl(unique_ptr_alias decoder, MediaTimeProvider* media_time_provider, - scoped_ptr algorithm, + unique_ptr_alias algorithm, scoped_refptr sink) : media_time_provider_(media_time_provider), - algorithm_(algorithm.Pass()), + algorithm_(std::move(algorithm)), sink_(sink), - decoder_(decoder.Pass()), + decoder_(std::move(decoder)), end_of_stream_written_(false), ended_cb_called_(false), need_more_input_(true), 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 c292b0c59f5f..bc7ff00bb837 100644 --- a/starboard/shared/starboard/player/filter/video_renderer_internal_impl.h +++ b/starboard/shared/starboard/player/filter/video_renderer_internal_impl.h @@ -16,6 +16,7 @@ #define STARBOARD_SHARED_STARBOARD_PLAYER_FILTER_VIDEO_RENDERER_INTERNAL_IMPL_H_ #include +#include #include "starboard/common/atomic.h" #include "starboard/common/log.h" @@ -46,9 +47,9 @@ class VideoRendererImpl : public VideoRenderer, private JobQueue::JobOwner { public: // All of the functions are called on the PlayerWorker thread unless marked // otherwise. - VideoRendererImpl(scoped_ptr decoder, + VideoRendererImpl(unique_ptr_alias decoder, MediaTimeProvider* media_time_provider, - scoped_ptr algorithm, + unique_ptr_alias algorithm, scoped_refptr sink); ~VideoRendererImpl() override; @@ -84,9 +85,9 @@ class VideoRendererImpl : public VideoRenderer, private JobQueue::JobOwner { void OnSeekTimeout(); MediaTimeProvider* const media_time_provider_; - scoped_ptr algorithm_; + unique_ptr_alias algorithm_; scoped_refptr sink_; - scoped_ptr decoder_; + unique_ptr_alias decoder_; PrerolledCB prerolled_cb_; EndedCB ended_cb_; diff --git a/starboard/shared/starboard/player/filter/wsola_internal.cc b/starboard/shared/starboard/player/filter/wsola_internal.cc index ad4e1bf9243c..bae7adb65d99 100644 --- a/starboard/shared/starboard/player/filter/wsola_internal.cc +++ b/starboard/shared/starboard/player/filter/wsola_internal.cc @@ -30,7 +30,6 @@ #include #include "starboard/common/log.h" -#include "starboard/common/scoped_ptr.h" #include "starboard/memory.h" #if SB_IS(ARCH_X86) || SB_IS(ARCH_X64) @@ -196,7 +195,7 @@ int DecimatedSearch(int decimation, int channels = search_segment->channels(); int block_size = target_block->frames(); int num_candidate_blocks = search_segment->frames() - (block_size - 1); - scoped_array dot_prod(new float[channels]); + std::unique_ptr dot_prod(new float[channels]); float similarity[3]; // Three elements for cubic interpolation. int n = 0; @@ -275,7 +274,7 @@ int FullSearch(int low_limit, const float* energy_candidate_blocks) { int channels = search_block->channels(); int block_size = target_block->frames(); - scoped_array dot_prod(new float[channels]); + std::unique_ptr dot_prod(new float[channels]); float best_similarity = std::numeric_limits::min(); int optimal_index = 0; @@ -321,8 +320,8 @@ int OptimalIndex(const scoped_refptr& search_block, // heuristically based on experiments. const int kSearchDecimation = 5; - scoped_array energy_target_block(new float[channels]); - scoped_array energy_candidate_blocks( + std::unique_ptr energy_target_block(new float[channels]); + std::unique_ptr energy_candidate_blocks( new float[channels * num_candidate_blocks]); // Energy of all candid frames. diff --git a/starboard/shared/starboard/player/job_thread.h b/starboard/shared/starboard/player/job_thread.h index 2ad61b465d71..2e4fd268009e 100644 --- a/starboard/shared/starboard/player/job_thread.h +++ b/starboard/shared/starboard/player/job_thread.h @@ -88,7 +88,7 @@ class JobThread { void RunLoop(); SbThread thread_; - scoped_ptr job_queue_; + std::unique_ptr job_queue_; }; } // namespace player diff --git a/starboard/shared/starboard/player/player_create.cc b/starboard/shared/starboard/player/player_create.cc index 1e16806db637..d3f721aa1463 100644 --- a/starboard/shared/starboard/player/player_create.cc +++ b/starboard/shared/starboard/player/player_create.cc @@ -13,6 +13,7 @@ // limitations under the License. #include +#include #include "starboard/player.h" @@ -210,12 +211,12 @@ SbPlayer SbPlayerCreate(SbWindow window, UpdateActiveSessionPlatformPlaybackState(kPlaying); - starboard::scoped_ptr handler( + starboard::unique_ptr_alias handler( new FilterBasedPlayerWorkerHandler(creation_param, provider)); SbPlayer player = SbPlayerPrivate::CreateInstance( audio_codec, video_codec, sample_deallocate_func, decoder_status_func, - player_status_func, player_error_func, context, handler.Pass()); + player_status_func, player_error_func, context, std::move(handler)); #if SB_PLAYER_ENABLE_VIDEO_DUMPER using ::starboard::shared::starboard::player::video_dmp::VideoDmpWriter; diff --git a/starboard/shared/starboard/player/player_internal.cc b/starboard/shared/starboard/player/player_internal.cc index 4e67ee0161d6..8dcd52133c97 100644 --- a/starboard/shared/starboard/player/player_internal.cc +++ b/starboard/shared/starboard/player/player_internal.cc @@ -51,12 +51,12 @@ SbPlayerPrivate::SbPlayerPrivate( SbPlayerStatusFunc player_status_func, SbPlayerErrorFunc player_error_func, void* context, - starboard::scoped_ptr player_worker_handler) + starboard::unique_ptr_alias player_worker_handler) : sample_deallocate_func_(sample_deallocate_func), context_(context), media_time_updated_at_(starboard::CurrentMonotonicTime()) { - worker_ = starboard::make_scoped_ptr(PlayerWorker::CreateInstance( - audio_codec, video_codec, player_worker_handler.Pass(), + worker_ = std::unique_ptr(PlayerWorker::CreateInstance( + audio_codec, video_codec, std::move(player_worker_handler), std::bind(&SbPlayerPrivate::UpdateMediaInfo, this, _1, _2, _3, _4), decoder_status_func, player_status_func, player_error_func, this, context)); @@ -75,11 +75,11 @@ SbPlayerPrivate* SbPlayerPrivate::CreateInstance( SbPlayerStatusFunc player_status_func, SbPlayerErrorFunc player_error_func, void* context, - starboard::scoped_ptr player_worker_handler) { + starboard::unique_ptr_alias player_worker_handler) { SbPlayerPrivate* ret = new SbPlayerPrivate( audio_codec, video_codec, sample_deallocate_func, decoder_status_func, player_status_func, player_error_func, context, - player_worker_handler.Pass()); + std::move(player_worker_handler)); if (ret && ret->worker_) { return ret; diff --git a/starboard/shared/starboard/player/player_internal.h b/starboard/shared/starboard/player/player_internal.h index 8f036b5b0b48..e78a68ead088 100644 --- a/starboard/shared/starboard/player/player_internal.h +++ b/starboard/shared/starboard/player/player_internal.h @@ -45,7 +45,7 @@ struct SbPlayerPrivate { SbPlayerStatusFunc player_status_func, SbPlayerErrorFunc player_error_func, void* context, - starboard::scoped_ptr player_worker_handler); + starboard::unique_ptr_alias player_worker_handler); void Seek(int64_t seek_to_time, int ticket); template @@ -83,7 +83,7 @@ struct SbPlayerPrivate { SbPlayerStatusFunc player_status_func, SbPlayerErrorFunc player_error_func, void* context, - starboard::scoped_ptr player_worker_handler); + starboard::unique_ptr_alias player_worker_handler); SbPlayerPrivate(const SbPlayerPrivate&) = delete; SbPlayerPrivate& operator=(const SbPlayerPrivate&) = delete; @@ -111,7 +111,7 @@ struct SbPlayerPrivate { // we may extrapolate the media time in GetInfo(). bool is_progressing_ = false; - starboard::scoped_ptr worker_; + std::unique_ptr worker_; starboard::Mutex audio_configurations_mutex_; std::vector audio_configurations_; diff --git a/starboard/shared/starboard/player/player_worker.cc b/starboard/shared/starboard/player/player_worker.cc index bc2cdb3e549b..72b1b68cb40a 100644 --- a/starboard/shared/starboard/player/player_worker.cc +++ b/starboard/shared/starboard/player/player_worker.cc @@ -15,6 +15,7 @@ #include "starboard/shared/starboard/player/player_worker.h" #include +#include #include "starboard/common/condition_variable.h" #include "starboard/common/instance_counter.h" @@ -64,7 +65,7 @@ struct ThreadParam { PlayerWorker* PlayerWorker::CreateInstance( SbMediaAudioCodec audio_codec, SbMediaVideoCodec video_codec, - scoped_ptr handler, + unique_ptr_alias handler, UpdateMediaInfoCB update_media_info_cb, SbPlayerDecoderStatusFunc decoder_status_func, SbPlayerStatusFunc player_status_func, @@ -72,7 +73,7 @@ PlayerWorker* PlayerWorker::CreateInstance( SbPlayer player, void* context) { PlayerWorker* ret = - new PlayerWorker(audio_codec, video_codec, handler.Pass(), + new PlayerWorker(audio_codec, video_codec, std::move(handler), update_media_info_cb, decoder_status_func, player_status_func, player_error_func, player, context); @@ -99,7 +100,7 @@ PlayerWorker::~PlayerWorker() { PlayerWorker::PlayerWorker(SbMediaAudioCodec audio_codec, SbMediaVideoCodec video_codec, - scoped_ptr handler, + unique_ptr_alias handler, UpdateMediaInfoCB update_media_info_cb, SbPlayerDecoderStatusFunc decoder_status_func, SbPlayerStatusFunc player_status_func, @@ -109,7 +110,7 @@ PlayerWorker::PlayerWorker(SbMediaAudioCodec audio_codec, : thread_(kSbThreadInvalid), audio_codec_(audio_codec), video_codec_(video_codec), - handler_(handler.Pass()), + handler_(std::move(handler)), update_media_info_cb_(update_media_info_cb), decoder_status_func_(decoder_status_func), player_status_func_(player_status_func), diff --git a/starboard/shared/starboard/player/player_worker.h b/starboard/shared/starboard/player/player_worker.h index 9b48f1bea20e..8ba7279a5b88 100644 --- a/starboard/shared/starboard/player/player_worker.h +++ b/starboard/shared/starboard/player/player_worker.h @@ -120,7 +120,7 @@ class PlayerWorker { static PlayerWorker* CreateInstance( SbMediaAudioCodec audio_codec, SbMediaVideoCodec video_codec, - scoped_ptr handler, + unique_ptr_alias handler, UpdateMediaInfoCB update_media_info_cb, SbPlayerDecoderStatusFunc decoder_status_func, SbPlayerStatusFunc player_status_func, @@ -181,7 +181,7 @@ class PlayerWorker { private: PlayerWorker(SbMediaAudioCodec audio_codec, SbMediaVideoCodec video_codec, - scoped_ptr handler, + unique_ptr_alias handler, UpdateMediaInfoCB update_media_info_cb, SbPlayerDecoderStatusFunc decoder_status_func, SbPlayerStatusFunc player_status_func, @@ -216,11 +216,11 @@ class PlayerWorker { void UpdateDecoderState(SbMediaType type, SbPlayerDecoderState state); SbThread thread_; - scoped_ptr job_queue_; + std::unique_ptr job_queue_; SbMediaAudioCodec audio_codec_; SbMediaVideoCodec video_codec_; - scoped_ptr handler_; + unique_ptr_alias handler_; UpdateMediaInfoCB update_media_info_cb_; SbPlayerDecoderStatusFunc decoder_status_func_;