rockbox_ffi 0.5.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/examples/play.rb +22 -5
- data/lib/rockbox_ffi/ffi.rb +1 -0
- data/lib/rockbox_ffi/player.rb +13 -2
- data/lib/rockbox_ffi/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7ea9e94f1a583732d3b06ddbb9f6f41e5777a37f2151054820116773d908f8b1
|
|
4
|
+
data.tar.gz: bd92c9ab53fb42598aa6e3d918956e21751d695b4bf7a75be65e9ce7ac8181d5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fe5e0733d3540168cf8b31a5c2f910dd0968fdc2883778a24d3e46e92c48f3edc7fcd5fcbab4eae97b11177fa7cf49f86348c41dbb00b015f0a32f09ebaf5f22
|
|
7
|
+
data.tar.gz: debc3b1bc0f7d340f17ee881d1454e7dd98fe7bf907c8c3e95375ddc863144c2c98509121b4ccc4208a4ca81f1ba4423a3c1412ac353650416a0e7cb00dc6ed4
|
data/README.md
CHANGED
|
@@ -68,8 +68,8 @@ RockboxFFI::Player.open(volume: 0.8) do |player|
|
|
|
68
68
|
player.set_replaygain(RockboxFFI::ReplayGainMode::TRACK, 0.0, true)
|
|
69
69
|
player.set_crossfade(RockboxFFI::CrossfadeMode::ALWAYS)
|
|
70
70
|
# Queue entries may be local files, http(s):// URLs to remote media,
|
|
71
|
-
# or live-radio /
|
|
72
|
-
player.set_queue(["a.flac", "https://example.com/b.mp3", "http://radio.example/stream"])
|
|
71
|
+
# or live-radio streams, or HLS / MPEG-DASH manifests (.m3u8/.mpd) — mix and match freely.
|
|
72
|
+
player.set_queue(["a.flac", "https://example.com/b.mp3", "http://radio.example/stream", "https://cdn.example.com/live/main.m3u8"])
|
|
73
73
|
player.play
|
|
74
74
|
player.status # => {state: "playing", index: 0, ...}
|
|
75
75
|
end
|
data/examples/play.rb
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Play
|
|
3
|
+
# Play an audio source through the real output device.
|
|
4
4
|
#
|
|
5
|
-
#
|
|
5
|
+
# The queue entry can be a local file, a remote http(s):// URL, an
|
|
6
|
+
# internet-radio stream, or an HLS (.m3u8) / MPEG-DASH (.mpd) manifest —
|
|
7
|
+
# the engine detects each kind automatically.
|
|
8
|
+
#
|
|
9
|
+
# Run: ruby -Ilib examples/play.rb [path-or-URL]
|
|
10
|
+
# ruby -Ilib examples/play.rb hls # public HLS test stream
|
|
11
|
+
# ruby -Ilib examples/play.rb dash # public MPEG-DASH test stream
|
|
6
12
|
|
|
7
13
|
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
|
|
8
14
|
require "rockbox_ffi"
|
|
@@ -10,8 +16,15 @@ require "rockbox_ffi"
|
|
|
10
16
|
REPO = File.expand_path("../../..", __dir__)
|
|
11
17
|
FIXTURE = File.join(REPO, "crates", "rocksky", "fixtures", "08 - Internet Money - Speak(Explicit).m4a")
|
|
12
18
|
|
|
13
|
-
#
|
|
14
|
-
|
|
19
|
+
# Public adaptive-streaming test streams (see crates/rockbox-playback/README.md
|
|
20
|
+
# for more).
|
|
21
|
+
HLS_DEFAULT = "https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8"
|
|
22
|
+
DASH_DEFAULT = "https://dash.akamaized.net/akamai/bbb_30fps/bbb_30fps.mpd"
|
|
23
|
+
|
|
24
|
+
# The queue accepts local files, http(s):// URLs (remote media / live radio),
|
|
25
|
+
# and HLS / MPEG-DASH manifest URLs.
|
|
26
|
+
arg = ARGV[0] || FIXTURE
|
|
27
|
+
file = { "hls" => HLS_DEFAULT, "dash" => DASH_DEFAULT }.fetch(arg, arg)
|
|
15
28
|
if !RockboxFFI.is_url?(file) && !File.exist?(file)
|
|
16
29
|
abort "no such file: #{file}"
|
|
17
30
|
end
|
|
@@ -39,11 +52,15 @@ trap("INT") do
|
|
|
39
52
|
end
|
|
40
53
|
|
|
41
54
|
# Poll status until playback finishes (state returns to "stopped").
|
|
55
|
+
# A live stream reports duration 0 and plays until Ctrl-C.
|
|
42
56
|
loop do
|
|
43
57
|
st = player.status
|
|
44
58
|
pos = st[:position_ms] / 1000.0
|
|
45
59
|
dur = st[:duration_ms] / 1000.0
|
|
46
|
-
|
|
60
|
+
clock = dur.zero? ? format("%.1fs / LIVE", pos) : format("%.1fs / %.1fs", pos, dur)
|
|
61
|
+
# The codec label carries the protocol for adaptive streams (e.g. "HLS AAC").
|
|
62
|
+
codec = st.dig(:metadata, :codec) || ""
|
|
63
|
+
printf("\r[%s] %s %s ", st[:state], codec, clock)
|
|
47
64
|
$stdout.flush
|
|
48
65
|
|
|
49
66
|
if st[:state] == "stopped" && st[:position_ms].positive?
|
data/lib/rockbox_ffi/ffi.rb
CHANGED
|
@@ -111,6 +111,7 @@ module RockboxFFI
|
|
|
111
111
|
extern "void* rb_player_new()"
|
|
112
112
|
extern "void* rb_player_new_with_config(uint32_t, float, float, int32_t, float, bool, int32_t, uint32_t, uint32_t, uint32_t, uint32_t, int32_t)"
|
|
113
113
|
extern "void* rb_player_new_with_config_ex(uint32_t, float, float, int32_t, float, bool, int32_t, uint32_t, uint32_t, uint32_t, uint32_t, int32_t, void*, uint32_t)"
|
|
114
|
+
extern "void* rb_player_new_with_output(void*, uint32_t, float, float, int32_t, float, bool, int32_t, uint32_t, uint32_t, uint32_t, uint32_t, int32_t, void*, uint32_t)"
|
|
114
115
|
extern "void rb_player_free(void*)"
|
|
115
116
|
extern "void rb_player_set_queue_json(void*, void*)"
|
|
116
117
|
extern "void rb_player_enqueue(void*, void*)"
|
data/lib/rockbox_ffi/player.rb
CHANGED
|
@@ -30,6 +30,13 @@ module RockboxFFI
|
|
|
30
30
|
fade_in_delay_ms: 0,
|
|
31
31
|
fade_in_duration_ms: 2000,
|
|
32
32
|
mix_mode: MixMode::CROSSFADE,
|
|
33
|
+
# Audio output backend. nil/"" => cpal (the default device). Other specs:
|
|
34
|
+
# "stdout" (or "-"), "fifo:/path", "unix:/path" (listen),
|
|
35
|
+
# "unix-connect:/path", "tcp:host:port" (listen), "tcp-connect:host:port".
|
|
36
|
+
# A listening socket blocks until a client connects. In stdout mode fd 1 IS
|
|
37
|
+
# the raw S16LE stereo PCM stream, so the host must keep stdout clean
|
|
38
|
+
# (e.g. pipe to `ffplay -f s16le -ar 44100 -ac 2 -`).
|
|
39
|
+
output: nil,
|
|
33
40
|
resume_file: nil, # an .m3u8 to auto-persist queue + position to
|
|
34
41
|
resume_save_interval_ms: 0 # 0 => 5 s default
|
|
35
42
|
}.freeze
|
|
@@ -55,11 +62,15 @@ module RockboxFFI
|
|
|
55
62
|
|
|
56
63
|
# Create a player with configuration overrides (see DEFAULT_CONFIG keys).
|
|
57
64
|
# sample_rate: 0 means the device default. Passing +resume_file:+ enables
|
|
58
|
-
# auto-persisting the queue + exact position to that .m3u8 file.
|
|
65
|
+
# auto-persisting the queue + exact position to that .m3u8 file. +output:+
|
|
66
|
+
# selects the audio backend (nil/"" => cpal; see DEFAULT_CONFIG for the
|
|
67
|
+
# full spec-string list).
|
|
59
68
|
def initialize(**opts)
|
|
60
69
|
c = DEFAULT_CONFIG.merge(opts)
|
|
61
70
|
resume_file = c[:resume_file].nil? ? nil : c[:resume_file].to_s
|
|
62
|
-
|
|
71
|
+
output = c[:output].nil? || c[:output].to_s.empty? ? nil : c[:output].to_s
|
|
72
|
+
ptr = Lib.rb_player_new_with_output(
|
|
73
|
+
output,
|
|
63
74
|
Integer(c[:sample_rate]), Float(c[:buffer_seconds]), Float(c[:volume]),
|
|
64
75
|
Integer(c[:replaygain_mode]), Float(c[:replaygain_preamp_db]),
|
|
65
76
|
RockboxFFI.b(c[:replaygain_prevent_clipping]), Integer(c[:crossfade_mode]),
|
data/lib/rockbox_ffi/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rockbox_ffi
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tsiry Sandratraina
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-09-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: fiddle
|