feat: add diagnostic logging for audio input and frame processing
- Log audio input details (type, source, sample rate, channels) when opening - Log first PCM frame metadata (size, samples, bytes per frame) for debugging - Log first LC3 encoded frame size to verify encoding pipeline
This commit is contained in:
@@ -597,6 +597,9 @@ class Streamer():
|
|||||||
for attempt in range(1, max_attempts + 1):
|
for attempt in range(1, max_attempts + 1):
|
||||||
try:
|
try:
|
||||||
pcm_format = await audio_input.open()
|
pcm_format = await audio_input.open()
|
||||||
|
logging.info(
|
||||||
|
f"Opened audio input: {type(audio_input).__name__} src={audio_source} sr={pcm_format.sample_rate} ch={pcm_format.channels}"
|
||||||
|
)
|
||||||
break # success
|
break # success
|
||||||
except _sd.PortAudioError as err:
|
except _sd.PortAudioError as err:
|
||||||
# -9985 == paDeviceUnavailable
|
# -9985 == paDeviceUnavailable
|
||||||
@@ -720,6 +723,12 @@ class Streamer():
|
|||||||
# Read the frame we need for encoding
|
# Read the frame we need for encoding
|
||||||
pcm_frame = await anext(frames_gen, None)
|
pcm_frame = await anext(frames_gen, None)
|
||||||
|
|
||||||
|
if big.get('logged_first_frame') is not True:
|
||||||
|
logging.info(
|
||||||
|
f"First PCM frame bytes={0 if pcm_frame is None else len(pcm_frame)} | lc3_frame_samples={big['lc3_frame_samples']} | bytes_per_frame={big['lc3_bytes_per_frame']}"
|
||||||
|
)
|
||||||
|
big['logged_first_frame'] = True
|
||||||
|
|
||||||
if pcm_frame is None: # Not all streams may stop at the same time
|
if pcm_frame is None: # Not all streams may stop at the same time
|
||||||
stream_finished[i] = True
|
stream_finished[i] = True
|
||||||
continue
|
continue
|
||||||
@@ -808,6 +817,13 @@ class Streamer():
|
|||||||
pcm_frame, num_bytes=big['lc3_bytes_per_frame'], bit_depth=big['pcm_bit_depth']
|
pcm_frame, num_bytes=big['lc3_bytes_per_frame'], bit_depth=big['pcm_bit_depth']
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if big.get('logged_first_lc3') is not True:
|
||||||
|
try:
|
||||||
|
logging.info(f"First LC3 frame size={len(lc3_frame)} bytes")
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
big['logged_first_lc3'] = True
|
||||||
|
|
||||||
await big['iso_queue'].write(lc3_frame)
|
await big['iso_queue'].write(lc3_frame)
|
||||||
frame_count += 1
|
frame_count += 1
|
||||||
# Increment guard counter (tracks frames since last discard)
|
# Increment guard counter (tracks frames since last discard)
|
||||||
|
|||||||
Reference in New Issue
Block a user