Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cellCamera/cellGem: Fix time stretching setting support #10476

Merged
merged 2 commits into from Jun 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 3 additions & 6 deletions rpcs3/Emu/Cell/Modules/cellCamera.cpp
Expand Up @@ -976,7 +976,7 @@ error_code cellCameraStart(s32 dev_num)
return CELL_CAMERA_ERROR_DEVICE_NOT_FOUND;
}

g_camera.timer.Start();
g_camera.start_timestamp = get_guest_system_time();
g_camera.is_streaming = true;

return CELL_OK;
Expand Down Expand Up @@ -1066,7 +1066,7 @@ error_code cellCameraReadEx(s32 dev_num, vm::ptr<CellCameraReadEx> read)

if (read) // NULL returns CELL_OK
{
read->timestamp = g_camera.timer.GetElapsedTimeInMicroSec();
read->timestamp = (get_guest_system_time() - g_camera.start_timestamp);
read->frame = g_camera.frame_num;
read->bytesread = g_camera.is_streaming ? get_video_buffer_size(g_camera.info) : 0;

Expand Down Expand Up @@ -1123,9 +1123,6 @@ error_code cellCameraStop(s32 dev_num)

g_camera.is_streaming = false;

std::lock_guard lock(g_camera.mutex);
g_camera.timer.Stop();

return CELL_OK;
}

Expand Down Expand Up @@ -1300,7 +1297,7 @@ void camera_context::operator()()
const u64 camera_id = 0;

data2 = image_data_size << 32 | buffer_number << 16 | camera_id;
data3 = timer.GetElapsedTimeInMicroSec(); // timestamp
data3 = get_guest_system_time() - start_timestamp; // timestamp
}
else // CELL_CAMERA_READ_FUNCCALL, also default
{
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/Modules/cellCamera.h
Expand Up @@ -417,7 +417,7 @@ class camera_context

shared_mutex mutex;
shared_mutex mutex_notify_data_map;
Timer timer;
u64 start_timestamp = 0;

atomic_t<u8> read_mode{CELL_CAMERA_READ_FUNCCALL};
atomic_t<bool> is_streaming{false};
Expand Down
10 changes: 5 additions & 5 deletions rpcs3/Emu/Cell/Modules/cellGem.cpp
Expand Up @@ -106,7 +106,7 @@ struct gem_config

shared_mutex mtx;

Timer timer;
u64 start_timestamp = 0;

// helper functions
bool is_controller_ready(u32 gem_num) const
Expand Down Expand Up @@ -738,7 +738,7 @@ error_code cellGemGetInertialState(u32 gem_num, u32 state_flag, u64 timestamp, v
{
ds3_input_to_ext(gem_num, inertial_state->ext);

inertial_state->timestamp = gem.timer.GetElapsedTimeInMicroSec();
inertial_state->timestamp = (get_guest_system_time() - gem.start_timestamp);
inertial_state->counter = gem.inertial_counter++;
inertial_state->accelerometer[0] = 10;
}
Expand Down Expand Up @@ -876,7 +876,7 @@ error_code cellGemGetState(u32 gem_num, u32 flag, u64 time_parameter, vm::ptr<Ce
ds3_input_to_ext(gem_num, gem_state->ext);

gem_state->tracking_flags = CELL_GEM_TRACKING_FLAG_POSITION_TRACKED | CELL_GEM_TRACKING_FLAG_VISIBLE;
gem_state->timestamp = gem.timer.GetElapsedTimeInMicroSec();
gem_state->timestamp = (get_guest_system_time() - gem.start_timestamp);
gem_state->quat[3] = 1.f;

return CELL_OK;
Expand Down Expand Up @@ -1006,7 +1006,7 @@ error_code cellGemInit(ppu_thread& ppu, vm::cptr<CellGemAttribute> attribute)
}

// TODO: is this correct?
gem.timer.Start();
gem.start_timestamp = get_guest_system_time();

return CELL_OK;
}
Expand Down Expand Up @@ -1153,7 +1153,7 @@ error_code cellGemReset(u32 gem_num)
gem.reset_controller(gem_num);

// TODO: is this correct?
gem.timer.Start();
gem.start_timestamp = get_guest_system_time();

return CELL_OK;
}
Expand Down