mirror of
https://repo.dec05eba.com/gpu-screen-recorder
synced 2026-04-20 00:45:49 +09:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6cbf660afa | ||
|
|
827751cc55 | ||
|
|
a4b3be3786 | ||
|
|
240ccf569c | ||
|
|
88d356386b | ||
|
|
c4104e18cc | ||
|
|
640e377c90 | ||
|
|
2545db7e50 |
@@ -1,4 +1,4 @@
|
|||||||
project('gpu-screen-recorder', ['c', 'cpp'], version : '5.11.3', default_options : ['warning_level=2'])
|
project('gpu-screen-recorder', ['c', 'cpp'], version : '5.11.5', default_options : ['warning_level=2'])
|
||||||
|
|
||||||
add_project_arguments('-Wshadow', language : ['c', 'cpp'])
|
add_project_arguments('-Wshadow', language : ['c', 'cpp'])
|
||||||
if get_option('buildtype') == 'debug'
|
if get_option('buildtype') == 'debug'
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "gpu-screen-recorder"
|
name = "gpu-screen-recorder"
|
||||||
type = "executable"
|
type = "executable"
|
||||||
version = "5.11.3"
|
version = "5.11.5"
|
||||||
platforms = ["posix"]
|
platforms = ["posix"]
|
||||||
|
|
||||||
[config]
|
[config]
|
||||||
|
|||||||
@@ -245,8 +245,8 @@ static bool gsr_video_encoder_vaapi_start(gsr_video_encoder *encoder, AVCodecCon
|
|||||||
video_codec_context->width = FFALIGN(video_codec_context->width, 2);
|
video_codec_context->width = FFALIGN(video_codec_context->width, 2);
|
||||||
video_codec_context->height = FFALIGN(video_codec_context->height, 2);
|
video_codec_context->height = FFALIGN(video_codec_context->height, 2);
|
||||||
} else {
|
} else {
|
||||||
video_codec_context->width = FFALIGN(video_codec_context->width, 256);
|
video_codec_context->width = FFALIGN(video_codec_context->width, 64);
|
||||||
video_codec_context->height = FFALIGN(video_codec_context->height, 256);
|
video_codec_context->height = FFALIGN(video_codec_context->height, 16);
|
||||||
}
|
}
|
||||||
} else if(self->params.egl->gpu_info.vendor == GSR_GPU_VENDOR_AMD && video_codec_context->codec_id == AV_CODEC_ID_AV1) {
|
} else if(self->params.egl->gpu_info.vendor == GSR_GPU_VENDOR_AMD && video_codec_context->codec_id == AV_CODEC_ID_AV1) {
|
||||||
// TODO: Dont do this for VCN 5 and forward which should fix this hardware bug
|
// TODO: Dont do this for VCN 5 and forward which should fix this hardware bug
|
||||||
|
|||||||
@@ -59,17 +59,26 @@ struct pa_handle {
|
|||||||
std::mutex reconnect_mutex;
|
std::mutex reconnect_mutex;
|
||||||
DeviceType device_type;
|
DeviceType device_type;
|
||||||
char stream_name[256];
|
char stream_name[256];
|
||||||
|
char node_name[256];
|
||||||
bool reconnect;
|
bool reconnect;
|
||||||
double reconnect_last_tried_seconds;
|
double reconnect_last_tried_seconds;
|
||||||
|
|
||||||
char device_name[DEVICE_NAME_MAX_SIZE];
|
char device_name[DEVICE_NAME_MAX_SIZE];
|
||||||
char default_output_device_name[DEVICE_NAME_MAX_SIZE];
|
char default_output_device_name[DEVICE_NAME_MAX_SIZE];
|
||||||
char default_input_device_name[DEVICE_NAME_MAX_SIZE];
|
char default_input_device_name[DEVICE_NAME_MAX_SIZE];
|
||||||
|
|
||||||
|
pa_proplist *proplist;
|
||||||
|
bool connected;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void pa_sound_device_free(pa_handle *p) {
|
static void pa_sound_device_free(pa_handle *p) {
|
||||||
assert(p);
|
assert(p);
|
||||||
|
|
||||||
|
if(p->proplist) {
|
||||||
|
pa_proplist_free(p->proplist);
|
||||||
|
p->proplist = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (p->stream) {
|
if (p->stream) {
|
||||||
pa_stream_unref(p->stream);
|
pa_stream_unref(p->stream);
|
||||||
p->stream = NULL;
|
p->stream = NULL;
|
||||||
@@ -186,6 +195,7 @@ static pa_handle* pa_sound_device_new(const char *server,
|
|||||||
p = pa_xnew0(pa_handle, 1);
|
p = pa_xnew0(pa_handle, 1);
|
||||||
p->attr = *attr;
|
p->attr = *attr;
|
||||||
p->ss = *ss;
|
p->ss = *ss;
|
||||||
|
snprintf(p->node_name, sizeof(p->node_name), "%s", name);
|
||||||
snprintf(p->stream_name, sizeof(p->stream_name), "%s", stream_name);
|
snprintf(p->stream_name, sizeof(p->stream_name), "%s", stream_name);
|
||||||
|
|
||||||
p->reconnect = true;
|
p->reconnect = true;
|
||||||
@@ -206,17 +216,17 @@ static pa_handle* pa_sound_device_new(const char *server,
|
|||||||
p->output_length = buffer_size;
|
p->output_length = buffer_size;
|
||||||
p->output_index = 0;
|
p->output_index = 0;
|
||||||
|
|
||||||
pa_proplist *proplist = pa_proplist_new();
|
p->proplist = pa_proplist_new();
|
||||||
pa_proplist_sets(proplist, PA_PROP_MEDIA_ROLE, "production");
|
pa_proplist_sets(p->proplist, PA_PROP_MEDIA_ROLE, "production");
|
||||||
if(strcmp(device_name, "") == 0) {
|
if(strcmp(device_name, "") == 0) {
|
||||||
pa_proplist_sets(proplist, "node.autoconnect", "false");
|
pa_proplist_sets(p->proplist, "node.autoconnect", "false");
|
||||||
pa_proplist_sets(proplist, "node.dont-reconnect", "true");
|
pa_proplist_sets(p->proplist, "node.dont-reconnect", "true");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(p->mainloop = pa_mainloop_new()))
|
if (!(p->mainloop = pa_mainloop_new()))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (!(p->context = pa_context_new_with_proplist(pa_mainloop_get_api(p->mainloop), name, proplist)))
|
if (!(p->context = pa_context_new_with_proplist(pa_mainloop_get_api(p->mainloop), p->node_name, p->proplist)))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (pa_context_connect(p->context, server, PA_CONTEXT_NOFLAGS, NULL) < 0) {
|
if (pa_context_connect(p->context, server, PA_CONTEXT_NOFLAGS, NULL) < 0) {
|
||||||
@@ -246,17 +256,58 @@ static pa_handle* pa_sound_device_new(const char *server,
|
|||||||
if(pa)
|
if(pa)
|
||||||
pa_operation_unref(pa);
|
pa_operation_unref(pa);
|
||||||
|
|
||||||
pa_proplist_free(proplist);
|
p->connected = true;
|
||||||
return p;
|
return p;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
if (rerror)
|
if (rerror)
|
||||||
*rerror = error;
|
*rerror = error;
|
||||||
pa_sound_device_free(p);
|
pa_sound_device_free(p);
|
||||||
pa_proplist_free(proplist);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void pa_sound_device_update_context_status(pa_handle *p) {
|
||||||
|
if(p->connected || !p->context || pa_context_get_state(p->context) != PA_CONTEXT_READY)
|
||||||
|
return;
|
||||||
|
|
||||||
|
p->connected = true;
|
||||||
|
pa_context_set_subscribe_callback(p->context, subscribe_cb, p);
|
||||||
|
pa_operation *pa = pa_context_subscribe(p->context, PA_SUBSCRIPTION_MASK_SERVER, NULL, NULL);
|
||||||
|
if(pa)
|
||||||
|
pa_operation_unref(pa);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool pa_sound_device_handle_context_recreate(pa_handle *p) {
|
||||||
|
if(p->context) {
|
||||||
|
pa_context_disconnect(p->context);
|
||||||
|
pa_context_unref(p->context);
|
||||||
|
p->context = NULL;
|
||||||
|
p->connected = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(p->context = pa_context_new_with_proplist(pa_mainloop_get_api(p->mainloop), p->node_name, p->proplist))) {
|
||||||
|
fprintf(stderr, "gsr error: pa_context_new_with_proplist failed\n");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(pa_context_connect(p->context, nullptr, PA_CONTEXT_NOFLAGS, NULL) < 0) {
|
||||||
|
fprintf(stderr, "gsr error: pa_context_connect failed\n");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
pa_mainloop_iterate(p->mainloop, 0, NULL);
|
||||||
|
pa_sound_device_update_context_status(p);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
if(p->context) {
|
||||||
|
pa_context_disconnect(p->context);
|
||||||
|
pa_context_unref(p->context);
|
||||||
|
p->context = NULL;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static bool pa_sound_device_should_reconnect(pa_handle *p, double now, char *device_name, size_t device_name_size) {
|
static bool pa_sound_device_should_reconnect(pa_handle *p, double now, char *device_name, size_t device_name_size) {
|
||||||
std::lock_guard<std::mutex> lock(p->reconnect_mutex);
|
std::lock_guard<std::mutex> lock(p->reconnect_mutex);
|
||||||
|
|
||||||
@@ -276,7 +327,6 @@ static bool pa_sound_device_should_reconnect(pa_handle *p, double now, char *dev
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool pa_sound_device_handle_reconnect(pa_handle *p, char *device_name, size_t device_name_size, double now) {
|
static bool pa_sound_device_handle_reconnect(pa_handle *p, char *device_name, size_t device_name_size, double now) {
|
||||||
int r;
|
|
||||||
if(!pa_sound_device_should_reconnect(p, now, device_name, device_name_size))
|
if(!pa_sound_device_should_reconnect(p, now, device_name, device_name_size))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -284,6 +334,10 @@ static bool pa_sound_device_handle_reconnect(pa_handle *p, char *device_name, si
|
|||||||
pa_stream_disconnect(p->stream);
|
pa_stream_disconnect(p->stream);
|
||||||
pa_stream_unref(p->stream);
|
pa_stream_unref(p->stream);
|
||||||
p->stream = NULL;
|
p->stream = NULL;
|
||||||
|
|
||||||
|
pa_sound_device_handle_context_recreate(p);
|
||||||
|
if(!p->connected)
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!(p->stream = pa_stream_new(p->context, p->stream_name, &p->ss, NULL))) {
|
if(!(p->stream = pa_stream_new(p->context, p->stream_name, &p->ss, NULL))) {
|
||||||
@@ -291,8 +345,8 @@ static bool pa_sound_device_handle_reconnect(pa_handle *p, char *device_name, si
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = pa_stream_connect_record(p->stream, device_name, &p->attr,
|
const int r = pa_stream_connect_record(p->stream, device_name, &p->attr,
|
||||||
(pa_stream_flags_t)(PA_STREAM_INTERPOLATE_TIMING|PA_STREAM_ADJUST_LATENCY|PA_STREAM_AUTO_TIMING_UPDATE));
|
(pa_stream_flags_t)(PA_STREAM_INTERPOLATE_TIMING|PA_STREAM_ADJUST_LATENCY|PA_STREAM_AUTO_TIMING_UPDATE|PA_STREAM_DONT_MOVE));
|
||||||
|
|
||||||
if(r < 0) {
|
if(r < 0) {
|
||||||
//pa_context_errno(p->context);
|
//pa_context_errno(p->context);
|
||||||
@@ -320,6 +374,15 @@ static int pa_sound_device_read(pa_handle *p, double timeout_seconds) {
|
|||||||
|
|
||||||
pa_mainloop_iterate(p->mainloop, 0, NULL);
|
pa_mainloop_iterate(p->mainloop, 0, NULL);
|
||||||
|
|
||||||
|
if(!p->context) {
|
||||||
|
if(!pa_sound_device_handle_context_recreate(p))
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
pa_sound_device_update_context_status(p);
|
||||||
|
if(!p->connected)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
if(!pa_sound_device_handle_reconnect(p, device_name, sizeof(device_name), start_time) || !p->stream)
|
if(!pa_sound_device_handle_reconnect(p, device_name, sizeof(device_name), start_time) || !p->stream)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user