core: Properly std::move things around

This commit is contained in:
zhupengfei 2020-01-28 22:19:36 +08:00
parent 06a0d86e9c
commit 3c6765e87c
No known key found for this signature in database
GPG key ID: DD129E108BD09378
8 changed files with 16 additions and 15 deletions

View file

@ -38,14 +38,14 @@ void DspInterface::EnableStretching(bool enable) {
perform_time_stretching = enable; perform_time_stretching = enable;
} }
void DspInterface::OutputFrame(StereoFrame16& frame) { void DspInterface::OutputFrame(StereoFrame16 frame) {
if (!sink) if (!sink)
return; return;
fifo.Push(frame.data(), frame.size()); fifo.Push(frame.data(), frame.size());
if (Core::System::GetInstance().VideoDumper().IsDumping()) { 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<s16, 2> sample) {
fifo.Push(&sample, 1); fifo.Push(&sample, 1);
if (Core::System::GetInstance().VideoDumper().IsDumping()) { if (Core::System::GetInstance().VideoDumper().IsDumping()) {
Core::System::GetInstance().VideoDumper().AddAudioSample(sample); Core::System::GetInstance().VideoDumper().AddAudioSample(std::move(sample));
} }
} }

View file

@ -100,7 +100,7 @@ public:
void EnableStretching(bool enable); void EnableStretching(bool enable);
protected: protected:
void OutputFrame(StereoFrame16& frame); void OutputFrame(StereoFrame16 frame);
void OutputSample(std::array<s16, 2> sample); void OutputSample(std::array<s16, 2> sample);
private: private:

View file

@ -400,7 +400,7 @@ bool DspHle::Impl::Tick() {
// shared memory region) // shared memory region)
current_frame = GenerateCurrentFrame(); current_frame = GenerateCurrentFrame();
parent.OutputFrame(current_frame); parent.OutputFrame(std::move(current_frame));
return true; return true;
} }

View file

@ -483,7 +483,8 @@ DspLle::DspLle(Memory::MemorySystem& memory, bool multithread)
*memory.GetFCRAMPointer(address - Memory::FCRAM_PADDR) = value; *memory.GetFCRAMPointer(address - Memory::FCRAM_PADDR) = value;
}; };
impl->teakra.SetAHBMCallback(ahbm); impl->teakra.SetAHBMCallback(ahbm);
impl->teakra.SetAudioCallback([this](std::array<s16, 2> sample) { OutputSample(sample); }); impl->teakra.SetAudioCallback(
[this](std::array<s16, 2> sample) { OutputSample(std::move(sample)); });
} }
DspLle::~DspLle() = default; DspLle::~DspLle() = default;

View file

@ -30,8 +30,8 @@ public:
virtual ~Backend(); virtual ~Backend();
virtual bool StartDumping(const std::string& path, const std::string& format, virtual bool StartDumping(const std::string& path, const std::string& format,
const Layout::FramebufferLayout& layout) = 0; const Layout::FramebufferLayout& layout) = 0;
virtual void AddVideoFrame(const VideoFrame& frame) = 0; virtual void AddVideoFrame(VideoFrame frame) = 0;
virtual void AddAudioFrame(const AudioCore::StereoFrame16& frame) = 0; virtual void AddAudioFrame(AudioCore::StereoFrame16 frame) = 0;
virtual void AddAudioSample(const std::array<s16, 2>& sample) = 0; virtual void AddAudioSample(const std::array<s16, 2>& sample) = 0;
virtual void StopDumping() = 0; virtual void StopDumping() = 0;
virtual bool IsDumping() const = 0; virtual bool IsDumping() const = 0;
@ -45,8 +45,8 @@ public:
const Layout::FramebufferLayout& /*layout*/) override { const Layout::FramebufferLayout& /*layout*/) override {
return false; return false;
} }
void AddVideoFrame(const VideoFrame& /*frame*/) override {} void AddVideoFrame(VideoFrame /*frame*/) override {}
void AddAudioFrame(const AudioCore::StereoFrame16& /*frame*/) override {} void AddAudioFrame(AudioCore::StereoFrame16 /*frame*/) override {}
void AddAudioSample(const std::array<s16, 2>& /*sample*/) override {} void AddAudioSample(const std::array<s16, 2>& /*sample*/) override {}
void StopDumping() override {} void StopDumping() override {}
bool IsDumping() const override { bool IsDumping() const override {

View file

@ -450,13 +450,13 @@ bool FFmpegBackend::StartDumping(const std::string& path, const std::string& for
return true; return true;
} }
void FFmpegBackend::AddVideoFrame(const VideoFrame& frame) { void FFmpegBackend::AddVideoFrame(VideoFrame frame) {
event1.Wait(); event1.Wait();
video_frame_buffers[next_buffer] = std::move(frame); video_frame_buffers[next_buffer] = std::move(frame);
event2.Set(); event2.Set();
} }
void FFmpegBackend::AddAudioFrame(const AudioCore::StereoFrame16& frame) { void FFmpegBackend::AddAudioFrame(AudioCore::StereoFrame16 frame) {
std::array<std::array<s16, 160>, 2> refactored_frame; std::array<std::array<s16, 160>, 2> refactored_frame;
for (std::size_t i = 0; i < frame.size(); i++) { for (std::size_t i = 0; i < frame.size(); i++) {
refactored_frame[0][i] = frame[i][0]; refactored_frame[0][i] = frame[i][0];

View file

@ -163,8 +163,8 @@ public:
~FFmpegBackend() override; ~FFmpegBackend() override;
bool StartDumping(const std::string& path, const std::string& format, bool StartDumping(const std::string& path, const std::string& format,
const Layout::FramebufferLayout& layout) override; const Layout::FramebufferLayout& layout) override;
void AddVideoFrame(const VideoFrame& frame) override; void AddVideoFrame(VideoFrame frame) override;
void AddAudioFrame(const AudioCore::StereoFrame16& frame) override; void AddAudioFrame(AudioCore::StereoFrame16 frame) override;
void AddAudioSample(const std::array<s16, 2>& sample) override; void AddAudioSample(const std::array<s16, 2>& sample) override;
void StopDumping() override; void StopDumping() override;
bool IsDumping() const override; bool IsDumping() const override;

View file

@ -67,7 +67,7 @@ void FrameDumperOpenGL::PresentLoop() {
glBindBuffer(GL_PIXEL_PACK_BUFFER, pbos[next_pbo].handle); glBindBuffer(GL_PIXEL_PACK_BUFFER, pbos[next_pbo].handle);
GLubyte* pixels = static_cast<GLubyte*>(glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY)); GLubyte* pixels = static_cast<GLubyte*>(glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY));
VideoDumper::VideoFrame frame_data{layout.width, layout.height, pixels}; 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); glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);