rpcs3/rpcs3/util/video_provider.h
Megamouse 9e76e14a79 recording: optimize access to video recorder
Use separate locks for audio and video
Fix audio mutex usage in cellRec.
Removes can_consume_sample, since we don't do any processing
between can_consume_sample and present_samples.
Use get_system_time for consistency.
Move pts reset to set_video_sink.
Make start time atomic.
Remove frame and sample counts.
Use m_active to early out to reduce mutex locks.
Do not try to present samples if the recording mode is stopped anyway.
2023-11-30 00:34:32 +01:00

42 lines
918 B
C++

#pragma once
#include "video_sink.h"
enum class recording_mode
{
stopped = 0,
rpcs3,
cell
};
namespace utils
{
class video_provider
{
public:
video_provider() = default;
~video_provider();
bool set_video_sink(std::shared_ptr<video_sink> sink, recording_mode type);
void set_pause_time_us(usz pause_time_us);
bool can_consume_frame();
void present_frame(std::vector<u8>& data, u32 pitch, u32 width, u32 height, bool is_bgra);
void present_samples(u8* buf, u32 sample_count, u16 channels);
private:
recording_mode check_mode();
recording_mode m_type = recording_mode::stopped;
std::shared_ptr<video_sink> m_video_sink;
shared_mutex m_video_mutex{};
shared_mutex m_audio_mutex{};
atomic_t<bool> m_active{false};
atomic_t<usz> m_start_time_us{umax};
s64 m_last_video_pts_incoming = -1;
s64 m_last_audio_pts_incoming = -1;
usz m_pause_time_us = 0;
};
} // namespace utils