diff options
| author | 2024-12-07 23:47:36 -0500 | |
|---|---|---|
| committer | 2024-12-07 23:47:36 -0500 | |
| commit | d81c406f62e996840d86333b81c41d0ae4aff347 (patch) | |
| tree | 9e6baf260ec56d14e8931b61936b0d043cb49847 /src/fruits/cmv | |
| parent | d4da3d8a644156b9f24b560eba58a87b912c1fef (diff) | |
| download | camu-d81c406f62e996840d86333b81c41d0ae4aff347.tar.gz camu-d81c406f62e996840d86333b81c41d0ae4aff347.tar.bz2 camu-d81c406f62e996840d86333b81c41d0ae4aff347.zip | |
Synced list reference 1
This marks a point where the list behavior is at least moderately robust
for the skip operation. It includes fixes for multiple deep-rooted
issues found by testing with input simulation.
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'src/fruits/cmv')
| -rw-r--r-- | src/fruits/cmv/cmv.c | 6 | ||||
| -rw-r--r-- | src/fruits/cmv/input_simulator.c | 53 | ||||
| -rw-r--r-- | src/fruits/cmv/input_simulator.h | 6 | ||||
| -rw-r--r-- | src/fruits/cmv/meson.build | 2 |
4 files changed, 66 insertions, 1 deletions
diff --git a/src/fruits/cmv/cmv.c b/src/fruits/cmv/cmv.c index 0fe33ad..9e3be3f 100644 --- a/src/fruits/cmv/cmv.c +++ b/src/fruits/cmv/cmv.c @@ -11,6 +11,8 @@ #include "../../server/common.c" #endif +#include "input_simulator.h" + struct cmv { struct aki_event_loop loop; struct camu_desktop desktop; @@ -121,8 +123,12 @@ s32 wmain(s32 argc, wchar_t **argv) struct aki_thread thread0; aki_thread_create(&thread0, event_loop_thread, &c); + //cmv_input_simulator_run(&c.desktop.sink); + while (camu_desktop_tick(&c.desktop)) {} + //cmv_input_simulator_stop(); + camu_desktop_stop(&c.desktop); aki_thread_join(&thread0); camu_desktop_free(&c.desktop); diff --git a/src/fruits/cmv/input_simulator.c b/src/fruits/cmv/input_simulator.c new file mode 100644 index 0000000..7bc3125 --- /dev/null +++ b/src/fruits/cmv/input_simulator.c @@ -0,0 +1,53 @@ +#include <aki/thread.h> +#include <al/random.h> + +#include "input_simulator.h" + +static struct aki_thread thread; +static s32 quit = 0; + +enum { + SKIP = 0, + BACKSKIP, + SHUFFLE, + BASE, // count + TOGGLE_PAUSE, + SEEK, +}; + +static aki_thread_result AKI_THREADCALL input_simulation_thread(void *userdata) +{ + struct camu_sink *sink = (struct camu_sink *)userdata; + while (!quit) { + aki_thread_sleep(AKI_TS_FROM_USEC(30000)); + switch (al_rand() % BASE) { + case SKIP: + camu_sink_skip(sink, (al_rand() % 5)); + break; + case BACKSKIP: + camu_sink_skip(sink, -(al_rand() % 5)); + break; + case SHUFFLE: + camu_sink_shuffle(sink); + break; + case TOGGLE_PAUSE: + camu_sink_toggle_pause(sink); + break; + case SEEK: + camu_sink_seek(sink, 0.0); + break; + } + } + return 0; +} + +void cmv_input_simulator_run(struct camu_sink *sink) +{ + aki_thread_create(&thread, input_simulation_thread, sink); +} + +void cmv_input_simulator_stop(void) +{ + quit = 1; + aki_thread_join(&thread); +} diff --git a/src/fruits/cmv/input_simulator.h b/src/fruits/cmv/input_simulator.h new file mode 100644 index 0000000..5380bb2 --- /dev/null +++ b/src/fruits/cmv/input_simulator.h @@ -0,0 +1,6 @@ +#pragma once + +#include "../../libsink/sink.h" + +void cmv_input_simulator_run(struct camu_sink *sink); +void cmv_input_simulator_stop(void); diff --git a/src/fruits/cmv/meson.build b/src/fruits/cmv/meson.build index 9b83847..b2ab0a2 100644 --- a/src/fruits/cmv/meson.build +++ b/src/fruits/cmv/meson.build @@ -1,4 +1,4 @@ -cmv_src = ['cmv.c'] +cmv_src = ['cmv.c', 'input_simulator.c'] cmv_deps = [common_deps, desktop] cmv_args = [] if get_option('sink-only') |