diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/buffer/volume.h | 19 | ||||
| -rw-r--r-- | src/codec/ffmpeg/decoder.c | 4 | ||||
| -rw-r--r-- | src/fruits/ctv/ctv.c | 2 | ||||
| -rw-r--r-- | src/fruits/droid/ctv/gradle/libs.versions.toml | 2 | ||||
| -rw-r--r-- | src/libsink/sink.c | 7 | ||||
| -rw-r--r-- | src/screen/screen.c | 4 |
6 files changed, 22 insertions, 16 deletions
diff --git a/src/buffer/volume.h b/src/buffer/volume.h index 87b1945..7d10e6d 100644 --- a/src/buffer/volume.h +++ b/src/buffer/volume.h @@ -1,10 +1,10 @@ #include "../codec/codec.h" -static inline f32 apply_volume_f32(f32 *data, size_t sample_count, s32 channel_count, f32 volume, f32 user, f32 step) +static inline f32 apply_volume_f32(f32 *data, size_t sample_count, s32 channel_count, f32 volume, f32 limit, f32 step) { for (u32 i = 0; i < sample_count; i++) { if (step != 0.f && i % channel_count == 0) { - volume = CLAMP(volume + step, 0.f, user); + volume = CLAMP(volume + step, 0.f, limit); } f64 sample = (f64)data[i]; sample *= volume; @@ -13,11 +13,11 @@ static inline f32 apply_volume_f32(f32 *data, size_t sample_count, s32 channel_c return volume; } -static inline f32 apply_volume_s32(s32 *data, size_t sample_count, s32 channel_count, f32 volume, f32 user, f32 step) +static inline f32 apply_volume_s32(s32 *data, size_t sample_count, s32 channel_count, f32 volume, f32 limit, f32 step) { for (u32 i = 0; i < sample_count; i++) { if (step != 0.f && i % channel_count == 0) { - volume = CLAMP(volume + step, 0.f, user); + volume = CLAMP(volume + step, 0.f, limit); } f64 sample = (f64)data[i]; sample *= volume; @@ -26,11 +26,11 @@ static inline f32 apply_volume_s32(s32 *data, size_t sample_count, s32 channel_c return volume; } -static inline f32 apply_volume_s16(s16 *data, size_t sample_count, s32 channel_count, f32 volume, f32 user, f32 step) +static inline f32 apply_volume_s16(s16 *data, size_t sample_count, s32 channel_count, f32 volume, f32 limit, f32 step) { for (u32 i = 0; i < sample_count; i++) { if (step != 0.f && i % channel_count == 0) { - volume = CLAMP(volume + step, 0.f, user); + volume = CLAMP(volume + step, 0.f, limit); } f64 sample = (f64)data[i]; sample *= volume; @@ -42,19 +42,20 @@ static inline f32 apply_volume_s16(s16 *data, size_t sample_count, s32 channel_c static inline f32 apply_volume(u8 *data, size_t size, struct camu_audio_format *fmt, f32 volume, f32 user, f32 step) { size_t sample_count; + f32 limit = MAX(user, volume); switch (camu_audio_format_bytes_per_sample(fmt)) { case 4: sample_count = size / 4; if (fmt->format == CAMU_SAMPLE_FORMAT_S32) { - return apply_volume_s32((s32 *)data, sample_count, fmt->channel_count, volume, user, step); + return apply_volume_s32((s32 *)data, sample_count, fmt->channel_count, volume, limit, step); } else if (fmt->format == CAMU_SAMPLE_FORMAT_FLT) { - return apply_volume_f32((f32 *)data, sample_count, fmt->channel_count, volume, user, step); + return apply_volume_f32((f32 *)data, sample_count, fmt->channel_count, volume, limit, step); } break; case 2: sample_count = size / 2; if (fmt->format == CAMU_SAMPLE_FORMAT_S16) { - return apply_volume_s16((s16 *)data, sample_count, fmt->channel_count, volume, user, step); + return apply_volume_s16((s16 *)data, sample_count, fmt->channel_count, volume, limit, step); } break; } diff --git a/src/codec/ffmpeg/decoder.c b/src/codec/ffmpeg/decoder.c index 1675433..e22f184 100644 --- a/src/codec/ffmpeg/decoder.c +++ b/src/codec/ffmpeg/decoder.c @@ -3,12 +3,12 @@ #include <al/lib.h> #include <libavutil/cpu.h> +#include "decoder.h" + #if !defined CAMU_SINK_NO_VIDEO && defined CAMU_FF_DECODER_HWACCEL #include "../../render/renderer.h" #endif -#include "decoder.h" - #ifdef CAMU_FF_DECODER_HWACCEL #if defined CAMU_RENDERER_VULKAN static const char *hwdevces[] = { "vulkan" }; diff --git a/src/fruits/ctv/ctv.c b/src/fruits/ctv/ctv.c index 55ab773..804cbed 100644 --- a/src/fruits/ctv/ctv.c +++ b/src/fruits/ctv/ctv.c @@ -26,7 +26,7 @@ static nn_thread_result NNWT_THREADCALL event_loop_thread(void *userdata) prefs->audio_lang = CAMU_LANG_ENGLISH; prefs->subtitle_lang = CAMU_LANG_ENGLISH; - if (!camu_desktop_connect(&c->desktop, &c->loop, NNWT_SOCKET_TCP, &CAMU_TEST_ADDR, CAMU_PORT)) { + if (!camu_desktop_connect(&c->desktop, &c->loop, CAMU_TEST_TYPE, &CAMU_TEST_ADDR, CAMU_PORT)) { return 0; } diff --git a/src/fruits/droid/ctv/gradle/libs.versions.toml b/src/fruits/droid/ctv/gradle/libs.versions.toml index 6869a38..4a8d0bc 100644 --- a/src/fruits/droid/ctv/gradle/libs.versions.toml +++ b/src/fruits/droid/ctv/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -agp = "8.9.0" +agp = "8.9.1" [libraries] diff --git a/src/libsink/sink.c b/src/libsink/sink.c index fe87df5..2b9d585 100644 --- a/src/libsink/sink.c +++ b/src/libsink/sink.c @@ -469,10 +469,14 @@ static void mixer_callback(void *userdata, u8 op) if (op == CAMU_MIXER_EMPTY) { log_info("Mixer empty."); #ifndef LIANA_LIST_SCUFFED_LOOP + // We need to sync with do_add_entry() because the order of + // the START/STOP's in the queue matters. + nn_mutex_lock(&sink->lock); queue_cmd(sink, (struct camu_sink_cmd){ .op = STOP, .value.i = CAMU_SINK_AUDIO }); + nn_mutex_unlock(&sink->lock); #else (void)sink; #endif @@ -1643,7 +1647,8 @@ void camu_sink_seek(struct camu_sink *sink, void *value, u8 mode) } case CAMU_SEEK_RELATIVE: { f64 offset = *(f64 *)value; - cmd.value.u = (u64)((pts + offset) * 1000000); + pts = MAX(pts + offset, 0.0); + cmd.value.u = (u64)(pts * 1000000); break; } case CAMU_SEEK_PERCENT: { diff --git a/src/screen/screen.c b/src/screen/screen.c index 155668e..0e44dcd 100644 --- a/src/screen/screen.c +++ b/src/screen/screen.c @@ -225,8 +225,8 @@ static bool key_callback(void *userdata, u8 state, u16 button) case STELA_KEY_E: scr->callback(scr->userdata, CAMU_SCREEN_RESEEK, NULL); break; - case STELA_KEY_V: { - f32 volume = 1.0; + case STELA_KEY_M: { + f32 volume = SCREEN_MOD1(scr) ? 1.f : 0.f; scr->callback(scr->userdata, CAMU_SCREEN_SET_VOLUME, &volume); break; } |