From 3c6765e87c78d151712f7c74859fad91b27db4a5 Mon Sep 17 00:00:00 2001 From: zhupengfei Date: Tue, 28 Jan 2020 22:19:36 +0800 Subject: [PATCH] core: Properly std::move things around --- src/audio_core/dsp_interface.cpp | 6 +++--- src/audio_core/dsp_interface.h | 2 +- src/audio_core/hle/hle.cpp | 2 +- src/audio_core/lle/lle.cpp | 3 ++- src/core/dumping/backend.h | 8 ++++---- src/core/dumping/ffmpeg_backend.cpp | 4 ++-- src/core/dumping/ffmpeg_backend.h | 4 ++-- src/video_core/renderer_opengl/frame_dumper_opengl.cpp | 2 +- 8 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/audio_core/dsp_interface.cpp b/src/audio_core/dsp_interface.cpp index b6e74b82c..1bb2a1d34 100644 --- a/src/audio_core/dsp_interface.cpp +++ b/src/audio_core/dsp_interface.cpp @@ -38,14 +38,14 @@ void DspInterface::EnableStretching(bool enable) { perform_time_stretching = enable; } -void DspInterface::OutputFrame(StereoFrame16& frame) { +void DspInterface::OutputFrame(StereoFrame16 frame) { if (!sink) return; fifo.Push(frame.data(), frame.size()); if (Core::System::GetInstance().VideoDumper().IsDumping()) { - Core::System::GetInstance().VideoDumper().AddAudioFrame(frame); + Core::System::GetInstance().VideoDumper().AddAudioFrame(std::move(frame)); } } @@ -56,7 +56,7 @@ void DspInterface::OutputSample(std::array sample) { fifo.Push(&sample, 1); if (Core::System::GetInstance().VideoDumper().IsDumping()) { - Core::System::GetInstance().VideoDumper().AddAudioSample(sample); + Core::System::GetInstance().VideoDumper().AddAudioSample(std::move(sample)); } } diff --git a/src/audio_core/dsp_interface.h b/src/audio_core/dsp_interface.h index fc3d7cab2..5b83e684d 100644 --- a/src/audio_core/dsp_interface.h +++ b/src/audio_core/dsp_interface.h @@ -100,7 +100,7 @@ public: void EnableStretching(bool enable); protected: - void OutputFrame(StereoFrame16& frame); + void OutputFrame(StereoFrame16 frame); void OutputSample(std::array sample); private: diff --git a/src/audio_core/hle/hle.cpp b/src/audio_core/hle/hle.cpp index 052e507c5..9c79a7537 100644 --- a/src/audio_core/hle/hle.cpp +++ b/src/audio_core/hle/hle.cpp @@ -400,7 +400,7 @@ bool DspHle::Impl::Tick() { // shared memory region) current_frame = GenerateCurrentFrame(); - parent.OutputFrame(current_frame); + parent.OutputFrame(std::move(current_frame)); return true; } diff --git a/src/audio_core/lle/lle.cpp b/src/audio_core/lle/lle.cpp index e9948d1c2..0121bae27 100644 --- a/src/audio_core/lle/lle.cpp +++ b/src/audio_core/lle/lle.cpp @@ -483,7 +483,8 @@ DspLle::DspLle(Memory::MemorySystem& memory, bool multithread) *memory.GetFCRAMPointer(address - Memory::FCRAM_PADDR) = value; }; impl->teakra.SetAHBMCallback(ahbm); - impl->teakra.SetAudioCallback([this](std::array sample) { OutputSample(sample); }); + impl->teakra.SetAudioCallback( + [this](std::array sample) { OutputSample(std::move(sample)); }); } DspLle::~DspLle() = default; diff --git a/src/core/dumping/backend.h b/src/core/dumping/backend.h index c2a4d532a..3dc89082c 100644 --- a/src/core/dumping/backend.h +++ b/src/core/dumping/backend.h @@ -30,8 +30,8 @@ public: virtual ~Backend(); virtual bool StartDumping(const std::string& path, const std::string& format, const Layout::FramebufferLayout& layout) = 0; - virtual void AddVideoFrame(const VideoFrame& frame) = 0; - virtual void AddAudioFrame(const AudioCore::StereoFrame16& frame) = 0; + virtual void AddVideoFrame(VideoFrame frame) = 0; + virtual void AddAudioFrame(AudioCore::StereoFrame16 frame) = 0; virtual void AddAudioSample(const std::array& sample) = 0; virtual void StopDumping() = 0; virtual bool IsDumping() const = 0; @@ -45,8 +45,8 @@ public: const Layout::FramebufferLayout& /*layout*/) override { return false; } - void AddVideoFrame(const VideoFrame& /*frame*/) override {} - void AddAudioFrame(const AudioCore::StereoFrame16& /*frame*/) override {} + void AddVideoFrame(VideoFrame /*frame*/) override {} + void AddAudioFrame(AudioCore::StereoFrame16 /*frame*/) override {} void AddAudioSample(const std::array& /*sample*/) override {} void StopDumping() override {} bool IsDumping() const override { diff --git a/src/core/dumping/ffmpeg_backend.cpp b/src/core/dumping/ffmpeg_backend.cpp index 811a5c99b..9becaff7b 100644 --- a/src/core/dumping/ffmpeg_backend.cpp +++ b/src/core/dumping/ffmpeg_backend.cpp @@ -450,13 +450,13 @@ bool FFmpegBackend::StartDumping(const std::string& path, const std::string& for return true; } -void FFmpegBackend::AddVideoFrame(const VideoFrame& frame) { +void FFmpegBackend::AddVideoFrame(VideoFrame frame) { event1.Wait(); video_frame_buffers[next_buffer] = std::move(frame); event2.Set(); } -void FFmpegBackend::AddAudioFrame(const AudioCore::StereoFrame16& frame) { +void FFmpegBackend::AddAudioFrame(AudioCore::StereoFrame16 frame) { std::array, 2> refactored_frame; for (std::size_t i = 0; i < frame.size(); i++) { refactored_frame[0][i] = frame[i][0]; diff --git a/src/core/dumping/ffmpeg_backend.h b/src/core/dumping/ffmpeg_backend.h index 0208195d5..8af74b0a8 100644 --- a/src/core/dumping/ffmpeg_backend.h +++ b/src/core/dumping/ffmpeg_backend.h @@ -163,8 +163,8 @@ public: ~FFmpegBackend() override; bool StartDumping(const std::string& path, const std::string& format, const Layout::FramebufferLayout& layout) override; - void AddVideoFrame(const VideoFrame& frame) override; - void AddAudioFrame(const AudioCore::StereoFrame16& frame) override; + void AddVideoFrame(VideoFrame frame) override; + void AddAudioFrame(AudioCore::StereoFrame16 frame) override; void AddAudioSample(const std::array& sample) override; void StopDumping() override; bool IsDumping() const override; diff --git a/src/video_core/renderer_opengl/frame_dumper_opengl.cpp b/src/video_core/renderer_opengl/frame_dumper_opengl.cpp index 7be4cc8ef..53985823c 100644 --- a/src/video_core/renderer_opengl/frame_dumper_opengl.cpp +++ b/src/video_core/renderer_opengl/frame_dumper_opengl.cpp @@ -67,7 +67,7 @@ void FrameDumperOpenGL::PresentLoop() { glBindBuffer(GL_PIXEL_PACK_BUFFER, pbos[next_pbo].handle); GLubyte* pixels = static_cast(glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY)); VideoDumper::VideoFrame frame_data{layout.width, layout.height, pixels}; - video_dumper.AddVideoFrame(frame_data); + video_dumper.AddVideoFrame(std::move(frame_data)); glUnmapBuffer(GL_PIXEL_PACK_BUFFER); glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);