Skip to content

Commit 48848f6

Browse files
committed
Updates
1 parent 67a46f8 commit 48848f6

5 files changed

Lines changed: 201 additions & 21 deletions

File tree

formats/libchdr/libchdr_chd.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -826,14 +826,13 @@ chd_error chd_open_file(RFILE *file, int mode, chd_file *parent, chd_file **chd)
826826
if (newchd->header.version < 5)
827827
{
828828
err = map_read(newchd);
829-
if (err != CHDERR_NONE)
830-
EARLY_EXIT(err);
831829
}
832830
else
833831
{
834832
err = decompress_v5_map(newchd, &(newchd->header));
835-
(void)err;
836833
}
834+
if (err != CHDERR_NONE)
835+
EARLY_EXIT(err);
837836

838837
#ifdef NEED_CACHE_HUNK
839838
/* allocate and init the hunk cache */

include/streams/interface_stream.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ enum intfstream_type
3636
{
3737
INTFSTREAM_FILE = 0,
3838
INTFSTREAM_MEMORY,
39-
INTFSTREAM_CHD
39+
INTFSTREAM_CHD,
40+
INTFSTREAM_RZIP
4041
};
4142

4243
typedef struct intfstream_internal intfstream_internal_t, intfstream_t;
@@ -74,6 +75,9 @@ int64_t intfstream_read(intfstream_internal_t *intf,
7475
int64_t intfstream_write(intfstream_internal_t *intf,
7576
const void *s, uint64_t len);
7677

78+
int intfstream_printf(intfstream_internal_t *intf,
79+
const char* format, ...);
80+
7781
int64_t intfstream_get_ptr(intfstream_internal_t *intf);
7882

7983
char *intfstream_gets(intfstream_internal_t *intf,
@@ -100,6 +104,8 @@ uint32_t intfstream_get_offset_to_start(intfstream_internal_t *intf);
100104

101105
uint32_t intfstream_get_frame_size(intfstream_internal_t *intf);
102106

107+
bool intfstream_is_compressed(intfstream_internal_t *intf);
108+
103109
intfstream_t* intfstream_open_file(const char *path,
104110
unsigned mode, unsigned hints);
105111

@@ -112,6 +118,9 @@ intfstream_t *intfstream_open_writable_memory(void *data,
112118
intfstream_t *intfstream_open_chd_track(const char *path,
113119
unsigned mode, unsigned hints, int32_t track);
114120

121+
intfstream_t* intfstream_open_rzip_file(const char *path,
122+
unsigned mode);
123+
115124
RETRO_END_DECLS
116125

117126
#endif

queues/task_queue.c

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -313,23 +313,20 @@ static scond_t *worker_cond = NULL;
313313
static sthread_t *worker_thread = NULL;
314314
static bool worker_continue = true; /* use running_lock when touching it */
315315

316+
/* 'queue_lock' must be held for the duration of this function */
316317
static void task_queue_remove(task_queue_t *queue, retro_task_t *task)
317318
{
318319
retro_task_t *t = NULL;
319320
retro_task_t *front = NULL;
320321

321-
slock_lock(queue_lock);
322322
front = queue->front;
323-
slock_unlock(queue_lock);
324323

325324
/* Remove first element if needed */
326325
if (task == front)
327326
{
328-
slock_lock(queue_lock);
329327
queue->front = task->next;
330328
if (queue->back == task) /* if only element, also update back */
331329
queue->back = NULL;
332-
slock_unlock(queue_lock);
333330
task->next = NULL;
334331
return;
335332
}
@@ -348,10 +345,8 @@ static void task_queue_remove(task_queue_t *queue, retro_task_t *task)
348345
/* When removing the tail of the queue, update the tail pointer */
349346
if (queue->back == task)
350347
{
351-
slock_lock(queue_lock);
352348
if (queue->back == task)
353349
queue->back = t;
354-
slock_unlock(queue_lock);
355350
}
356351
break;
357352
}
@@ -506,18 +501,31 @@ static void threaded_worker(void *userdata)
506501
finished = task->finished;
507502
slock_unlock(property_lock);
508503

509-
slock_lock(running_lock);
510-
task_queue_remove(&tasks_running, task);
511-
slock_unlock(running_lock);
512-
513504
/* Update queue */
514505
if (!finished)
515506
{
516-
/* Re-add task to running queue */
517-
retro_task_threaded_push_running(task);
507+
/* Move the task to the back of the queue */
508+
/* mimics retro_task_threaded_push_running, but also includes a task_queue_remove */
509+
slock_lock(running_lock);
510+
slock_lock(queue_lock);
511+
if (task->next != NULL) /* do nothing if only item in queue */
512+
{
513+
task_queue_remove(&tasks_running, task);
514+
task_queue_put(&tasks_running, task);
515+
scond_signal(worker_cond);
516+
}
517+
slock_unlock(queue_lock);
518+
slock_unlock(running_lock);
518519
}
519520
else
520521
{
522+
/* Remove task from running queue */
523+
slock_lock(running_lock);
524+
slock_lock(queue_lock);
525+
task_queue_remove(&tasks_running, task);
526+
slock_unlock(queue_lock);
527+
slock_unlock(running_lock);
528+
521529
/* Add task to finished queue */
522530
slock_lock(finished_lock);
523531
task_queue_put(&tasks_finished, task);

0 commit comments

Comments
 (0)