fix usb device update behavior
This commit is contained in:
@@ -66,7 +66,12 @@ if audio_mode in ["Webapp", "USB"]:
|
||||
if default_input not in input_options:
|
||||
default_input = input_options[0]
|
||||
|
||||
selected_option = st.selectbox("Input Device", input_options, index=input_options.index(default_input))
|
||||
col1, col2 = st.columns([3, 1], vertical_alignment="bottom")
|
||||
with col1:
|
||||
selected_option = st.selectbox("Input Device", input_options, index=input_options.index(default_input))
|
||||
with col2:
|
||||
if st.button("Refresh"):
|
||||
st.rerun()
|
||||
# We send only the numeric/card identifier (before :) or 'default'
|
||||
input_device = selected_option.split(":", 1)[0] if ":" in selected_option else selected_option
|
||||
else:
|
||||
@@ -76,23 +81,22 @@ if audio_mode in ["Webapp", "USB"]:
|
||||
|
||||
if stop_stream:
|
||||
try:
|
||||
r = requests.post(f"{BACKEND_URL}/stop_audio")
|
||||
if r.status_code == 200:
|
||||
r = requests.post(f"{BACKEND_URL}/stop_audio").json()
|
||||
if r['was_running']:
|
||||
st.success("Stream Stopped!")
|
||||
else:
|
||||
st.error(f"Failed to stop: {r.text}")
|
||||
st.success("Stream was not running.")
|
||||
except Exception as e:
|
||||
st.error(f"Error: {e}")
|
||||
|
||||
if start_stream:
|
||||
# Always send stop to ensure backend is in a clean state, regardless of current status
|
||||
try:
|
||||
requests.post(f"{BACKEND_URL}/stop_audio", timeout=5)
|
||||
except Exception:
|
||||
# Ignore connection or 500 errors – backend may not be running yet
|
||||
pass
|
||||
r = requests.post(f"{BACKEND_URL}/stop_audio").json()
|
||||
if r['was_running']:
|
||||
st.success("Stream Stopped!")
|
||||
|
||||
# Small pause lets backend fully release audio devices before re-init
|
||||
import time; time.sleep(0.7)
|
||||
import time; time.sleep(1)
|
||||
# Prepare config using the model (do NOT send qos_config, only relevant fields)
|
||||
q = quality_map[quality]
|
||||
config = auracast_config.AuracastConfigGroup(
|
||||
|
||||
Reference in New Issue
Block a user