rocksky 0.9.0 → 0.10.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e27b27d24d5d5c59963b65031fb641ecb90cb322a9107f3a62a431e6d1973a0c
4
- data.tar.gz: 4a314bfa67627103279e453ab7f3563f3c0265c02ca0c1db1ca88259ca26cb33
3
+ metadata.gz: 506387a27a8e92d1310a65f855110efff853b6079d9dbb65d6a3e1e56932cc18
4
+ data.tar.gz: 9d190b167472ba41881d547b527e501e446a75d844cefd4ff5b3200cd461cc94
5
5
  SHA512:
6
- metadata.gz: 498b7790bd6961f4a5e118ab4485bf124afb9283fb838a38f6c21195fa50ba47e22bc10ae98518e6804401e3b8de63e5580cb8957a3690f0dcf39a4e72d18de9
7
- data.tar.gz: 3f1bb359b30802470a0c7d59ea921850ee43060bba3c67ba8f672eebb1d01c3d6814135462b47c029104bbfb3f5bb32de2b592ffab590c6521f703c3b37995f9
6
+ metadata.gz: 1a82ef8bb90f40689b29067ba2debfe55eb8e099ed0897c3a69b795a3f03e76c49b10ba42d2035377027ea6701b53ac7be2195b2aead08f0a609ebd4e3058e9c
7
+ data.tar.gz: 78ca04c14127de3ae2b6993a942129ad1d9118679f1c8458807d315744e703932ae3c861fb32349fb615dff4d4086207bc38e19a2361d27a8fa047291576addf
data/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.10.0
4
+
5
+ - Remote-player protocol: now-playing records accept optional audio info —
6
+ `codec` (audio codec/container, e.g. "mp3", "flac") and `sampleRate` (sample
7
+ rate in Hz, e.g. 44100). A player includes them in the `track` payload when
8
+ set (`codec` / `sample_rate` on the wire, omitted otherwise); a controller's
9
+ `:now_playing` event exposes them on the `:track` hash.
10
+
11
+ ## 0.9.1
12
+
13
+ - Fix a segfault when tearing down a `RemotePlayer` / `RemoteController`.
14
+ `#close` freed the native handle while the `#listen` background thread was
15
+ still blocked inside `#next_command` / `#next_event` (a use-after-free). It now
16
+ stops the background task and **joins** the listen thread — so the poll has
17
+ returned — before freeing. `#next_command` / `#next_event` also no-op once the
18
+ handle is released.
19
+
3
20
  ## 0.3.0
4
21
 
5
22
  - `feed.get_stories` now accepts optional `feed:` (at-uri) and `following:`
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "repo": "tsirysndr/rocksky",
3
- "tag": "bindings-v0.6.0",
3
+ "tag": "bindings-v0.7.0",
4
4
  "checksums": {
5
- "aarch64-apple-darwin": "e2de89af96e1330427898524254ddb57728453947b607c4dd29fb8ed7c513b27",
6
- "aarch64-linux-gnu": "37b8f5ec3812cb15f7eeb75beb44ffe857cca95c11064d1e781eaff6edf7c14d",
7
- "x86_64-apple-darwin": "7a550b51fc75e1e4d7c5393423f2920dda980ea8f026c9bde8edd926d18d3795",
8
- "x86_64-linux-gnu": "683e9c14579041c77fa69b53f73b43a44432719c608d7af74f950c9263c5c53b",
9
- "x86_64-unknown-freebsd": "4ecf5a61000b46111aef2c66e241c97e712c8ef6af386a01afddfe2c05136893",
10
- "x86_64-unknown-netbsd": "0c619e60f6cf95c42bbe61adb26be8550024c8cbea08be6de9fb3127db627900"
5
+ "aarch64-apple-darwin": "e9a772586564269dccf8448d46162b85fe5290307b818b3a4fc26ff634c2ab57",
6
+ "aarch64-linux-gnu": "fbfc5d12a8c532f437577f1c2e36c794760e78bb66749af33eef17d14a60cafc",
7
+ "x86_64-apple-darwin": "81e5628ea2f269ac8efefce85fa5eae093b1d49848aba580da9f267a36f85115",
8
+ "x86_64-linux-gnu": "3d3de1e3b691416676dd1c09879b14944a5c85d1d8911650113e6ee7783326e2",
9
+ "x86_64-unknown-freebsd": "b0ad8071e2a6baf1096d4f82221c440e56bf9426e435244ade8687f08edabf69",
10
+ "x86_64-unknown-netbsd": "08e9ff48d6273e63d6ebdc5eb3882777bc9bd227bc9126478a98c5041e2f1f05"
11
11
  }
12
12
  }
@@ -27,7 +27,8 @@ module Rocksky
27
27
  #
28
28
  # Records (now-playing / queue items) are passed as Hashes with camelCase keys
29
29
  # (title, artist, album, albumArtist, albumArt, durationMs, elapsedMs,
30
- # isPlaying / songUri, albumUri, trackNumber), matching the wire record shape.
30
+ # isPlaying, codec, sampleRate / songUri, albumUri, trackNumber), matching the
31
+ # wire record shape.
31
32
  class RemotePlayer
32
33
  # Connect and register a controllable player in the background. +token+ is a
33
34
  # Rocksky access token (JWT); +name+ is the device-picker label; +url+
@@ -57,6 +58,8 @@ module Rocksky
57
58
  # Block until the next controller command, returned as a symbol-keyed Hash
58
59
  # (e.g. +{ action: "play" }+), or +nil+ once disconnected.
59
60
  def next_command
61
+ return nil if @ptr.null?
62
+
60
63
  cmd = Rocksky.unwrap(C.rocksky_remote_player_next_command(@ptr))
61
64
  cmd && Rocksky.symbolize(cmd)
62
65
  end
@@ -77,7 +80,10 @@ module Rocksky
77
80
 
78
81
  # Advertise the currently-playing track. Call whenever it changes, and
79
82
  # periodically (~every 1–4s) with a fresh +elapsedMs+ so controllers show
80
- # smooth progress. +track+ is a camelCase Hash.
83
+ # smooth progress. +track+ is a camelCase Hash. Optional audio info —
84
+ # +codec+ (audio codec/container, e.g. "mp3", "flac") and +sampleRate+
85
+ # (sample rate in Hz, e.g. 44100) — is included in the track payload when
86
+ # set, and omitted otherwise.
81
87
  def set_now_playing(track)
82
88
  Rocksky.unwrap(C.rocksky_remote_player_set_now_playing(@ptr, JSON.generate(track)))
83
89
  end
@@ -103,7 +109,12 @@ module Rocksky
103
109
  def close
104
110
  return if @ptr.null?
105
111
 
106
- @thread&.kill
112
+ # Stop the background task so a blocked #next_command returns nil and the
113
+ # #listen loop exits, then WAIT for that thread to leave the native call
114
+ # before freeing — freeing the handle while a poll is in flight is a
115
+ # use-after-free (segfault).
116
+ C.rocksky_remote_player_disconnect(@ptr)
117
+ @thread&.join unless @thread == Thread.current
107
118
  @thread = nil
108
119
  C.rocksky_remote_player_free(@ptr)
109
120
  @ptr = Fiddle::Pointer.new(0)
@@ -157,7 +168,9 @@ module Rocksky
157
168
  # Register a handler for a server event type, one of +:devices+,
158
169
  # +:device_registered+, +:device_unregistered+, +:primary_changed+,
159
170
  # +:now_playing+, +:status+, +:queue+. The block receives the full
160
- # symbol-keyed event Hash. Returns +self+ for chaining.
171
+ # symbol-keyed event Hash. A +:now_playing+ event carries the advertised
172
+ # track under +:track+, including optional +:codec+ / +:sampleRate+ audio
173
+ # info when the player supplied it. Returns +self+ for chaining.
161
174
  def on(event_type, &block)
162
175
  @handlers[event_type.to_sym] = block
163
176
  self
@@ -166,6 +179,8 @@ module Rocksky
166
179
  # Block until the next update, returned as a symbol-keyed Hash (each carries a
167
180
  # +:type+), or +nil+ once disconnected.
168
181
  def next_event
182
+ return nil if @ptr.null?
183
+
169
184
  ev = Rocksky.unwrap(C.rocksky_remote_controller_next_event(@ptr))
170
185
  ev && Rocksky.symbolize(ev)
171
186
  end
@@ -244,7 +259,12 @@ module Rocksky
244
259
  def close
245
260
  return if @ptr.null?
246
261
 
247
- @thread&.kill
262
+ # Stop the background task so a blocked #next_event returns nil and the
263
+ # #listen loop exits, then WAIT for that thread to leave the native call
264
+ # before freeing — freeing the handle while a poll is in flight is a
265
+ # use-after-free (segfault).
266
+ C.rocksky_remote_controller_disconnect(@ptr)
267
+ @thread&.join unless @thread == Thread.current
248
268
  @thread = nil
249
269
  C.rocksky_remote_controller_free(@ptr)
250
270
  @ptr = Fiddle::Pointer.new(0)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rocksky
4
- VERSION = "0.9.0"
4
+ VERSION = "0.10.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rocksky
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rocksky