diff --git a/Makefile.common b/Makefile.common index fbb7c1a430..58d1114b6a 100644 --- a/Makefile.common +++ b/Makefile.common @@ -122,7 +122,7 @@ OBJ += frontend/frontend.o \ intl/msg_hash_pt.o \ intl/msg_hash_us.o \ runloop.o \ - tasks/task_queue.o \ + libretro-common/rthreads/task_queue.o \ tasks/tasks_internal.o \ tasks/task_content.o \ tasks/task_file_transfer.o \ diff --git a/griffin/griffin.c b/griffin/griffin.c index 715a47d364..11259aec17 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -700,7 +700,7 @@ RETROARCH #include "../libretro_version_1.c" #include "../retroarch.c" #include "../runloop.c" -#include "../tasks/task_queue.c" +#include "../libretro-common/rthreads/task_queue.c" #include "../tasks/tasks_internal.c" #include "../msg_hash.c" diff --git a/tasks/task_queue.h b/libretro-common/include/rthreads/task_queue.h similarity index 67% rename from tasks/task_queue.h rename to libretro-common/include/rthreads/task_queue.h index 48c401a5de..2825928577 100644 --- a/tasks/task_queue.h +++ b/libretro-common/include/rthreads/task_queue.h @@ -1,21 +1,27 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2011-2016 - Higor Euripedes - * Copyright (C) 2011-2016 - Daniel De Matteis +/* Copyright (C) 2010-2016 The RetroArch team * - * RetroArch is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (task_queue.h). + * --------------------------------------------------------------------------------------- * - * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. + * Permission is hereby granted, free of charge, + * to any person obtaining a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: * - * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see . + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef TASK_QUEUE_H -#define TASK_QUEUE_H +#ifndef __LIBRETRO_SDK_TASK_QUEUE_H__ +#define __LIBRETRO_SDK_TASK_QUEUE_H__ #include #include diff --git a/tasks/task_queue.c b/libretro-common/rthreads/task_queue.c similarity index 79% rename from tasks/task_queue.c rename to libretro-common/rthreads/task_queue.c index 03b87b6d23..2669ee6897 100644 --- a/tasks/task_queue.c +++ b/libretro-common/rthreads/task_queue.c @@ -1,24 +1,30 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2011-2016 - Higor Euripedes - * Copyright (C) 2011-2016 - Daniel De Matteis +/* Copyright (C) 2010-2016 The RetroArch team * - * RetroArch is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (task_queue.c). + * --------------------------------------------------------------------------------------- * - * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. + * Permission is hereby granted, free of charge, + * to any person obtaining a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: * - * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see . + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include #include #include -#include "task_queue.h" +#include #ifdef HAVE_THREADS #include @@ -44,6 +50,44 @@ struct retro_task_impl static task_queue_t tasks_running = {NULL, NULL}; static task_queue_t tasks_finished = {NULL, NULL}; +#ifndef RARCH_INTERNAL +static void task_queue_msg_push(unsigned prio, unsigned duration, + bool flush, const char *fmt, ...) +{ + char buf[1024]; + va_list ap; + + va_start(ap, fmt); + vsnprintf(buf, sizeof(buf), fmt, ap); + va_end(ap); + + /* print something here */ +} + +void task_queue_push_progress(retro_task_t *task) +{ + if (task->title) + { + if (task->finished) + { + if (task->error) + task_queue_msg_push(1, 60, true, "%s: %s", + "Task failed\n", task->title); + else + task_queue_msg_push(1, 60, true, "100%%: %s", task->title); + } + else + { + if (task->progress >= 0 && task->progress <= 100) + task_queue_msg_push(1, 60, true, "%i%%: %s", + task->progress, task->title); + else + task_queue_msg_push(1, 60, true, "%s...", task->title); + } + } +} +#endif + static void task_queue_put(task_queue_t *queue, retro_task_t *task) { task->next = NULL; diff --git a/retroarch.c b/retroarch.c index e8287cec50..0dd0d08298 100644 --- a/retroarch.c +++ b/retroarch.c @@ -55,7 +55,6 @@ #include "configuration.h" #include "general.h" #include "runloop.h" -#include "tasks/task_queue.h" #include "performance.h" #include "cheats.h" #include "system.h" diff --git a/runloop.c b/runloop.c index 471c7c9a3d..9d50f1ee61 100644 --- a/runloop.c +++ b/runloop.c @@ -27,6 +27,7 @@ #ifdef HAVE_THREADS #include #endif +#include #include #include @@ -54,7 +55,6 @@ #include "msg_hash.h" -#include "tasks/task_queue.h" #include "input/input_keyboard.h" #ifdef HAVE_MENU diff --git a/tasks/tasks_internal.c b/tasks/tasks_internal.c index 9ec9047235..2ae5e44b7b 100644 --- a/tasks/tasks_internal.c +++ b/tasks/tasks_internal.c @@ -18,12 +18,12 @@ #include #include -#include "task_queue.h" +#include "tasks_internal.h" #include "../msg_hash.h" #include "../runloop.h" -static void task_msg_queue_pushf(unsigned prio, unsigned duration, +static void task_queue_msg_push(unsigned prio, unsigned duration, bool flush, const char *fmt, ...) { char buf[1024]; @@ -42,18 +42,18 @@ void task_queue_push_progress(retro_task_t *task) if (task->finished) { if (task->error) - task_msg_queue_pushf(1, 60, true, "%s: %s", + task_queue_msg_push(1, 60, true, "%s: %s", msg_hash_to_str(MSG_TASK_FAILED), task->title); else - task_msg_queue_pushf(1, 60, true, "100%%: %s", task->title); + task_queue_msg_push(1, 60, true, "100%%: %s", task->title); } else { if (task->progress >= 0 && task->progress <= 100) - task_msg_queue_pushf(1, 60, true, "%i%%: %s", + task_queue_msg_push(1, 60, true, "%i%%: %s", task->progress, task->title); else - task_msg_queue_pushf(1, 60, true, "%s...", task->title); + task_queue_msg_push(1, 60, true, "%s...", task->title); } } } diff --git a/tasks/tasks_internal.h b/tasks/tasks_internal.h index eff0e4b73a..514969cc21 100644 --- a/tasks/tasks_internal.h +++ b/tasks/tasks_internal.h @@ -19,7 +19,7 @@ #include #include -#include "task_queue.h" +#include #include "../runloop.h"