Added JAM feature
This commit is contained in:
+15
-4
@@ -2784,6 +2784,12 @@ fn handle_device_playback_snapshot(
|
||||
runtime: &mut Runtime,
|
||||
snapshot: crate::devices::PlaybackSnapshot,
|
||||
) {
|
||||
// Personal-device reconciliation must never change Jam ownership. Jam
|
||||
// has its own authority and lifecycle even when the same TUI also belongs
|
||||
// to a trusted-device group.
|
||||
if state.device_playback.role == state::DevicePlaybackRole::Jam {
|
||||
return;
|
||||
}
|
||||
if snapshot.device_id == state.device_playback.self_device_id {
|
||||
return;
|
||||
}
|
||||
@@ -2813,7 +2819,7 @@ fn handle_device_playback_snapshot(
|
||||
return;
|
||||
}
|
||||
let lease_expired = active_idle_lease_expired(&snapshot, now);
|
||||
let already_controls_this_device = state.device_playback.is_control()
|
||||
let already_controls_this_device = state.device_playback.is_personal_control()
|
||||
&& state.device_playback.active_device_id.as_deref() == Some(snapshot.device_id.as_str());
|
||||
if !lease_expired || already_controls_this_device {
|
||||
let was_active = state.device_playback.is_audio_owner();
|
||||
@@ -2828,7 +2834,7 @@ fn handle_device_playback_snapshot(
|
||||
return;
|
||||
}
|
||||
|
||||
if state.device_playback.is_control() {
|
||||
if state.device_playback.is_personal_control() {
|
||||
return;
|
||||
}
|
||||
become_active_device(state, runtime, false);
|
||||
@@ -2942,7 +2948,7 @@ fn handle_app_event(state: &mut AppState, runtime: &mut Runtime, event: AppEvent
|
||||
})
|
||||
.unwrap_or(1)
|
||||
.max(1);
|
||||
let active_revoked = state.device_playback.is_control()
|
||||
let active_revoked = state.device_playback.is_personal_control()
|
||||
&& state
|
||||
.device_playback
|
||||
.active_device_id
|
||||
@@ -2960,7 +2966,7 @@ fn handle_app_event(state: &mut AppState, runtime: &mut Runtime, event: AppEvent
|
||||
})
|
||||
.is_some_and(|device| device.revoked)
|
||||
});
|
||||
let active_missing = state.device_playback.is_control()
|
||||
let active_missing = state.device_playback.is_personal_control()
|
||||
&& state
|
||||
.device_playback
|
||||
.active_device_id
|
||||
@@ -3022,6 +3028,11 @@ fn handle_app_event(state: &mut AppState, runtime: &mut Runtime, event: AppEvent
|
||||
AppEvent::DevicePlayback(snapshot) => {
|
||||
handle_device_playback_snapshot(state, runtime, snapshot);
|
||||
}
|
||||
AppEvent::PlaybackCommand(_)
|
||||
if state.device_playback.role == state::DevicePlaybackRole::Jam =>
|
||||
{
|
||||
tracing::debug!("ignored personal-device playback command while Jam is active");
|
||||
}
|
||||
AppEvent::PlaybackCommand(command) => {
|
||||
handle_playback_command(state, runtime, command);
|
||||
}
|
||||
|
||||
@@ -423,6 +423,12 @@ fn handle_connected_devices(
|
||||
});
|
||||
}
|
||||
KeyCode::Enter => {
|
||||
if state.device_playback.role == crate::app::state::DevicePlaybackRole::Jam {
|
||||
state.status_message =
|
||||
Some("leave the current Jam before switching personal devices".into());
|
||||
state.popup = Some(Popup::ConnectedDevices { cursor });
|
||||
return;
|
||||
}
|
||||
if cursor == 0 {
|
||||
super::transfer_active_to_this_device(state, runtime);
|
||||
state.status_message = Some("active playback moved to this device".into());
|
||||
|
||||
@@ -1248,6 +1248,10 @@ impl DevicePlaybackState {
|
||||
|| (self.role == DevicePlaybackRole::Jam && !self.jam_host)
|
||||
}
|
||||
|
||||
pub fn is_personal_control(&self) -> bool {
|
||||
self.role == DevicePlaybackRole::Control
|
||||
}
|
||||
|
||||
pub fn is_audio_owner(&self) -> bool {
|
||||
self.role == DevicePlaybackRole::Active
|
||||
|| (self.role == DevicePlaybackRole::Jam && self.jam_host)
|
||||
|
||||
Reference in New Issue
Block a user