ascii-chat
Binary v0.16.50-198-g78f51665f
Library lib/v0.3.2-2240-g78f51665f
Video chat in your terminal
Loading...
Searching...
No Matches
misc.c File Reference

Go to the source code of this file.

Typedefs

typedef void ui_mdns_server_t
typedef void render_file_t
typedef void media_source_t
typedef void symbol_cache_t
typedef void(* signal_handler_t) (int)
typedef void mdns_query_t
typedef void mdns_result_t

Functions

int keyboard_init (void)
int socket_init (void)
asciichat_error_t audio_stop_duplex (audio_context_t *ctx)
 Stop full-duplex audio.
void audio_terminate_portaudio_final (void)
 Terminate PortAudio and free all device resources.
tty_info_t get_current_tty (void)
terminal_capabilities_t apply_color_mode_override (terminal_capabilities_t caps, const terminal_options_t *options)
render_file_t * render_file_create (const char *output_file, int width, int height, int fps, int vcodec_id, int acodec_id)
void render_file_set_audio_source (render_file_t *rf, media_source_t *source, int sample_rate)
void render_file_set_video_source (render_file_t *rf, media_source_t *source)
int render_file_write_frame (render_file_t *rf, const uint8_t *data, uint64_t duration_ns)
int render_file_destroy (render_file_t *rf)
void render_file_set_snapshot_actual_duration (render_file_t *rf, double duration_sec)
int terminal_clear_scrollback (int fd)
int terminal_reset (int fd)
void symbol_cache_destroy (void)
void terminal_stop_resize_detection (void)
void known_hosts_destroy (void)
 Cleanup function to free cached known_hosts path.
int platform_restore_timer_resolution (void)
h265_encoder_t * h265_encoder_create (int width, int height, double fps)
signal_handler_t platform_signal (int sig, signal_handler_t handler)
void platform_force_exit (int exit_code)
void set_interrupt_callback (void(*callback)(void))
void signal_exit (void)
bool should_exit (void)
mdns_query_t * ui_mdns_query (const char *service)
mdns_result_t * ui_mdns_get_best_address (mdns_query_t *query)
int ui_mdns_select (const ui_mdns_server_t *servers, int count)
void ui_mdns_free_results (mdns_result_t *results)

Typedef Documentation

◆ mdns_query_t

typedef void mdns_query_t

Definition at line 144 of file misc.c.

◆ mdns_result_t

typedef void mdns_result_t

Definition at line 145 of file misc.c.

◆ media_source_t

typedef void media_source_t

Definition at line 46 of file misc.c.

◆ render_file_t

typedef void render_file_t

Definition at line 45 of file misc.c.

◆ signal_handler_t

typedef void(* signal_handler_t) (int)

Definition at line 121 of file misc.c.

◆ symbol_cache_t

typedef void symbol_cache_t

Definition at line 98 of file misc.c.

◆ ui_mdns_server_t

typedef void ui_mdns_server_t

Definition at line 16 of file misc.c.

Function Documentation

◆ apply_color_mode_override()

terminal_capabilities_t apply_color_mode_override ( terminal_capabilities_t caps,
const terminal_options_t * options )

Definition at line 40 of file misc.c.

40 {
41 (void)options;
42 return caps;
43}

Referenced by apply_color_mode_override_into(), session_display_create(), and session_protocol_build_capabilities().

◆ get_current_tty()

tty_info_t get_current_tty ( void )

Definition at line 35 of file misc.c.

35 {
36 tty_info_t tty = {0};
37 return tty;
38}

Referenced by session_display_create().

◆ h265_encoder_create()

h265_encoder_t * h265_encoder_create ( int width,
int height,
double fps )

Definition at line 113 of file misc.c.

113 {
114 (void)width;
115 (void)height;
116 (void)fps;
117 return NULL; // No video encoding in WASM
118}
unsigned int height
Definition fft.c:24
unsigned int width
Definition fft.c:24

References height, and width.

◆ keyboard_init()

int keyboard_init ( void )

Definition at line 18 of file misc.c.

18 {
19 return 0;
20}

Referenced by asciichat_shared_init(), stats_runtime_start(), ui_status_display_interactive(), and ui_sync_start().

◆ platform_force_exit()

void platform_force_exit ( int exit_code)

Definition at line 129 of file misc.c.

129 {
130 (void)exit_code;
131}

Referenced by session_handle_keyboard_input().

◆ platform_restore_timer_resolution()

int platform_restore_timer_resolution ( void )

Definition at line 107 of file misc.c.

107 {
108 return ASCIICHAT_OK;
109}
@ ASCIICHAT_OK
Definition error_codes.h:50

References ASCIICHAT_OK.

Referenced by asciichat_shared_destroy().

◆ platform_signal()

signal_handler_t platform_signal ( int sig,
signal_handler_t handler )

Definition at line 123 of file misc.c.

123 {
124 (void)sig;
125 (void)handler;
126 return NULL;
127}

Referenced by main(), and session_server_like_run().

◆ render_file_create()

render_file_t * render_file_create ( const char * output_file,
int width,
int height,
int fps,
int vcodec_id,
int acodec_id )

Definition at line 48 of file misc.c.

48 {
49 (void)output_file;
50 (void)width;
51 (void)height;
52 (void)fps;
53 (void)vcodec_id;
54 (void)acodec_id;
55 return NULL; // No file rendering in browser
56}

References height, and width.

◆ render_file_destroy()

int render_file_destroy ( render_file_t * rf)

Definition at line 76 of file misc.c.

76 {
77 (void)rf;
78 return 0;
79}

◆ render_file_set_audio_source()

void render_file_set_audio_source ( render_file_t * rf,
media_source_t * source,
int sample_rate )

Definition at line 58 of file misc.c.

58 {
59 (void)rf;
60 (void)source;
61 (void)sample_rate;
62}
audio_visualization_source_t source
Definition fft.c:25

References source.

◆ render_file_set_snapshot_actual_duration()

void render_file_set_snapshot_actual_duration ( render_file_t * rf,
double duration_sec )

Definition at line 81 of file misc.c.

81 {
82 (void)rf;
83 (void)duration_sec;
84}

◆ render_file_set_video_source()

void render_file_set_video_source ( render_file_t * rf,
media_source_t * source )

Definition at line 64 of file misc.c.

64 {
65 (void)rf;
66 (void)source;
67}

References source.

◆ render_file_write_frame()

int render_file_write_frame ( render_file_t * rf,
const uint8_t * data,
uint64_t duration_ns )

Definition at line 69 of file misc.c.

69 {
70 (void)rf;
71 (void)data;
72 (void)duration_ns;
73 return 0;
74}

◆ set_interrupt_callback()

void set_interrupt_callback ( void(* cb )(void))

Register a mode-specific interrupt callback

Called by mode-specific code to register a callback that will be invoked when signal_exit() is called. Used to shut down network sockets so threads blocked in recv() unblock quickly instead of waiting for timeouts.

The callback is called synchronously from signal_exit(), so it must be async-signal-safe (only atomics, socket_shutdown(), no malloc/etc).

Only one callback can be registered at a time. Setting a new callback replaces the previous one.

Parameters
cbFunction to call on exit signal, or NULL to unregister

Definition at line 133 of file misc.c.

133 {
134 (void)callback;
135}

◆ should_exit()

bool should_exit ( void )

Check if the application should exit

Called by mode main loops to detect shutdown requests from signals or errors.

Returns
true if shutdown has been requested, false otherwise

Definition at line 139 of file misc.c.

139 {
140 return false;
141}

◆ signal_exit()

void signal_exit ( void )

Signal that the application should exit

Sets the global exit flag and calls the registered interrupt callback if set. Safe to call from signal handlers (uses only atomics and function pointers). Called by signal handlers (SIGTERM, Ctrl+C) and normal code (errors, timeouts).

Definition at line 137 of file misc.c.

137{}

◆ socket_init()

int socket_init ( void )

Definition at line 22 of file misc.c.

22 {
23 return 0;
24}

Referenced by asciichat_shared_init().

◆ symbol_cache_destroy()

void symbol_cache_destroy ( void )

Definition at line 99 of file misc.c.

99{}

Referenced by asciichat_shared_destroy().

◆ terminal_clear_scrollback()

int terminal_clear_scrollback ( int fd)

Definition at line 87 of file misc.c.

87 {
88 (void)fd;
89 return ASCIICHAT_OK;
90}

References ASCIICHAT_OK.

◆ terminal_reset()

int terminal_reset ( int fd)

Definition at line 92 of file misc.c.

92 {
93 (void)fd;
94 return ASCIICHAT_OK;
95}

References ASCIICHAT_OK.

◆ terminal_stop_resize_detection()

void terminal_stop_resize_detection ( void )

Definition at line 102 of file misc.c.

102{}

Referenced by asciichat_shared_destroy().

◆ ui_mdns_free_results()

void ui_mdns_free_results ( mdns_result_t * results)

Definition at line 163 of file misc.c.

163 {
164 (void)results;
165}

◆ ui_mdns_get_best_address()

mdns_result_t * ui_mdns_get_best_address ( mdns_query_t * query)

Definition at line 152 of file misc.c.

152 {
153 (void)query;
154 return NULL;
155}

◆ ui_mdns_query()

mdns_query_t * ui_mdns_query ( const char * service)

Definition at line 147 of file misc.c.

147 {
148 (void)service;
149 return NULL;
150}

◆ ui_mdns_select()

int ui_mdns_select ( const ui_mdns_server_t * servers,
int count )

Shared controller list: arrows/j/k move, Enter selects, digits choose by number, Esc/q cancels. Resizes retain the selection and scroll it into view. Returns -1 without waiting when no interactive terminal is available.

Definition at line 157 of file misc.c.

157 {
158 (void)servers;
159 (void)count;
160 return -1;
161}