Compare commits

..
3 Commits
Author SHA1 Message Date
Ultradesu 1f9539ffd7 Bump protocols. Added proto status 2026-07-28 22:59:35 +01:00
Ultradesu d854a4d4e0 Bump furumi 0.2.2 -> 0.2.3 2026-07-28 22:45:50 +01:00
Ultradesu 6175423b0c Bump protocols. Added proto status 2026-07-28 22:24:17 +01:00
4 changed files with 41 additions and 5 deletions

No files matched your search

Generated
+1 -1
View File
@@ -1565,7 +1565,7 @@ dependencies = [
[[package]]
name = "furumi_tui"
version = "0.2.2"
version = "0.2.3"
dependencies = [
"anyhow",
"blake3",
+13
View File
@@ -263,6 +263,7 @@ pub async fn run(
state.device_playback.self_device_name = device_name.clone();
state.device_playback.active_device_id = Some(device_id);
state.device_playback.active_device_name = Some(device_name);
state.device_playback.startup_takeover_pending = true;
}
let player_events = event_tx.clone();
let mut runtime = Runtime {
@@ -2811,6 +2812,18 @@ fn handle_device_playback_snapshot(
if !snapshot.active {
return;
}
// Starting a player is an explicit claim of the active role. Import the
// current queue/position from the previously active peer, then announce a
// normal handoff so that the old owner becomes a control device. This is
// intentionally one-shot: subsequent snapshots use the regular lease and
// explicit-transfer rules.
if state.device_playback.startup_takeover_pending {
state.device_playback.startup_takeover_pending = false;
become_control_device(state, runtime, snapshot);
transfer_active_to_this_device(state, runtime);
state.status_message = Some("playback moved to this newly started player".to_string());
return;
}
if local_active_lease_protected(state, now) {
tracing::debug!(
remote = %snapshot.device_id,
+3
View File
@@ -1240,6 +1240,9 @@ pub struct DevicePlaybackState {
pub remote: BTreeMap<String, crate::devices::PlaybackSnapshot>,
pub last_remote_snapshot: Option<crate::devices::PlaybackSnapshot>,
pub jam_host: bool,
/// A freshly started TUI owns playback by protocol. The first active
/// snapshot discovered during startup is imported and handed off here.
pub startup_takeover_pending: bool,
}
impl DevicePlaybackState {
+24 -4
View File
@@ -1249,8 +1249,7 @@ impl DeviceSync {
device: &StoredDevice,
transport_stats: Arc<crate::federation::TransportStats>,
) -> Result<()> {
let ticket: PeerTicket = device.endpoint_ticket.parse()?;
let peer = service.connect(ticket).await?;
let peer = resolve_device_peer(&service, device).await?;
let own_ticket = service.ticket().await?.to_string();
let identity = self.ensure_identity()?;
let profile = self.own_profile(&own_ticket)?;
@@ -2380,7 +2379,7 @@ impl DeviceSync {
let own = self.ensure_identity()?.device_id;
let conn = lock(&self.conn);
let mut stmt = conn.prepare(
"SELECT device_id, endpoint_ticket
"SELECT device_id, endpoint_id, endpoint_ticket
FROM sync_devices
WHERE trusted_at_ms IS NOT NULL
AND revoked_at_ms IS NULL
@@ -2390,7 +2389,8 @@ impl DeviceSync {
let rows = stmt.query_map([own], |row| {
Ok(StoredDevice {
device_id: row.get(0)?,
endpoint_ticket: row.get(1)?,
endpoint_id: row.get(1)?,
endpoint_ticket: row.get(2)?,
})
})?;
Ok(rows.collect::<rusqlite::Result<Vec<_>>>()?)
@@ -2642,9 +2642,29 @@ impl DeviceSync {
#[derive(Debug)]
struct StoredDevice {
device_id: String,
endpoint_id: String,
endpoint_ticket: String,
}
async fn resolve_device_peer(
service: &MusicDhtService,
device: &StoredDevice,
) -> Result<music_dht::EndpointId> {
if let Ok(peer) = device.endpoint_id.parse::<music_dht::EndpointId>()
&& (service.connected_peers().contains(&peer)
|| service
.known_peers()
.iter()
.any(|contact| contact.peer_id == peer))
{
// The live DHT contact carries a ticket for the current schema. The
// persisted device ticket may predate a schema upgrade.
return Ok(peer);
}
let ticket: PeerTicket = device.endpoint_ticket.parse()?;
service.connect(ticket).await.map_err(Into::into)
}
pub async fn serve_peers(
mut acceptor: StreamAcceptor,
sync: Arc<DeviceSync>,