2026-02-15 21:11:33 +09:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
2026-02-15 22:55:53 +09:00
|
|
|
#include <freertos/FreeRTOS.h>
|
|
|
|
|
#include <freertos/task.h>
|
2026-02-15 21:46:18 +09:00
|
|
|
#include "lvgl.h"
|
2026-02-15 21:11:33 +09:00
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
|
AUDIO_IDLE = 0,
|
|
|
|
|
AUDIO_CONNECTED,
|
|
|
|
|
AUDIO_PLAYING,
|
|
|
|
|
AUDIO_ERROR,
|
|
|
|
|
} audio_state_t;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Initialize the audio streaming client.
|
|
|
|
|
* @param uri WebSocket URI (e.g. "ws://192.168.2.199:8766")
|
|
|
|
|
* @param codec Pointer to CodecPort instance (passed as void* for C linkage)
|
|
|
|
|
*/
|
|
|
|
|
void audio_client_init(const char *uri, void *codec);
|
|
|
|
|
|
|
|
|
|
/** Start the WebSocket connection and playback task. */
|
|
|
|
|
void audio_client_start(void);
|
|
|
|
|
|
|
|
|
|
/** Stop playback and disconnect. */
|
|
|
|
|
void audio_client_stop(void);
|
|
|
|
|
|
|
|
|
|
/** Get current audio client state. */
|
|
|
|
|
audio_state_t audio_client_get_state(void);
|
|
|
|
|
|
2026-02-15 22:55:53 +09:00
|
|
|
/**
|
|
|
|
|
* Register a task to be notified (via xTaskNotifyGive) when a new status
|
|
|
|
|
* image arrives. Call before audio_client_start().
|
|
|
|
|
*/
|
|
|
|
|
void audio_client_set_image_notify_task(TaskHandle_t task);
|
|
|
|
|
|
2026-02-15 21:46:18 +09:00
|
|
|
/**
|
|
|
|
|
* Get the latest status image descriptor.
|
2026-02-16 21:56:28 +09:00
|
|
|
* @param updated Set to true if a new image arrived since last call.
|
2026-02-15 21:46:18 +09:00
|
|
|
* @return Pointer to the static image descriptor (always valid).
|
|
|
|
|
*/
|
|
|
|
|
const lv_img_dsc_t *audio_client_get_status_image(bool *updated);
|
|
|
|
|
|
2026-02-16 21:56:28 +09:00
|
|
|
/**
|
|
|
|
|
* Acknowledge that the status image was successfully rendered.
|
|
|
|
|
* Clears the updated flag so subsequent get_status_image calls return false.
|
|
|
|
|
*/
|
|
|
|
|
void audio_client_ack_status_image(void);
|
|
|
|
|
|
2026-02-15 21:11:33 +09:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|