Skip to content

Commit

Permalink
[raspi] Switch from scoped_ptr to std::unique_ptr (#3680)
Browse files Browse the repository at this point in the history
Test-On-Device: True
b/291356560
  • Loading branch information
alexanderbobrovnik authored Jun 26, 2024
1 parent f88ff28 commit 7ad546e
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 22 deletions.
5 changes: 2 additions & 3 deletions starboard/raspi/shared/application_dispmanx.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

#include <memory>

#include "starboard/common/scoped_ptr.h"
#include "starboard/configuration.h"
#include "starboard/raspi/shared/dispmanx_util.h"
#include "starboard/shared/internal_only.h"
Expand Down Expand Up @@ -85,10 +84,10 @@ class ApplicationDispmanx
void ShutdownDispmanx();

// The DISPMANX display.
scoped_ptr<DispmanxDisplay> display_;
std::unique_ptr<DispmanxDisplay> display_;

// DISPMANX helper to render video frames.
scoped_ptr<DispmanxVideoRenderer> video_renderer_;
std::unique_ptr<DispmanxVideoRenderer> video_renderer_;

// The single open window, if any.
SbWindow window_;
Expand Down
2 changes: 2 additions & 0 deletions starboard/raspi/shared/configuration_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#ifndef STARBOARD_RASPI_SHARED_CONFIGURATION_PUBLIC_H_
#define STARBOARD_RASPI_SHARED_CONFIGURATION_PUBLIC_H_

#define DEPRECATED_SCOPED_PTR

// --- System Header Configuration -------------------------------------------

// Any system headers listed here that are not provided by the platform will be
Expand Down
5 changes: 2 additions & 3 deletions starboard/raspi/shared/dispmanx_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include <utility>

#include "starboard/common/scoped_ptr.h"
#include "starboard/memory.h"

namespace starboard {
Expand Down Expand Up @@ -93,7 +92,7 @@ void DispmanxYUV420Resource::WriteData(const void* data) {
}

void DispmanxYUV420Resource::ClearWithBlack() {
scoped_array<uint8_t> data(new uint8_t[width() * height() * 3 / 2]);
std::unique_ptr<uint8_t[]> data(new uint8_t[width() * height() * 3 / 2]);
memset(data.get(), 0, width() * height());
memset(data.get() + width() * height(), 0x80, width() * height() / 2);
WriteData(data.get());
Expand All @@ -110,7 +109,7 @@ void DispmanxRGB565Resource::WriteData(const void* data) {
}

void DispmanxRGB565Resource::ClearWithBlack() {
scoped_array<uint8_t> data(new uint8_t[width() * height() * 2]);
std::unique_ptr<uint8_t[]> data(new uint8_t[width() * height() * 2]);
memset(data.get(), 0, width() * height() * 2);
WriteData(data.get());
}
Expand Down
4 changes: 2 additions & 2 deletions starboard/raspi/shared/dispmanx_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
#include <bcm_host.h>

#include <functional>
#include <memory>

#include "starboard/common/log.h"
#include "starboard/common/scoped_ptr.h"
#include "starboard/configuration.h"
#include "starboard/shared/internal_only.h"
#include "starboard/shared/starboard/player/filter/video_frame_internal.h"
Expand Down Expand Up @@ -177,7 +177,7 @@ class DispmanxVideoRenderer {
void ShowElement();

private:
scoped_ptr<DispmanxElement> element_;
std::unique_ptr<DispmanxElement> element_;
scoped_refptr<VideoFrame> frame_;
// Value of |frame_| when HideElement() gets called.
scoped_refptr<VideoFrame> hidden_frame_;
Expand Down
24 changes: 12 additions & 12 deletions starboard/raspi/shared/player_components_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// limitations under the License.

#include "starboard/common/ref_counted.h"
#include "starboard/common/scoped_ptr.h"
#include "starboard/raspi/shared/open_max/video_decoder.h"
#include "starboard/raspi/shared/video_renderer_sink_impl.h"
#include "starboard/shared/ffmpeg/ffmpeg_audio_decoder.h"
Expand All @@ -39,10 +38,10 @@ namespace {
class PlayerComponentsFactory : public PlayerComponents::Factory {
bool CreateSubComponents(
const CreationParameters& creation_parameters,
scoped_ptr<AudioDecoder>* audio_decoder,
scoped_ptr<AudioRendererSink>* audio_renderer_sink,
scoped_ptr<VideoDecoder>* video_decoder,
scoped_ptr<VideoRenderAlgorithm>* video_render_algorithm,
std::unique_ptr<AudioDecoder>* audio_decoder,
std::unique_ptr<AudioRendererSink>* audio_renderer_sink,
std::unique_ptr<VideoDecoder>* video_decoder,
std::unique_ptr<VideoRenderAlgorithm>* video_render_algorithm,
scoped_refptr<VideoRendererSink>* video_renderer_sink,
std::string* error_message) override {
SB_DCHECK(error_message);
Expand All @@ -58,19 +57,20 @@ class PlayerComponentsFactory : public PlayerComponents::Factory {
OpusAudioDecoderImpl;

if (audio_stream_info.codec == kSbMediaAudioCodecOpus) {
scoped_ptr<OpusAudioDecoderImpl> opus_audio_decoder_impl(
std::unique_ptr<OpusAudioDecoderImpl> opus_audio_decoder_impl(
new OpusAudioDecoderImpl(audio_stream_info));
if (opus_audio_decoder_impl && opus_audio_decoder_impl->is_valid()) {
return opus_audio_decoder_impl.PassAs<AudioDecoder>();
return std::unique_ptr<AudioDecoder>(
std::move(opus_audio_decoder_impl));
}
} else {
scoped_ptr<AudioDecoderImpl> audio_decoder_impl(
std::unique_ptr<AudioDecoderImpl> audio_decoder_impl(
AudioDecoderImpl::Create(audio_stream_info));
if (audio_decoder_impl && audio_decoder_impl->is_valid()) {
return audio_decoder_impl.PassAs<AudioDecoder>();
return std::unique_ptr<AudioDecoder>(std::move(audio_decoder_impl));
}
}
return scoped_ptr<AudioDecoder>();
return std::unique_ptr<AudioDecoder>();
};

audio_decoder->reset(new AdaptiveAudioDecoder(
Expand Down Expand Up @@ -102,8 +102,8 @@ class PlayerComponentsFactory : public PlayerComponents::Factory {
} // namespace

// static
scoped_ptr<PlayerComponents::Factory> PlayerComponents::Factory::Create() {
return make_scoped_ptr<PlayerComponents::Factory>(
std::unique_ptr<PlayerComponents::Factory> PlayerComponents::Factory::Create() {
return std::unique_ptr<PlayerComponents::Factory>(
new PlayerComponentsFactory);
}

Expand Down
5 changes: 3 additions & 2 deletions starboard/raspi/shared/window_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

#include <EGL/egl.h>

#include "starboard/common/scoped_ptr.h"
#include <memory>

#include "starboard/raspi/shared/dispmanx_util.h"
#include "starboard/shared/internal_only.h"
#include "starboard/window.h"
Expand All @@ -27,7 +28,7 @@ struct SbWindowPrivate {
const SbWindowOptions* options);
~SbWindowPrivate();

starboard::scoped_ptr<starboard::raspi::shared::DispmanxElement> element;
std::unique_ptr<starboard::raspi::shared::DispmanxElement> element;
EGL_DISPMANX_WINDOW_T window;
};

Expand Down

0 comments on commit 7ad546e

Please sign in to comment.