Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: GPL-3.0-only
SDK ?= ../osos-lab/rvx-sdk
OUT ?= build
extensions := balance crossfeed dsp night-shift playback-log
extensions := balance crossfeed dsp fast-seek long-audio-fix night-shift playback-log sleep-timer

.PHONY: all $(extensions)
all: $(extensions)
Expand Down
8 changes: 7 additions & 1 deletion NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ Balance, Crossfeed, DSP and the Night Shift scheduling and gamma code are from
RevolaOS extensions, revision 36d197b180e55a304ea0468de4330c0d07fe715f.
Night Shift derives from kayboll’s RepriseOS work. Playback Log derives from
the work of brilliant-alien and lgreitis in osos-lab. Its Settings artwork is
from osos-lab commit 10485fa. The original RevolaOS notice follows.
from osos-lab commit 10485fa. Sleep Timer, Fast Seek and Long Audio Fix are
from RevolaOS extensions, revision c179e6dc21ea8a32e46bf9af1d0906c8793190e8.
Sleep Timer is based on kayboll’s RepriseOS Sleep Timer shortcut; Fast Seek
and Long Audio Fix are the same fixes as kayboll’s RepriseOS pull requests
63 and 62. Their catalog icons and the Sleep Timer moon are Cupertino Icons
glyphs (MIT), see the LICENSE.cupertino-icons beside each. The original
RevolaOS notice follows.

RevolaOS
Copyright (C) 2026 The RevolaOS Authors. GPL-3.0-only.
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@ This repository hosts the source for these RepriseOS extensions and accepts prop
- [Night Shift](extensions/night-shift/) warms the display manually or automatically from sunset to sunrise.
- [Playback Log](extensions/playback-log/) records listening history for scrobbling and optional detailed reports.
- [Crossfeed](extensions/crossfeed/) blends a little of each stereo channel into the other for headphone listening. It uses the included [DSP library](extensions/dsp/).
- [Sleep Timer](extensions/sleep-timer/) sets Apple's sleep timer from the Now Playing context menu and shows the minutes left in Now Playing.
- [Fast Seek](extensions/fast-seek/) makes seeks in long AAC and Apple Lossless files jump to the target instead of stepping through every frame.
- [Long Audio Fix](extensions/long-audio-fix/) plays AAC and Apple Lossless files longer than 13.5 hours to the end.

To add your extension to the catalog, open a PR following the [submission guide](catalog/README.md). Later releases are picked up automatically.
15 changes: 15 additions & 0 deletions catalog/sources.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,18 @@ tag_prefix = "playback-log/v"
repo = "RepriseOS/repriseos-extensions"
path = "extensions/dsp"
tag_prefix = "dsp/v"

[fast-seek]
repo = "RepriseOS/repriseos-extensions"
path = "extensions/fast-seek"
tag_prefix = "fast-seek/v"

[long-audio-fix]
repo = "RepriseOS/repriseos-extensions"
path = "extensions/long-audio-fix"
tag_prefix = "long-audio-fix/v"

[sleep-timer]
repo = "RepriseOS/repriseos-extensions"
path = "extensions/sleep-timer"
tag_prefix = "sleep-timer/v"
3 changes: 3 additions & 0 deletions extensions/fast-seek/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SPDX-License-Identifier: GPL-3.0-only
main_SOURCES := main.c
include $(SDK)/rv.mk
15 changes: 15 additions & 0 deletions extensions/fast-seek/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Fast Seek

The same approach as [Seek MP4 audio by chunk instead of sample by sample](https://github.com/RepriseOS/repriseos/pull/63) by kayboll for RepriseOS, arrived at independently.

Apple's MP4 parser seeks an AAC or Apple Lossless file (M4A, M4B) by stepping through every sample to the target, reading the sample-size table from disk in 128 KB windows. A backward seek starts from the first sample. A jump of several hours in an audiobook takes seconds and many disk reads. Chapters, the scrubber and resuming an episode all seek this way.

The extension binds the entry of the sample walk. It finds the chunk holding the target from the in-memory time-to-sample and sample-to-chunk tables and starts the walk at that chunk's first sample, leaving Apple's loop at most a few seconds of audio in iTunes files. Files with more than one edit, or more than one frame length before the target, seek the stock way.

Disabling it restores Apple's walk at once.

| | |
|---|---|
| Default | on |
| Memory | image only |
| Settings | none |
20 changes: 20 additions & 0 deletions extensions/fast-seek/assets/LICENSE.cupertino-icons
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)

Copyright (c) 2016 Vladimir Kharlampidi

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:

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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions extensions/fast-seek/assets/settings-fast-seek.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions extensions/fast-seek/listing.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
details = "Seek, pick a chapter or resume in a long AAC or Apple Lossless file (M4A, M4B). Playback continues at the target right away instead of after a long pause. Nothing is added to the menus."

icon = "assets/settings-fast-seek.png"
152 changes: 152 additions & 0 deletions extensions/fast-seek/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
/* SPDX-License-Identifier: GPL-3.0-only */

/* The same approach as RepriseOS pull request 63 by kayboll, arrived at
* independently. */

/* Apple's MP4 parser seeks by stepping through every sample from its current
* position, or from the first sample when the target lies behind, until the
* presentation time reaches the target: about 155 instructions per AAC frame and
* a 128 KB table read every 32,768 frames. This handler runs at the entry of
* that walk (MP4Parser_SeekAudioTrack), works out from the time-to-sample and
* sample-to-chunk runs which chunk holds the target, moves the track state to
* that chunk's first sample and lets Apple's loop finish the chunk, loading the
* table windows as it always does. Tables outside the plain shape (several
* edits, several time-to-sample runs before the target, windows not at the
* table start) leave the walk to Apple. */

#include "osos-2.0.5.h"
#include "rv_api.h"
#include "rv_sites.h"
#include "rv_ui.h"

static const struct rv_api *api;

static uint32_t word(const void *base, uint32_t offset)
{
return RV_FIELD(base, offset, uint32_t);
}

static uint64_t pair(const void *base, uint32_t offset)
{
return (uint64_t)word(base, offset + 4) << 32 | word(base, offset);
}

static void set_pair(void *base, uint32_t offset, uint64_t value)
{
RV_FIELD(base, offset, uint32_t) = (uint32_t)value;
RV_FIELD(base, offset + 4, uint32_t) = (uint32_t)(value >> 32);
}

/* a × b for b below 2^16 (timescales and frame lengths), without the 64-bit
* multiply helper. */
static uint64_t mul(uint32_t a, uint32_t b)
{
uint32_t low = (a & 0xffff) * b, high = (a >> 16) * b;
return ((uint64_t)(high >> 16) << 32) + ((uint64_t)(high & 0xffff) << 16) + low;
}

/* Move the audio track to the first sample of the chunk that holds the seek
* target, when the tables allow it. Samples and chunks are 1-based, as in the
* track state. */
static void position(uint8_t *parser, uint32_t ms)
{
uint8_t *track = RV_FIELD(parser, MP4Parser_audio_track, uint8_t *);
/* Apple's walk returns at once for a track without a chunk offset atom. */
if (!track || pair(track, MP4Track_chunk_offset_atom) == UINT64_MAX)
return;
const uint8_t *sizes = RV_FIELD(track, MP4Track_sample_sizes, const uint8_t *);
const uint8_t *chunks = RV_FIELD(track, MP4Track_chunk_offsets, const uint8_t *);
const uint8_t *runs = RV_FIELD(track, MP4Track_sample_to_chunk, const uint8_t *);
const uint8_t *times = RV_FIELD(track, MP4Track_time_to_sample, const uint8_t *);
const uint8_t *edits = RV_FIELD(track, MP4Track_edits, const uint8_t *);
uint32_t timescale = word(track, MP4Track_timescale);
if (!sizes || !chunks || !runs || !times || !timescale || timescale > 0xffff)
return;
uint32_t run_count = word(runs, MP4SampleTable_count);
if (word(times, MP4SampleTable_window_first) ||
!word(times, MP4SampleTable_count) || word(runs, MP4SampleTable_window_first) ||
!run_count || run_count > MP4_SampleToChunkWindow)
return;
/* One edit, already the current one: presentation time starts at its media start. */
uint64_t edit_start = 0;
if (edits) {
if (word(edits, MP4EditList_count) != 1 || word(track, MP4Track_edit_index))
return;
edit_start = pair(track, MP4Track_edit_media_start);
if (edit_start == UINT64_MAX)
return;
}
/* Only the first time-to-sample run; a target past it stays with Apple. */
const uint8_t *time = RV_FIELD(times, MP4SampleTable_window, const uint8_t *);
uint32_t delta = word(time, MP4TimeToSampleEntry_delta);
uint32_t in_run = word(time, MP4TimeToSampleEntry_count);
if (!delta || delta > 0xffff)
return;
/* The first sample inside the edit, and the sample at which Apple's loop stops,
* rounded down: the loop can only move forward from where it is put. */
uint64_t target = Runtime_UDiv64(mul(ms, timescale), 1000);
uint64_t first = Runtime_UDiv64(edit_start + delta - 1, delta) + 1;
uint64_t stop = first - 1 + Runtime_UDiv64(target, delta);
if (stop < 1 || stop > in_run || stop > word(sizes, MP4SampleSizeTable_count))
return;
/* The chunk holding `stop`, from the sample-to-chunk runs. */
const uint8_t *run = RV_FIELD(runs, MP4SampleTable_window, const uint8_t *);
uint32_t chunk_count = word(chunks, MP4SampleTable_count);
uint32_t index = (uint32_t)stop - 1, before = 0, run_index = 0, chunk, chunk_first;
for (;; run_index++, run += MP4SampleToChunkEntry_bytes) {
uint32_t from = word(run, MP4SampleToChunkEntry_first_chunk);
uint32_t per = word(run, MP4SampleToChunkEntry_samples_per_chunk);
uint32_t until = run_index + 1 < run_count
? word(run + MP4SampleToChunkEntry_bytes,
MP4SampleToChunkEntry_first_chunk)
: chunk_count + 1;
if (!per || until <= from)
return;
uint32_t span = (until - from) * per;
if (index - before < span) {
chunk = from + (index - before) / per;
chunk_first = before + (chunk - from) * per + 1;
break;
}
before += span;
if (run_index + 1 >= run_count)
return;
}
/* Already inside the stretch Apple would walk forward: leave it. */
uint32_t sample = word(track, MP4Track_sample);
if (sample >= chunk_first && sample <= stop)
return;
RV_FIELD(track, MP4Track_sample, uint32_t) = chunk_first;
RV_FIELD(track, MP4Track_sample_to_chunk_index, uint32_t) = run_index;
RV_FIELD(track, MP4Track_chunk, uint32_t) = chunk;
RV_FIELD(track, MP4Track_sample_in_chunk, uint32_t) = 0;
RV_FIELD(track, MP4Track_chunk_byte_offset, uint32_t) = 0;
RV_FIELD(track, MP4Track_time_to_sample_index, uint32_t) = 0;
RV_FIELD(track, MP4Track_time_to_sample_run, uint32_t) = chunk_first - 1;
set_pair(track, MP4Track_decode_time, mul(chunk_first - 1, delta));
set_pair(track, MP4Track_presentation_time,
chunk_first > first ? mul(chunk_first - (uint32_t)first, delta) : 0);
}

static uint32_t on_seek(uint8_t *parser, uint32_t ms, const void *next)
{
position(parser, ms);
return api->hook_next(next, (uint32_t)parser, ms, 0, 0, 0, 0);
}

static const struct rv_hook hooks[] = {
RV_HOOK_FILTER(RV_SITE_MP4Parser_SeekAudioTrack_entry, on_seek),
};

static const struct rv_descriptor extension = {
.size = sizeof extension,
RV_HOOKS(hooks),
};

const struct rv_descriptor *rv_module_entry(const struct rv_api *core,
rv_extension_handle handle)
{
(void)handle;
api = core;
return &extension;
}
13 changes: 13 additions & 0 deletions extensions/fast-seek/manifest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
id = "fast-seek"
name = "Fast Seek"
description = "Seeking in long AAC and Apple Lossless files (audiobooks, podcasts) jumps straight to the target instead of stepping through every frame on the way."
version = "0.1.0"
author = "RepriseOS and RevolaOS contributors"
license = "GPL-3.0-only"
api = "1.82"
stability = "beta"
category = "media"

[[module]]
name = "main"
trigger = "always"
3 changes: 3 additions & 0 deletions extensions/long-audio-fix/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SPDX-License-Identifier: GPL-3.0-only
main_SOURCES := main.c
include $(SDK)/rv.mk
15 changes: 15 additions & 0 deletions extensions/long-audio-fix/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Long Audio Fix

The same fix as [Play MP4 audiobooks past 13.5 hours](https://github.com/RepriseOS/repriseos/pull/62) by kayboll for RepriseOS, arrived at independently.

Apple's MP4 parser ends an AAC or Apple Lossless file (M4A, M4B) once playback passes 2^31 samples: 13:31:35 at 44.1 kHz, 12:25:39 at 48 kHz. Past that point every sample counts as outside the edit list, so the track ends, and a seek there ends it at once. This affects files with an edit list, which iTunes, ffmpeg and most audiobook tools write.

The parser keeps the decode time in 64 bits but compares it with the edit list in 32. The extension replaces the three sign-extensions of the low word with loads of the high word.

Disabling it restores Apple's compares at once.

| | |
|---|---|
| Default | on |
| Memory | image only |
| Settings | none |
20 changes: 20 additions & 0 deletions extensions/long-audio-fix/assets/LICENSE.cupertino-icons
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)

Copyright (c) 2016 Vladimir Kharlampidi

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:

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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions extensions/long-audio-fix/assets/settings-long-audio-fix.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions extensions/long-audio-fix/listing.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
details = "Play an AAC or Apple Lossless file (M4A, M4B) longer than 13.5 hours. It plays to the end instead of stopping at 13:31:35. Nothing is added to the menus."

icon = "assets/settings-long-audio-fix.png"
36 changes: 36 additions & 0 deletions extensions/long-audio-fix/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* SPDX-License-Identifier: GPL-3.0-only */

/* The same fix as RepriseOS pull request 62 by kayboll, arrived at independently. */

/* The MP4 parser compares a track's 64-bit decode time with its edit list after
* sign-extending the low word, so past 2^31 media ticks (13:31:35 at 44.1 kHz)
* every sample counts as outside the edit and the track ends. Each site holds
* `asr r1, r0, #31` with r0 the low word; the replacement loads the high word
* from the track instead. */

#include "rv_api.h"
#include "rv_sites.h"
#include "rv_ui.h"

static const struct rv_hook hooks[] = {
/* ldr r1, [r2, #-20]: r2 is track + edit_media_start, the high word of decode_time
* sits 20 bytes before it. */
RV_HOOK_WORD(RV_SITE_MP4Parser_ReadEditStartTest_word, 0xe5121014),
/* ldr r1, [r2, #-28]: r2 is track + edit_media_end. */
RV_HOOK_WORD(RV_SITE_MP4Parser_ReadEditEndTest_word, 0xe512101c),
/* The same compare in the seek walk, r2 again track + edit_media_end. */
RV_HOOK_WORD(RV_SITE_MP4Parser_SeekEditEndTest_word, 0xe512101c),
};

static const struct rv_descriptor extension = {
.size = sizeof extension,
RV_HOOKS(hooks),
};

const struct rv_descriptor *rv_module_entry(const struct rv_api *core,
rv_extension_handle handle)
{
(void)core;
(void)handle;
return &extension;
}
Loading