Compare commits

...

3 Commits

Author SHA1 Message Date
dec05eba
4363f8b2b0 5.10.2 2025-12-08 02:53:43 +01:00
dec05eba
5906a0c06f nvfbc: fix scaled monitor capture not working correctly 2025-12-08 02:53:29 +01:00
dec05eba
2c53638bb0 Fix high cpu usage when not receiving audio 2025-12-08 02:22:23 +01:00
5 changed files with 15 additions and 12 deletions

View File

@@ -1,4 +1,4 @@
project('gpu-screen-recorder', ['c', 'cpp'], version : '5.10.0', default_options : ['warning_level=2'])
project('gpu-screen-recorder', ['c', 'cpp'], version : '5.10.2', default_options : ['warning_level=2'])
add_project_arguments('-Wshadow', language : ['c', 'cpp'])
if get_option('buildtype') == 'debug'

View File

@@ -1,7 +1,7 @@
[package]
name = "gpu-screen-recorder"
type = "executable"
version = "5.10.0"
version = "5.10.2"
platforms = ["posix"]
[config]

View File

@@ -288,7 +288,7 @@ static int gsr_capture_nvfbc_start(gsr_capture *cap, gsr_capture_metadata *captu
capture_metadata->video_height = self->tracking_height;
if(self->params.output_resolution.x > 0 && self->params.output_resolution.y > 0) {
self->params.output_resolution = scale_keep_aspect_ratio((vec2i){capture_metadata->recording_width, capture_metadata->recording_height}, self->params.output_resolution);
self->params.output_resolution = scale_keep_aspect_ratio((vec2i){capture_metadata->video_width, capture_metadata->video_height}, self->params.output_resolution);
capture_metadata->video_width = self->params.output_resolution.x;
capture_metadata->video_height = self->params.output_resolution.y;
} else if(self->params.region_size.x > 0 && self->params.region_size.y > 0) {

View File

@@ -3552,7 +3552,7 @@ int main(int argc, char **argv) {
while(running) {
void *sound_buffer;
int sound_buffer_size = -1;
//const double time_before_read_seconds = clock_get_monotonic_seconds();
const double time_before_read_seconds = clock_get_monotonic_seconds();
if(audio_device.sound_device.handle) {
// TODO: use this instead of calculating time to read. But this can fluctuate and we dont want to go back in time,
// also it's 0.0 for some users???
@@ -3562,8 +3562,6 @@ int main(int argc, char **argv) {
const bool got_audio_data = sound_buffer_size >= 0;
//fprintf(stderr, "got audio data: %s\n", got_audio_data ? "yes" : "no");
//const double time_after_read_seconds = clock_get_monotonic_seconds();
//const double time_to_read_seconds = time_after_read_seconds - time_before_read_seconds;
//fprintf(stderr, "time to read: %f, %s, %f\n", time_to_read_seconds, got_audio_data ? "yes" : "no", timeout_sec);
const double this_audio_frame_time = clock_get_monotonic_seconds() - paused_time_offset;
@@ -3632,10 +3630,9 @@ int main(int argc, char **argv) {
}
}
if(!audio_device.sound_device.handle)
if(!audio_device.sound_device.handle) {
av_usleep(timeout_ms * 1000);
if(got_audio_data) {
} else if(got_audio_data) {
// TODO: Instead of converting audio, get float audio from alsa. Or does alsa do conversion internally to get this format?
if(needs_audio_conversion)
swr_convert(swr, &audio_device.frame->data[0], audio_track.codec_context->frame_size, (const uint8_t**)&sound_buffer, audio_track.codec_context->frame_size);
@@ -3663,6 +3660,13 @@ int main(int argc, char **argv) {
audio_device.frame->pts += audio_track.codec_context->frame_size;
num_received_frames++;
} else {
// TODO: Maybe sleep for time_to_sleep_until_next_frame/4? for better latency
const double time_after_read_seconds = clock_get_monotonic_seconds();
const double time_to_read_seconds = time_after_read_seconds - time_before_read_seconds;
const double time_to_sleep_until_next_frame = timeout_sec - time_to_read_seconds;
if(time_to_sleep_until_next_frame > 0.0)
av_usleep(time_to_sleep_until_next_frame * 1000ULL * 1000ULL);
}
}

View File

@@ -312,10 +312,9 @@ static int pa_sound_device_read(pa_handle *p, double timeout_seconds) {
if(!pa_sound_device_handle_reconnect(p, device_name, sizeof(device_name), start_time))
goto fail;
if(pa_stream_get_state(p->stream) != PA_STREAM_READY) {
pa_mainloop_iterate(p->mainloop, 0, NULL);
pa_mainloop_iterate(p->mainloop, 0, NULL);
if(pa_stream_get_state(p->stream) != PA_STREAM_READY)
goto fail;
}
CHECK_DEAD_GOTO(p, rerror, fail);