(task_save) Use flags instead of booleans
(task_screenshot) Start reducing amount of parameters
This commit is contained in:
parent
11047c6f4d
commit
07378abbdf
2 changed files with 30 additions and 32 deletions
|
@ -135,6 +135,12 @@ struct autosave_st
|
|||
unsigned num;
|
||||
};
|
||||
|
||||
enum autosave_flags
|
||||
{
|
||||
AUTOSAVE_FLAG_QUIT = (1 << 0),
|
||||
AUTOSAVE_FLAG_COMPRESS_FILES = (1 << 1)
|
||||
};
|
||||
|
||||
struct autosave
|
||||
{
|
||||
void *buffer;
|
||||
|
@ -146,8 +152,7 @@ struct autosave
|
|||
sthread_t *thread;
|
||||
size_t bufsize;
|
||||
unsigned interval;
|
||||
bool quit;
|
||||
bool compress_files;
|
||||
uint8_t flags;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -208,7 +213,7 @@ static void autosave_thread(void *data)
|
|||
intfstream_t *file = NULL;
|
||||
|
||||
/* Should probably deal with this more elegantly. */
|
||||
if (save->compress_files)
|
||||
if (save->flags & AUTOSAVE_FLAG_COMPRESS_FILES)
|
||||
file = intfstream_open_rzip_file(save->path,
|
||||
RETRO_VFS_FILE_ACCESS_WRITE);
|
||||
else
|
||||
|
@ -226,7 +231,7 @@ static void autosave_thread(void *data)
|
|||
|
||||
slock_lock(save->cond_lock);
|
||||
|
||||
if (save->quit)
|
||||
if (save->flags & AUTOSAVE_FLAG_QUIT)
|
||||
{
|
||||
slock_unlock(save->cond_lock);
|
||||
break;
|
||||
|
@ -266,10 +271,11 @@ static autosave_t *autosave_new(const char *path,
|
|||
if (!handle)
|
||||
return NULL;
|
||||
|
||||
handle->quit = false;
|
||||
handle->flags = 0;
|
||||
handle->bufsize = size;
|
||||
handle->interval = interval;
|
||||
handle->compress_files = compress;
|
||||
if (compress)
|
||||
handle->flags |= AUTOSAVE_FLAG_COMPRESS_FILES;
|
||||
handle->retro_buffer = data;
|
||||
handle->path = path;
|
||||
|
||||
|
@ -300,7 +306,7 @@ static autosave_t *autosave_new(const char *path,
|
|||
static void autosave_free(autosave_t *handle)
|
||||
{
|
||||
slock_lock(handle->cond_lock);
|
||||
handle->quit = true;
|
||||
handle->flags |= AUTOSAVE_FLAG_QUIT;
|
||||
slock_unlock(handle->cond_lock);
|
||||
scond_signal(handle->cond);
|
||||
sthread_join(handle->thread);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue