Make screenshots thread-safe
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
using atomic_bool = std::atomic_bool;
|
using atomic_bool = std::atomic_bool;
|
||||||
|
using atomic_int = std::atomic_int;
|
||||||
#else
|
#else
|
||||||
#include <stdatomic.h>
|
#include <stdatomic.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -112,7 +113,7 @@ typedef struct monitor_t
|
|||||||
int mon_force_resize;
|
int mon_force_resize;
|
||||||
int mon_fullchange;
|
int mon_fullchange;
|
||||||
int mon_changeframecount;
|
int mon_changeframecount;
|
||||||
int mon_screenshots;
|
atomic_int mon_screenshots;
|
||||||
uint32_t* mon_pal_lookup;
|
uint32_t* mon_pal_lookup;
|
||||||
int* mon_cga_palette;
|
int* mon_cga_palette;
|
||||||
int mon_pal_lookup_static; /* Whether it should not be freed by the API. */
|
int mon_pal_lookup_static; /* Whether it should not be freed by the API. */
|
||||||
|
@@ -442,7 +442,7 @@ video_screenshot_monitor(uint32_t *buf, int start_x, int start_y, int row_len, i
|
|||||||
video_take_screenshot_monitor((const char *) path, buf, start_x, start_y, row_len, monitor_index);
|
video_take_screenshot_monitor((const char *) path, buf, start_x, start_y, row_len, monitor_index);
|
||||||
png_destroy_write_struct(&png_ptr[monitor_index], &info_ptr[monitor_index]);
|
png_destroy_write_struct(&png_ptr[monitor_index], &info_ptr[monitor_index]);
|
||||||
|
|
||||||
monitors[monitor_index].mon_screenshots--;
|
atomic_fetch_sub(&monitors[monitor_index].mon_screenshots, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -942,6 +942,7 @@ video_monitor_init(int index)
|
|||||||
monitors[index].mon_force_resize = 1;
|
monitors[index].mon_force_resize = 1;
|
||||||
monitors[index].mon_vid_type = VIDEO_FLAG_TYPE_NONE;
|
monitors[index].mon_vid_type = VIDEO_FLAG_TYPE_NONE;
|
||||||
atomic_init(&doresize_monitors[index], 0);
|
atomic_init(&doresize_monitors[index], 0);
|
||||||
|
atomic_init(&monitors[index].mon_screenshots, 0);
|
||||||
if (index >= 1) ui_init_monitor(index);
|
if (index >= 1) ui_init_monitor(index);
|
||||||
monitors[index].mon_blit_data_ptr->blit_thread = thread_create(blit_thread, monitors[index].mon_blit_data_ptr);
|
monitors[index].mon_blit_data_ptr->blit_thread = thread_create(blit_thread, monitors[index].mon_blit_data_ptr);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user