Skip to content

Commit 91c3b33

Browse files
committed
example: fix audio_debug glitch on Windows
1 parent 4632a78 commit 91c3b33

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

examples/device/uac2_speaker_fb/src/audio_debug.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
# Install python3 HID package https://pypi.org/project/hid/
33
# Install python3 matplotlib package https://pypi.org/project/matplotlib/
44

5-
from ctypes import *
5+
from ctypes import Structure, c_uint32, c_uint8, c_int8, c_int16, c_uint16
6+
import signal
67
try:
78
import hid
89
import matplotlib.pyplot as plt
910
import matplotlib.animation as animation
1011
except:
1112
print("Missing import, please try 'pip install hid matplotlib' or consult your OS's python package manager.")
13+
exit(1)
1214

1315
# Example must be compiled with CFG_AUDIO_DEBUG=1
1416
VID = 0xcafe
@@ -29,6 +31,7 @@ class audio_debug_info_t (Structure):
2931
dev = hid.Device(VID, PID)
3032

3133
if dev:
34+
signal.signal(signal.SIGINT, signal.SIG_DFL)
3235
# Create figure for plotting
3336
fig = plt.figure()
3437
ax = fig.add_subplot(1, 1, 1)
@@ -61,10 +64,10 @@ def animate(i):
6164
ax.set_ylim(bottom=0, top=info.fifo_size)
6265

6366
# Format plot
64-
plt.title('FIFO information')
65-
plt.grid()
67+
ax.set_title('FIFO information')
68+
ax.grid(True)
6669

6770
print(f'Sample rate:{info.sample_rate} | Alt settings:{info.alt_settings} | Volume:{info.volume[:]}')
6871

69-
ani = animation.FuncAnimation(fig, animate, interval=10)
70-
plt.show()
72+
ani = animation.FuncAnimation(fig, animate, interval=10, cache_frame_data=False) # type: ignore
73+
plt.show(block=True)

0 commit comments

Comments
 (0)