summaryrefslogtreecommitdiff
path: root/src/libsink
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsink')
-rw-r--r--src/libsink/desktop.c23
-rw-r--r--src/libsink/desktop.h5
-rw-r--r--src/libsink/input_simulator.c37
3 files changed, 43 insertions, 22 deletions
diff --git a/src/libsink/desktop.c b/src/libsink/desktop.c
index 35c0b1b..780818c 100644
--- a/src/libsink/desktop.c
+++ b/src/libsink/desktop.c
@@ -63,25 +63,25 @@ static u8 sink_callback(void *userdata, u8 op, u8 type, void *opaque)
case CAMU_SINK_START:
switch (type) {
case CAMU_SINK_AUDIO:
+ log_info("Starting audio.");
camu_mixer_resume(mixer);
- log_info("Audio started.");
break;
case CAMU_SINK_VIDEO:
+ log_info("Starting video.");
camu_screen_set_state(scr, CAMU_SCREEN_PLAYING);
camu_screen_wake(scr);
- log_info("Video started.");
break;
}
break;
case CAMU_SINK_STOP:
switch (type) {
case CAMU_SINK_AUDIO:
+ log_info("Stopping audio.");
camu_mixer_pause(mixer);
- log_info("Audio stopped.");
break;
case CAMU_SINK_VIDEO:
+ log_info("Stopping video.");
camu_screen_set_state(scr, CAMU_SCREEN_PAUSED);
- log_info("Video stopped.");
break;
}
break;
@@ -143,7 +143,7 @@ static void log_sink_status(struct camu_desktop *c)
offset += al_snprintf(status + offset, sizeof(status) - offset, "]");
status[offset] = '\0';
- log_info("%s, window size: %ux%u, volume: %f", status, c->scr.width, c->scr.height, c->mixer.volume);
+ log_info("%s, window size: %ux%u, volume: %.2f", status, c->scr.width, c->scr.height, c->mixer.volume);
return;
notplaying:
log_info("Not playing, window size: %ux%u", c->scr.width, c->scr.height);
@@ -153,12 +153,17 @@ static void screen_callback(void *userdata, u8 op, void *opaque)
{
struct camu_desktop *c = (struct camu_desktop *)userdata;
switch (op) {
- case CAMU_SCREEN_SET_VOLUME:
- camu_mixer_set_volume(&c->mixer, *(f32 *)opaque);
+ case CAMU_SCREEN_SET_VOLUME: {
+ f32 volume = *(f32 *)opaque;
+ camu_mixer_set_volume(&c->mixer, volume);
+ log_info("Volume: %f.", volume);
break;
- case CAMU_SCREEN_OFFSET_VOLUME:
- camu_mixer_offset_volume(&c->mixer, *(f32 *)opaque);
+ }
+ case CAMU_SCREEN_OFFSET_VOLUME: {
+ f32 volume = camu_mixer_offset_volume(&c->mixer, *(f32 *)opaque);
+ log_info("Volume: %f.", volume);
break;
+ }
case CAMU_SCREEN_SKIP:
camu_sink_skip(&c->sink, *(s32 *)opaque);
break;
diff --git a/src/libsink/desktop.h b/src/libsink/desktop.h
index 279fd7b..3c66a22 100644
--- a/src/libsink/desktop.h
+++ b/src/libsink/desktop.h
@@ -4,9 +4,10 @@
#include <al/str.h>
#include <nnwt/event_loop.h>
-#include "../libsink/sink.h"
-
#include "../screen/screen.h"
+#include "../render/renderer.h"
+#include "../mixer/mixer.h"
+#include "../libsink/sink.h"
struct camu_desktop {
struct nn_event_loop *loop;
diff --git a/src/libsink/input_simulator.c b/src/libsink/input_simulator.c
index 871f0ce..19786af 100644
--- a/src/libsink/input_simulator.c
+++ b/src/libsink/input_simulator.c
@@ -1,7 +1,9 @@
#include "../screen/screen.h"
#ifdef CAMU_SCREEN_DEBUG_KEY
-#include <nnwt/thread.h>
+#define AL_LOG_SECTION "input_simulator"
+#include <al/log.h>
#include <al/random.h>
+#include <nnwt/thread.h>
#include "input_simulator.h"
@@ -10,10 +12,10 @@ static s32 quit = 1;
static struct nn_thread thread;
enum {
- SEEK,
SKIP,
BACKSKIP,
TOGGLE_PAUSE,
+ SEEK,
SHUFFLE,
MARK, // count
};
@@ -23,25 +25,38 @@ static nn_thread_result NNWT_THREADCALL input_simulation_thread(void *userdata)
struct camu_sink *sink = (struct camu_sink *)userdata;
nn_thread_set_name("input_simulator");
while (!quit) {
- nn_thread_sleep(NNWT_TS_FROM_USEC(60000));
- switch (al_rand() % MARK) {
- case SKIP:
- camu_sink_skip(sink, (al_rand() % 5));
+ //nn_thread_sleep(NNWT_TS_FROM_USEC(2000000 + al_random_int(0, 1750000)));
+ //nn_thread_sleep(NNWT_TS_FROM_USEC(60000));
+ nn_thread_sleep(NNWT_TS_FROM_USEC(30000));
+ switch (al_random_int(0, MARK - 1)) {
+ case SKIP: {
+ s32 n = al_random_int(1, 5);
+ log_debug("SKIP (n: %d).", n);
+ camu_sink_skip(sink, n);
break;
- case BACKSKIP:
- camu_sink_skip(sink, -(al_rand() % 5));
+ }
+ case BACKSKIP: {
+ s32 n = al_random_int(-5, -1);
+ log_debug("BACKSKIP (n: %d).", n);
+ camu_sink_skip(sink, n);
break;
- case SHUFFLE:
+ }
+ case SHUFFLE: {
+ log_debug("SHUFFLE.");
camu_sink_shuffle(sink);
break;
- case TOGGLE_PAUSE:
+ }
+ case TOGGLE_PAUSE: {
+ log_debug("TOGGLE_PAUSE.");
camu_sink_toggle_pause(sink);
break;
+ }
case SEEK: {
f64 pos = al_rand() / (f64)AL_RAND_MAX;
if (pos < 0.005) pos = 0.0;
if (pos > 0.995) pos = 1.0;
- else if (pos > 0.99) pos = .9999;
+ else if (pos > 0.99) pos = 0.9999;
+ log_debug("SEEK (pos: %f).", pos);
camu_sink_seek(sink, &pos, CAMU_SEEK_PERCENT);
break;
}