Skip to content
Merged
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
17 changes: 13 additions & 4 deletions plugins/listener/src/actors/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,14 @@ impl Actor for ListenerActor {
crate::actors::ChannelMode::MicAndSpeaker => {}
}

SessionEvent::StreamResponse {
if let Err(error) = (SessionEvent::StreamResponse {
session_id: state.args.session_id.clone(),
response,
})
.emit(&state.args.app)
{
tracing::error!(?error, "stream_response_emit_failed");
}
.emit(&state.args.app)?;
}

ListenerMsg::StreamStartFailed(error) => {
Expand Down Expand Up @@ -524,7 +527,10 @@ async fn process_stream<S, E>(
response.set_channel_index(channel_idx, total_channels);
}

let _ = myself.send_message(ListenerMsg::StreamResponse(response));
if myself.send_message(ListenerMsg::StreamResponse(response)).is_err() {
tracing::warn!("actor_gone_during_finalize");
break;
}

if received_from_finalize {
tracing::info!(from_finalize = true, "break_from_finalize");
Expand Down Expand Up @@ -554,7 +560,10 @@ async fn process_stream<S, E>(
response.set_channel_index(channel_idx, total_channels);
}

let _ = myself.send_message(ListenerMsg::StreamResponse(response));
if myself.send_message(ListenerMsg::StreamResponse(response)).is_err() {
tracing::warn!("actor_gone_breaking_stream_loop");
break;
}
}
// Something went wrong while sending or receiving a websocket message. Should restart.
Ok(Some(Err(e))) => {
Expand Down
6 changes: 2 additions & 4 deletions plugins/listener/src/actors/recorder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,17 +165,15 @@ impl Actor for RecorderActor {
&st.wav_path,
&temp_ogg_path,
VorbisEncodeSettings::default(),
)
.map_err(into_actor_err)
{
) {
Ok(_) => {
std::fs::rename(&temp_ogg_path, &st.ogg_path)?;
std::fs::remove_file(&st.wav_path)?;
}
Err(e) => {
tracing::error!(error = ?e, "wav_to_ogg_failed_keeping_wav");
let _ = std::fs::remove_file(&temp_ogg_path);
return Err(e);
// Keep WAV as a fallback, but don't cause an actor failure
}
}
}
Expand Down
20 changes: 11 additions & 9 deletions plugins/listener/src/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,13 @@ impl<R: tauri::Runtime, T: tauri::Manager<R>> ListenerPluginExt<R> for T {
guard.session_supervisor = Some(supervisor_ref);
guard.supervisor_handle = Some(handle);

SessionEvent::RunningActive {
if let Err(error) = (SessionEvent::RunningActive {
session_id: params.session_id,
}
})
.emit(&guard.app)
.unwrap();
{
tracing::error!(?error, "failed_to_emit_running_active");
}

tracing::info!("session_started");
}
Expand All @@ -141,9 +143,9 @@ impl<R: tauri::Runtime, T: tauri::Manager<R>> ListenerPluginExt<R> for T {
};

if let Some(session_id) = session_id.clone() {
SessionEvent::Finalizing { session_id }
.emit(&guard.app)
.unwrap();
if let Err(error) = (SessionEvent::Finalizing { session_id }).emit(&guard.app) {
tracing::error!(?error, "failed_to_emit_finalizing");
}
}

if let Some(supervisor_cell) = guard.session_supervisor.take() {
Expand All @@ -160,9 +162,9 @@ impl<R: tauri::Runtime, T: tauri::Manager<R>> ListenerPluginExt<R> for T {
}

if let Some(session_id) = session_id {
SessionEvent::Inactive { session_id }
.emit(&guard.app)
.unwrap();
if let Err(error) = (SessionEvent::Inactive { session_id }).emit(&guard.app) {
tracing::error!(?error, "failed_to_emit_inactive");
}
}

tracing::info!("session_stopped");
Expand Down
Loading