mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-08-04 15:19:47 +00:00
Merge branch 'master' into cellAdec
This commit is contained in:
commit
3c831904e2
20 changed files with 111 additions and 72 deletions
2
3rdparty/7zip/7zip
vendored
2
3rdparty/7zip/7zip
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit e008ce3976c087bfd21344af8f00a23cf69d4174
|
Subproject commit e5431fa6f5505e385c6f9367260717e9c47dc2ee
|
2
3rdparty/FAudio
vendored
2
3rdparty/FAudio
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 74d45e615c2e7510c7e0f2ccb91dc6d7ccae4bec
|
Subproject commit b7c2e109ea86b82109244c9c4569ce9ad0c884df
|
2
3rdparty/OpenAL/openal-soft
vendored
2
3rdparty/OpenAL/openal-soft
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit d3875f333fb6abe2f39d82caca329414871ae53b
|
Subproject commit 90191edd20bb877c5cbddfdac7ec0fe49ad93727
|
2
3rdparty/curl/curl
vendored
2
3rdparty/curl/curl
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit b1ef0e1a01c0bb6ee5367bd9c186a603bde3615a
|
Subproject commit 75a2079d5c28debb2eaa848ca9430f1fe0d7844c
|
2
3rdparty/libsdl-org/SDL
vendored
2
3rdparty/libsdl-org/SDL
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit c98c4fbff6d8f3016a3ce6685bf8f43433c3efcc
|
Subproject commit 9c821dc21ccbd69b2bda421fdb35cb4ae2da8f5e
|
|
@ -784,26 +784,26 @@ s32 cellCameraIsAttached(s32 dev_num)
|
||||||
|
|
||||||
if (g_cfg.io.camera == camera_handler::null)
|
if (g_cfg.io.camera == camera_handler::null)
|
||||||
{
|
{
|
||||||
return false;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& g_camera = g_fxo->get<camera_thread>();
|
auto& g_camera = g_fxo->get<camera_thread>();
|
||||||
|
|
||||||
if (!g_camera.init)
|
if (!g_camera.init)
|
||||||
{
|
{
|
||||||
return false;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!check_dev_num(dev_num))
|
if (!check_dev_num(dev_num))
|
||||||
{
|
{
|
||||||
return false;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
vm::var<s32> type;
|
vm::var<s32> type;
|
||||||
|
|
||||||
if (cellCameraGetType(dev_num, type) != CELL_OK)
|
if (cellCameraGetType(dev_num, type) != CELL_OK)
|
||||||
{
|
{
|
||||||
return false;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::lock_guard lock(g_camera.mutex);
|
std::lock_guard lock(g_camera.mutex);
|
||||||
|
@ -821,12 +821,12 @@ s32 cellCameraIsAttached(s32 dev_num)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return is_attached;
|
return is_attached ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 cellCameraIsOpen(s32 dev_num)
|
s32 cellCameraIsOpen(s32 dev_num)
|
||||||
{
|
{
|
||||||
cellCamera.notice("cellCameraIsOpen(dev_num=%d)", dev_num);
|
cellCamera.trace("cellCameraIsOpen(dev_num=%d)", dev_num);
|
||||||
|
|
||||||
if (g_cfg.io.camera == camera_handler::null)
|
if (g_cfg.io.camera == camera_handler::null)
|
||||||
{
|
{
|
||||||
|
@ -852,7 +852,7 @@ s32 cellCameraIsOpen(s32 dev_num)
|
||||||
|
|
||||||
s32 cellCameraIsStarted(s32 dev_num)
|
s32 cellCameraIsStarted(s32 dev_num)
|
||||||
{
|
{
|
||||||
cellCamera.notice("cellCameraIsStarted(dev_num=%d)", dev_num);
|
cellCamera.trace("cellCameraIsStarted(dev_num=%d)", dev_num);
|
||||||
|
|
||||||
if (g_cfg.io.camera == camera_handler::null)
|
if (g_cfg.io.camera == camera_handler::null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -956,9 +956,9 @@ static inline void pos_to_gem_state(u32 gem_num, gem_config::gem_controller& con
|
||||||
static constexpr f32 PI = 3.14159265f;
|
static constexpr f32 PI = 3.14159265f;
|
||||||
const auto degree_to_rad = [](f32 degree) -> f32 { return degree * PI / 180.0f; };
|
const auto degree_to_rad = [](f32 degree) -> f32 { return degree * PI / 180.0f; };
|
||||||
|
|
||||||
static constexpr f32 CONE = 10.0f / 2.0f;
|
const f32 max_angle_per_side = g_cfg.io.fake_move_rotation_cone / 2.0f;
|
||||||
const f32 roll = -degree_to_rad((image_y - half_height) / half_height * CONE); // This is actually the pitch
|
const f32 roll = -degree_to_rad((image_y - half_height) / half_height * max_angle_per_side); // This is actually the pitch
|
||||||
const f32 pitch = -degree_to_rad((image_x - half_width) / half_width * CONE); // This is actually the yaw
|
const f32 pitch = -degree_to_rad((image_x - half_width) / half_width * max_angle_per_side); // This is actually the yaw
|
||||||
const f32 yaw = degree_to_rad(0.0f);
|
const f32 yaw = degree_to_rad(0.0f);
|
||||||
const f32 cr = std::cos(roll * 0.5f);
|
const f32 cr = std::cos(roll * 0.5f);
|
||||||
const f32 sr = std::sin(roll * 0.5f);
|
const f32 sr = std::sin(roll * 0.5f);
|
||||||
|
|
|
@ -7,10 +7,10 @@ class null_camera_handler final : public camera_handler_base
|
||||||
public:
|
public:
|
||||||
null_camera_handler() : camera_handler_base() {}
|
null_camera_handler() : camera_handler_base() {}
|
||||||
|
|
||||||
void open_camera() override { m_state = camera_handler_state::open; }
|
void open_camera() override { set_state(camera_handler_state::open); }
|
||||||
void close_camera() override { m_state = camera_handler_state::closed; }
|
void close_camera() override { set_state(camera_handler_state::closed); }
|
||||||
void start_camera() override { m_state = camera_handler_state::running; }
|
void start_camera() override { set_state(camera_handler_state::running); }
|
||||||
void stop_camera() override { m_state = camera_handler_state::open; }
|
void stop_camera() override { set_state(camera_handler_state::open); }
|
||||||
|
|
||||||
void set_format(s32 format, u32 bytesize) override
|
void set_format(s32 format, u32 bytesize) override
|
||||||
{
|
{
|
||||||
|
@ -45,6 +45,6 @@ public:
|
||||||
height = 0;
|
height = 0;
|
||||||
frame_number = 0;
|
frame_number = 0;
|
||||||
bytes_read = 0;
|
bytes_read = 0;
|
||||||
return m_state;
|
return get_state();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,22 +30,29 @@ public:
|
||||||
virtual u64 frame_number() const = 0; // Convenience function to check if there's a new frame.
|
virtual u64 frame_number() const = 0; // Convenience function to check if there's a new frame.
|
||||||
virtual camera_handler_state get_image(u8* buf, u64 size, u32& width, u32& height, u64& frame_number, u64& bytes_read) = 0;
|
virtual camera_handler_state get_image(u8* buf, u64 size, u32& width, u32& height, u64& frame_number, u64& bytes_read) = 0;
|
||||||
|
|
||||||
camera_handler_state get_state() const { return m_state.load(); };
|
camera_handler_state get_state() const { return m_state.load(); }
|
||||||
|
void set_state(camera_handler_state state) { m_state = m_state_expected = state; }
|
||||||
|
|
||||||
bool mirrored() const { return m_mirrored; };
|
camera_handler_state get_expected_state() const { return m_state_expected.load(); }
|
||||||
s32 format() const { return m_format; };
|
void set_expected_state(camera_handler_state state) { m_state_expected = state; }
|
||||||
u32 bytesize() const { return m_bytesize; };
|
|
||||||
u32 width() const { return m_width; };
|
bool mirrored() const { return m_mirrored; }
|
||||||
u32 height() const { return m_height; };
|
s32 format() const { return m_format; }
|
||||||
u32 frame_rate() const { return m_frame_rate; };
|
u32 bytesize() const { return m_bytesize; }
|
||||||
|
u32 width() const { return m_width; }
|
||||||
|
u32 height() const { return m_height; }
|
||||||
|
u32 frame_rate() const { return m_frame_rate; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::mutex m_mutex;
|
std::mutex m_mutex;
|
||||||
atomic_t<camera_handler_state> m_state = camera_handler_state::closed;
|
|
||||||
bool m_mirrored = false;
|
bool m_mirrored = false;
|
||||||
s32 m_format = 2; // CELL_CAMERA_RAW8
|
s32 m_format = 2; // CELL_CAMERA_RAW8
|
||||||
u32 m_bytesize = 0;
|
u32 m_bytesize = 0;
|
||||||
u32 m_width = 640;
|
u32 m_width = 640;
|
||||||
u32 m_height = 480;
|
u32 m_height = 480;
|
||||||
u32 m_frame_rate = 30;
|
u32 m_frame_rate = 30;
|
||||||
|
|
||||||
|
private:
|
||||||
|
atomic_t<camera_handler_state> m_state = camera_handler_state::closed;
|
||||||
|
atomic_t<camera_handler_state> m_state_expected = camera_handler_state::closed;
|
||||||
};
|
};
|
||||||
|
|
|
@ -83,6 +83,7 @@ namespace rsx
|
||||||
|
|
||||||
add_dropdown(&g_cfg.io.pad_mode, localized_string_id::HOME_MENU_SETTINGS_INPUT_PAD_MODE);
|
add_dropdown(&g_cfg.io.pad_mode, localized_string_id::HOME_MENU_SETTINGS_INPUT_PAD_MODE);
|
||||||
add_unsigned_slider(&g_cfg.io.pad_sleep, localized_string_id::HOME_MENU_SETTINGS_INPUT_PAD_SLEEP, " µs", 100);
|
add_unsigned_slider(&g_cfg.io.pad_sleep, localized_string_id::HOME_MENU_SETTINGS_INPUT_PAD_SLEEP, " µs", 100);
|
||||||
|
add_unsigned_slider(&g_cfg.io.fake_move_rotation_cone, localized_string_id::HOME_MENU_SETTINGS_INPUT_FAKE_MOVE_ROTATION_CONE, "°", 1);
|
||||||
|
|
||||||
apply_layout();
|
apply_layout();
|
||||||
}
|
}
|
||||||
|
|
|
@ -223,6 +223,7 @@ enum class localized_string_id
|
||||||
HOME_MENU_SETTINGS_INPUT_CAMERA_FLIP,
|
HOME_MENU_SETTINGS_INPUT_CAMERA_FLIP,
|
||||||
HOME_MENU_SETTINGS_INPUT_PAD_MODE,
|
HOME_MENU_SETTINGS_INPUT_PAD_MODE,
|
||||||
HOME_MENU_SETTINGS_INPUT_PAD_SLEEP,
|
HOME_MENU_SETTINGS_INPUT_PAD_SLEEP,
|
||||||
|
HOME_MENU_SETTINGS_INPUT_FAKE_MOVE_ROTATION_CONE,
|
||||||
HOME_MENU_SETTINGS_ADVANCED,
|
HOME_MENU_SETTINGS_ADVANCED,
|
||||||
HOME_MENU_SETTINGS_ADVANCED_PREFERRED_SPU_THREADS,
|
HOME_MENU_SETTINGS_ADVANCED_PREFERRED_SPU_THREADS,
|
||||||
HOME_MENU_SETTINGS_ADVANCED_MAX_CPU_PREEMPTIONS,
|
HOME_MENU_SETTINGS_ADVANCED_MAX_CPU_PREEMPTIONS,
|
||||||
|
|
|
@ -91,8 +91,8 @@ scoped_progress_dialog::scoped_progress_dialog(std::string text) noexcept
|
||||||
|
|
||||||
scoped_progress_dialog& scoped_progress_dialog::operator=(std::string text) noexcept
|
scoped_progress_dialog& scoped_progress_dialog::operator=(std::string text) noexcept
|
||||||
{
|
{
|
||||||
// Exchange text atomically
|
// Set text atomically
|
||||||
g_progr_text_queue[m_text_index].exchange(make_single_value(std::move(text)));
|
g_progr_text_queue[m_text_index].store(make_single_value(std::move(text)));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -283,6 +283,7 @@ struct cfg_root : cfg::node
|
||||||
cfg::string midi_devices{this, "Emulated Midi devices", "ßßß@@@ßßß@@@ßßß@@@"};
|
cfg::string midi_devices{this, "Emulated Midi devices", "ßßß@@@ßßß@@@ßßß@@@"};
|
||||||
cfg::_bool load_sdl_mappings{ this, "Load SDL GameController Mappings", true };
|
cfg::_bool load_sdl_mappings{ this, "Load SDL GameController Mappings", true };
|
||||||
cfg::_bool debug_overlay{ this, "IO Debug overlay", false, true };
|
cfg::_bool debug_overlay{ this, "IO Debug overlay", false, true };
|
||||||
|
cfg::uint<1, 180> fake_move_rotation_cone{ this, "Fake Move Rotation Cone", 10, true };
|
||||||
|
|
||||||
} io{ this };
|
} io{ this };
|
||||||
|
|
||||||
|
|
|
@ -79,11 +79,14 @@ flow_layout::~flow_layout()
|
||||||
|
|
||||||
void flow_layout::clear()
|
void flow_layout::clear()
|
||||||
{
|
{
|
||||||
while (QLayoutItem* item = takeAt(0))
|
for (QLayoutItem* item : m_item_list)
|
||||||
|
{
|
||||||
|
if (item)
|
||||||
{
|
{
|
||||||
delete item->widget();
|
delete item->widget();
|
||||||
delete item;
|
delete item;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
m_item_list.clear();
|
m_item_list.clear();
|
||||||
m_positions.clear();
|
m_positions.clear();
|
||||||
}
|
}
|
||||||
|
@ -185,8 +188,8 @@ int flow_layout::doLayout(const QRect& rect, bool testOnly) const
|
||||||
int x = effectiveRect.x();
|
int x = effectiveRect.x();
|
||||||
int y = effectiveRect.y();
|
int y = effectiveRect.y();
|
||||||
int lineHeight = 0;
|
int lineHeight = 0;
|
||||||
int rows = 0;
|
int row_count = 0;
|
||||||
int cols = 0;
|
int col_count = 0;
|
||||||
|
|
||||||
if (m_dynamic_spacing)
|
if (m_dynamic_spacing)
|
||||||
{
|
{
|
||||||
|
@ -259,8 +262,8 @@ int flow_layout::doLayout(const QRect& rect, bool testOnly) const
|
||||||
pos.row = row;
|
pos.row = row;
|
||||||
pos.col = col++;
|
pos.col = col++;
|
||||||
|
|
||||||
rows = std::max(rows, pos.row + 1);
|
row_count = std::max(row_count, pos.row + 1);
|
||||||
cols = std::max(cols, pos.col + 1);
|
col_count = std::max(col_count, pos.col + 1);
|
||||||
|
|
||||||
if (!testOnly)
|
if (!testOnly)
|
||||||
item->setGeometry(QRect(QPoint(x, y), item->sizeHint()));
|
item->setGeometry(QRect(QPoint(x, y), item->sizeHint()));
|
||||||
|
@ -269,8 +272,8 @@ int flow_layout::doLayout(const QRect& rect, bool testOnly) const
|
||||||
lineHeight = qMax(lineHeight, item->sizeHint().height());
|
lineHeight = qMax(lineHeight, item->sizeHint().height());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_rows = rows;
|
m_rows = row_count;
|
||||||
m_cols = cols;
|
m_cols = col_count;
|
||||||
|
|
||||||
return y + lineHeight - rect.y() + bottom;
|
return y + lineHeight - rect.y() + bottom;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,16 +11,11 @@ struct gui_save
|
||||||
|
|
||||||
gui_save()
|
gui_save()
|
||||||
{
|
{
|
||||||
key = "";
|
|
||||||
name = "";
|
|
||||||
def = QVariant();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gui_save(const QString& k, const QString& n, const QVariant& d)
|
gui_save(const QString& k, const QString& n, const QVariant& d)
|
||||||
|
: key(k), name(n), def(d)
|
||||||
{
|
{
|
||||||
key = k;
|
|
||||||
name = n;
|
|
||||||
def = d;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const gui_save& rhs) const noexcept
|
bool operator==(const gui_save& rhs) const noexcept
|
||||||
|
|
|
@ -244,6 +244,7 @@ private:
|
||||||
case localized_string_id::HOME_MENU_SETTINGS_INPUT_CAMERA_FLIP: return tr("Camera Flip", "Input");
|
case localized_string_id::HOME_MENU_SETTINGS_INPUT_CAMERA_FLIP: return tr("Camera Flip", "Input");
|
||||||
case localized_string_id::HOME_MENU_SETTINGS_INPUT_PAD_MODE: return tr("Pad Handler Mode", "Input");
|
case localized_string_id::HOME_MENU_SETTINGS_INPUT_PAD_MODE: return tr("Pad Handler Mode", "Input");
|
||||||
case localized_string_id::HOME_MENU_SETTINGS_INPUT_PAD_SLEEP: return tr("Pad Handler Sleep", "Input");
|
case localized_string_id::HOME_MENU_SETTINGS_INPUT_PAD_SLEEP: return tr("Pad Handler Sleep", "Input");
|
||||||
|
case localized_string_id::HOME_MENU_SETTINGS_INPUT_FAKE_MOVE_ROTATION_CONE: return tr("Fake PS Move Rotation Cone", "Input");
|
||||||
case localized_string_id::HOME_MENU_SETTINGS_ADVANCED: return tr("Advanced");
|
case localized_string_id::HOME_MENU_SETTINGS_ADVANCED: return tr("Advanced");
|
||||||
case localized_string_id::HOME_MENU_SETTINGS_ADVANCED_PREFERRED_SPU_THREADS: return tr("Preferred SPU Threads", "Advanced");
|
case localized_string_id::HOME_MENU_SETTINGS_ADVANCED_PREFERRED_SPU_THREADS: return tr("Preferred SPU Threads", "Advanced");
|
||||||
case localized_string_id::HOME_MENU_SETTINGS_ADVANCED_MAX_CPU_PREEMPTIONS: return tr("Max Power Saving CPU-Preemptions", "Advanced");
|
case localized_string_id::HOME_MENU_SETTINGS_ADVANCED_MAX_CPU_PREEMPTIONS: return tr("Max Power Saving CPU-Preemptions", "Advanced");
|
||||||
|
|
|
@ -47,6 +47,7 @@ void qt_camera_handler::set_camera(const QCameraDevice& camera_info)
|
||||||
{
|
{
|
||||||
if (camera_info.isNull())
|
if (camera_info.isNull())
|
||||||
{
|
{
|
||||||
|
set_expected_state(camera_handler_state::closed);
|
||||||
reset();
|
reset();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -57,9 +58,9 @@ void qt_camera_handler::set_camera(const QCameraDevice& camera_info)
|
||||||
camera_log.success("Using camera: id=\"%s\", description=\"%s\", front_facing=%d", camera_info.id().toStdString(), camera_info.description(), front_facing);
|
camera_log.success("Using camera: id=\"%s\", description=\"%s\", front_facing=%d", camera_info.id().toStdString(), camera_info.description(), front_facing);
|
||||||
|
|
||||||
// Create camera and video surface
|
// Create camera and video surface
|
||||||
m_media_capture_session.reset(new QMediaCaptureSession(nullptr));
|
m_media_capture_session = std::make_unique<QMediaCaptureSession>(nullptr);
|
||||||
m_video_sink.reset(new qt_camera_video_sink(front_facing, nullptr));
|
m_video_sink = std::make_unique<qt_camera_video_sink>(front_facing, nullptr);
|
||||||
m_camera.reset(new QCamera(camera_info));
|
m_camera = std::make_unique<QCamera>(camera_info);
|
||||||
|
|
||||||
connect(m_camera.get(), &QCamera::activeChanged, this, &qt_camera_handler::handle_camera_active);
|
connect(m_camera.get(), &QCamera::activeChanged, this, &qt_camera_handler::handle_camera_active);
|
||||||
connect(m_camera.get(), &QCamera::errorOccurred, this, &qt_camera_handler::handle_camera_error);
|
connect(m_camera.get(), &QCamera::errorOccurred, this, &qt_camera_handler::handle_camera_error);
|
||||||
|
@ -76,14 +77,37 @@ void qt_camera_handler::handle_camera_active(bool is_active)
|
||||||
{
|
{
|
||||||
camera_log.notice("Camera active status changed to %d", is_active);
|
camera_log.notice("Camera active status changed to %d", is_active);
|
||||||
|
|
||||||
|
// Check if the camera does what it's supposed to do.
|
||||||
|
const camera_handler_state expected_state = get_expected_state();
|
||||||
|
|
||||||
|
switch (expected_state)
|
||||||
|
{
|
||||||
|
case camera_handler_state::closed:
|
||||||
|
case camera_handler_state::open:
|
||||||
|
{
|
||||||
if (is_active)
|
if (is_active)
|
||||||
{
|
{
|
||||||
m_state = camera_handler_state::running;
|
// This is not supposed to happen and indicates an unexpected QCamera issue
|
||||||
|
camera_log.error("Camera started unexpectedly");
|
||||||
|
set_state(camera_handler_state::running);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
break;
|
||||||
|
}
|
||||||
|
case camera_handler_state::running:
|
||||||
{
|
{
|
||||||
m_state = camera_handler_state::closed;
|
if (!is_active)
|
||||||
|
{
|
||||||
|
// This is not supposed to happen and indicates an unexpected QCamera issue
|
||||||
|
camera_log.error("Camera stopped unexpectedly");
|
||||||
|
set_state(camera_handler_state::open);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
set_state(expected_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void qt_camera_handler::handle_camera_error(QCamera::Error error, const QString& errorString)
|
void qt_camera_handler::handle_camera_error(QCamera::Error error, const QString& errorString)
|
||||||
|
@ -100,7 +124,11 @@ void qt_camera_handler::open_camera()
|
||||||
{
|
{
|
||||||
camera_log.notice("Switching camera from %s to %s", m_camera_id, camera_id);
|
camera_log.notice("Switching camera from %s to %s", m_camera_id, camera_id);
|
||||||
camera_log.notice("Stopping old camera...");
|
camera_log.notice("Stopping old camera...");
|
||||||
if (m_camera) m_camera->stop();
|
if (m_camera)
|
||||||
|
{
|
||||||
|
set_expected_state(camera_handler_state::open);
|
||||||
|
m_camera->stop();
|
||||||
|
}
|
||||||
m_camera_id = camera_id;
|
m_camera_id = camera_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +157,7 @@ void qt_camera_handler::open_camera()
|
||||||
{
|
{
|
||||||
if (m_camera_id.empty()) camera_log.notice("Camera disabled");
|
if (m_camera_id.empty()) camera_log.notice("Camera disabled");
|
||||||
else camera_log.error("No camera found");
|
else camera_log.error("No camera found");
|
||||||
m_state = camera_handler_state::closed;
|
set_state(camera_handler_state::closed);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +176,7 @@ void qt_camera_handler::open_camera()
|
||||||
// Update camera and view finder settings
|
// Update camera and view finder settings
|
||||||
update_camera_settings();
|
update_camera_settings();
|
||||||
|
|
||||||
m_state = camera_handler_state::open;
|
set_state(camera_handler_state::open);
|
||||||
}
|
}
|
||||||
|
|
||||||
void qt_camera_handler::close_camera()
|
void qt_camera_handler::close_camera()
|
||||||
|
@ -159,11 +187,12 @@ void qt_camera_handler::close_camera()
|
||||||
{
|
{
|
||||||
if (m_camera_id.empty()) camera_log.notice("Camera disabled");
|
if (m_camera_id.empty()) camera_log.notice("Camera disabled");
|
||||||
else camera_log.error("No camera found");
|
else camera_log.error("No camera found");
|
||||||
m_state = camera_handler_state::closed;
|
set_state(camera_handler_state::closed);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unload/close camera
|
// Unload/close camera
|
||||||
|
set_expected_state(camera_handler_state::closed);
|
||||||
m_camera->stop();
|
m_camera->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +204,7 @@ void qt_camera_handler::start_camera()
|
||||||
{
|
{
|
||||||
if (m_camera_id.empty()) camera_log.notice("Camera disabled");
|
if (m_camera_id.empty()) camera_log.notice("Camera disabled");
|
||||||
else camera_log.error("No camera found");
|
else camera_log.error("No camera found");
|
||||||
m_state = camera_handler_state::closed;
|
set_state(camera_handler_state::closed);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,6 +235,7 @@ void qt_camera_handler::start_camera()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Start camera. We will start receiving frames now.
|
// Start camera. We will start receiving frames now.
|
||||||
|
set_expected_state(camera_handler_state::running);
|
||||||
m_camera->start();
|
m_camera->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,7 +247,7 @@ void qt_camera_handler::stop_camera()
|
||||||
{
|
{
|
||||||
if (m_camera_id.empty()) camera_log.notice("Camera disabled");
|
if (m_camera_id.empty()) camera_log.notice("Camera disabled");
|
||||||
else camera_log.error("No camera found");
|
else camera_log.error("No camera found");
|
||||||
m_state = camera_handler_state::closed;
|
set_state(camera_handler_state::closed);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,6 +258,7 @@ void qt_camera_handler::stop_camera()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop camera. The camera will still be drawing power.
|
// Stop camera. The camera will still be drawing power.
|
||||||
|
set_expected_state(camera_handler_state::open);
|
||||||
m_camera->stop();
|
m_camera->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,26 +315,26 @@ camera_handler_base::camera_handler_state qt_camera_handler::get_image(u8* buf,
|
||||||
m_camera_id != camera_id)
|
m_camera_id != camera_id)
|
||||||
{
|
{
|
||||||
camera_log.notice("Switching cameras");
|
camera_log.notice("Switching cameras");
|
||||||
m_state = camera_handler_state::closed;
|
set_state(camera_handler_state::closed);
|
||||||
return camera_handler_state::closed;
|
return camera_handler_state::closed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_camera_id.empty())
|
if (m_camera_id.empty())
|
||||||
{
|
{
|
||||||
camera_log.notice("Camera disabled");
|
camera_log.notice("Camera disabled");
|
||||||
m_state = camera_handler_state::closed;
|
set_state(camera_handler_state::closed);
|
||||||
return camera_handler_state::closed;
|
return camera_handler_state::closed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_camera || !m_video_sink)
|
if (!m_camera || !m_video_sink)
|
||||||
{
|
{
|
||||||
camera_log.fatal("Error: camera invalid");
|
camera_log.fatal("Error: camera invalid");
|
||||||
m_state = camera_handler_state::closed;
|
set_state(camera_handler_state::closed);
|
||||||
return camera_handler_state::closed;
|
return camera_handler_state::closed;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Backup current state. State may change through events.
|
// Backup current state. State may change through events.
|
||||||
const camera_handler_state current_state = m_state;
|
const camera_handler_state current_state = get_state();
|
||||||
|
|
||||||
if (current_state == camera_handler_state::running)
|
if (current_state == camera_handler_state::running)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,8 +17,6 @@ public:
|
||||||
qt_camera_handler();
|
qt_camera_handler();
|
||||||
virtual ~qt_camera_handler();
|
virtual ~qt_camera_handler();
|
||||||
|
|
||||||
void set_camera(const QCameraDevice& camera_info);
|
|
||||||
|
|
||||||
void open_camera() override;
|
void open_camera() override;
|
||||||
void close_camera() override;
|
void close_camera() override;
|
||||||
void start_camera() override;
|
void start_camera() override;
|
||||||
|
@ -31,11 +29,12 @@ public:
|
||||||
camera_handler_state get_image(u8* buf, u64 size, u32& width, u32& height, u64& frame_number, u64& bytes_read) override;
|
camera_handler_state get_image(u8* buf, u64 size, u32& width, u32& height, u64& frame_number, u64& bytes_read) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void set_camera(const QCameraDevice& camera_info);
|
||||||
void reset();
|
void reset();
|
||||||
void update_camera_settings();
|
void update_camera_settings();
|
||||||
|
|
||||||
std::string m_camera_id;
|
std::string m_camera_id;
|
||||||
std::shared_ptr<QCamera> m_camera;
|
std::unique_ptr<QCamera> m_camera;
|
||||||
std::unique_ptr<QMediaCaptureSession> m_media_capture_session;
|
std::unique_ptr<QMediaCaptureSession> m_media_capture_session;
|
||||||
std::unique_ptr<qt_camera_video_sink> m_video_sink;
|
std::unique_ptr<qt_camera_video_sink> m_video_sink;
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,9 @@ class user_account
|
||||||
public:
|
public:
|
||||||
explicit user_account(const std::string& user_id = "00000001");
|
explicit user_account(const std::string& user_id = "00000001");
|
||||||
|
|
||||||
std::string GetUserId() const { return m_user_id; }
|
const std::string& GetUserId() const { return m_user_id; }
|
||||||
std::string GetUserDir() const { return m_user_dir; }
|
const std::string& GetUserDir() const { return m_user_dir; }
|
||||||
std::string GetUsername() const { return m_username; }
|
const std::string& GetUsername() const { return m_username; }
|
||||||
|
|
||||||
static std::map<u32, user_account> GetUserAccounts(const std::string& base_dir);
|
static std::map<u32, user_account> GetUserAccounts(const std::string& base_dir);
|
||||||
|
|
||||||
|
|
|
@ -989,14 +989,14 @@ template <typename To, typename From> requires (std::is_integral_v<decltype(std:
|
||||||
constexpr bool is_from_signed = std::is_signed_v<CommonFrom>;
|
constexpr bool is_from_signed = std::is_signed_v<CommonFrom>;
|
||||||
constexpr bool is_to_signed = std::is_signed_v<CommonTo>;
|
constexpr bool is_to_signed = std::is_signed_v<CommonTo>;
|
||||||
|
|
||||||
constexpr auto from_mask = is_from_signed > is_to_signed ? UnFrom{umax} >> 1 : UnFrom{umax};
|
constexpr auto from_mask = (is_from_signed && !is_to_signed) ? UnFrom{umax} >> 1 : UnFrom{umax};
|
||||||
constexpr auto to_mask = is_to_signed > is_from_signed ? UnTo{umax} >> 1 : UnTo{umax};
|
constexpr auto to_mask = (is_to_signed && !is_from_signed) ? UnTo{umax} >> 1 : UnTo{umax};
|
||||||
|
|
||||||
constexpr auto mask = ~(from_mask & to_mask);
|
constexpr auto mask = ~(from_mask & to_mask);
|
||||||
|
|
||||||
// Signed to unsigned always require test
|
// Signed to unsigned always require test
|
||||||
// Otherwise, this is bit-wise narrowing or conversion between types of different signedness of the same size
|
// Otherwise, this is bit-wise narrowing or conversion between types of different signedness of the same size
|
||||||
if constexpr (is_from_signed > is_to_signed || to_mask < from_mask)
|
if constexpr ((is_from_signed && !is_to_signed) || to_mask < from_mask)
|
||||||
{
|
{
|
||||||
// Try to optimize test if both are of the same signedness
|
// Try to optimize test if both are of the same signedness
|
||||||
if (is_from_signed != is_to_signed ? !!(value & mask) : static_cast<CommonTo>(value) != value) [[unlikely]]
|
if (is_from_signed != is_to_signed ? !!(value & mask) : static_cast<CommonTo>(value) != value) [[unlikely]]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue