How 100askteam/xiaozhi-linux works
Major Components
• Control Center: This module (in the “control_center” folder) implements the core logic, interfaces and communication methods (e.g., HTTP, WebSocket client, UDP IPC, JSON utilities, UUID generation) that tie the various subsystems together.
• Sound App: The “sound_app” module handles audio-related functionalities – including recording, audio playback, audio encoding (Opus), and UDP IPC for data exchange.
• Graphical User Interface (GUI): Found in the “gui” folder, this component integrates LVGL and includes additional support libraries, demos, and configuration files. It provides the front-end user experience.
Interactions and Data Flow
• The Control Center serves as a central hub that interfaces with both the Sound App and the GUI.
• Sound App and Control Center exchange audio data and command signals using IPC via UDP (noted by the ipc_udp.* files in both modules).
• External services (if any) such as network communications (HTTP/WebSocket) are handled by the control_center.
Architectural Patterns and Design Principles
• Modular Separation: The project cleanly separates core functionality, audio processing, and graphical output. This separation enables platform-specific adaptations (BSP for different hardware platforms) without disrupting common core features.
• Layered Architecture: At the lower level, sound_app and control_center handle “backend” processing, while the gui layer is responsible for user interaction, likely driven by an event-loop paradigm (supported by LVGL).
• Communication via IPC: The use of UDP-based inter-process communication suggests a loosely coupled design where modules can communicate asynchronously.
• Use of Common Libraries: The GUI leverages LVGL and its many demos and configuration files. The control_center uses modern C++ utilities (JSON, UUID, HTTP, WebSocket) to manage flows.