ascii-chat 0.11.33
Video chat in your terminal
Loading...
Searching...
No Matches
misc.c File Reference

Miscellaneous stubs for WASM. More...

Go to the source code of this file.

Typedefs

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

Functions

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)
 Get current TTY information.
 
terminal_capabilities_t apply_color_mode_override (terminal_capabilities_t caps)
 Apply command-line overrides to detected capabilities.
 
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)
 
asciichat_error_t terminal_clear_scrollback (int fd)
 Clear terminal scrollback buffer.
 
asciichat_error_t terminal_reset (int fd)
 Reset terminal to default state.
 
void symbol_cache_destroy (void)
 Clean up the symbol cache and free all resources.
 
void terminal_stop_resize_detection (void)
 No-op stub on POSIX platforms (no resize detection thread)
 
void known_hosts_destroy (void)
 Cleanup function to free cached known_hosts path.
 
void platform_cleanup_binary_path_cache (void)
 Cleanup the binary PATH cache.
 
asciichat_error_t platform_restore_timer_resolution (void)
 Restore default timer precision.
 
h265_encoder_t * h265_encoder_create (int width, int height, double fps)
 
signal_handler_t platform_signal (int sig, signal_handler_t handler)
 Set a signal handler.
 
void platform_force_exit (int exit_code)
 Forcefully terminate the process immediately without cleanup.
 
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)
 TUI-based server selection with formatted display.
 
void ui_mdns_free_results (mdns_result_t *results)
 

Detailed Description

Miscellaneous stubs for WASM.

Definition in file misc.c.

Typedef Documentation

◆ audio_context_t

typedef void audio_context_t

Definition at line 12 of file misc.c.

◆ h265_encoder_t

typedef void h265_encoder_t

Definition at line 104 of file misc.c.

◆ mdns_query_t

typedef void mdns_query_t

Definition at line 136 of file misc.c.

◆ mdns_result_t

typedef void mdns_result_t

Definition at line 137 of file misc.c.

◆ media_source_t

typedef void media_source_t

Definition at line 34 of file misc.c.

◆ render_file_t

typedef void render_file_t

Definition at line 33 of file misc.c.

◆ signal_handler_t

typedef void(* signal_handler_t) (int)

Definition at line 113 of file misc.c.

◆ symbol_cache_t

typedef void symbol_cache_t

Definition at line 87 of file misc.c.

◆ ui_mdns_server_t

typedef void ui_mdns_server_t

Definition at line 13 of file misc.c.

Function Documentation

◆ apply_color_mode_override()

terminal_capabilities_t apply_color_mode_override ( terminal_capabilities_t  caps)

Apply command-line overrides to detected capabilities.

Parameters
capsTerminal capabilities structure to modify
Returns
Modified terminal capabilities structure

Applies any command-line option overrides to the detected terminal capabilities. Overrides may include:

  • Force color mode (–color, –no-color, –256, –truecolor)
  • Force UTF-8 mode (–utf8)
  • Render mode selection (–bg, –fg, –half-block)
  • Palette selection (–palette)
Note
Returns a modified copy of the input structure.
Overrides take precedence over detected capabilities.

Definition at line 29 of file misc.c.

29 {
30 return caps;
31}

Referenced by main(), session_display_create(), and threaded_send_terminal_size_with_auto_detect().

◆ get_current_tty()

tty_info_t get_current_tty ( void  )

Get current TTY information.

Returns
TTY information structure with file descriptor and path

Retrieves information about the current TTY (terminal). Returns file descriptor for TTY access, device path, and ownership information. Useful for advanced terminal operations that require direct TTY access.

Note
File descriptor may need to be closed if owns_fd is true.
TTY path is platform-specific (Unix: /dev/tty, Windows: CON, etc.).

Definition at line 24 of file misc.c.

24 {
25 tty_info_t tty = {0};
26 return tty;
27}
TTY detection and management structure.
Definition terminal.h:753

Referenced by session_display_create().

◆ h265_encoder_create()

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

Definition at line 105 of file misc.c.

105 {
106 (void)width;
107 (void)height;
108 (void)fps;
109 return NULL; // No video encoding in WASM
110}

Referenced by h265_client_context_create().

◆ 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 36 of file misc.c.

37 {
38 (void)output_file;
39 (void)width;
40 (void)height;
41 (void)fps;
42 (void)vcodec_id;
43 (void)acodec_id;
44 return NULL; // No file rendering in browser
45}

◆ render_file_destroy()

int render_file_destroy ( render_file_t *  rf)

Definition at line 65 of file misc.c.

65 {
66 (void)rf;
67 return 0;
68}

◆ 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 47 of file misc.c.

47 {
48 (void)rf;
49 (void)source;
50 (void)sample_rate;
51}

◆ render_file_set_snapshot_actual_duration()

void render_file_set_snapshot_actual_duration ( render_file_t *  rf,
double  duration_sec 
)

Definition at line 70 of file misc.c.

70 {
71 (void)rf;
72 (void)duration_sec;
73}

◆ render_file_set_video_source()

void render_file_set_video_source ( render_file_t *  rf,
media_source_t *  source 
)

Definition at line 53 of file misc.c.

53 {
54 (void)rf;
55 (void)source;
56}

◆ render_file_write_frame()

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

Definition at line 58 of file misc.c.

58 {
59 (void)rf;
60 (void)data;
61 (void)duration_ns;
62 return 0;
63}

◆ set_interrupt_callback()

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

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 125 of file misc.c.

125 {
126 (void)callback;
127}

Referenced by client_main(), and discovery_main().

◆ 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 131 of file misc.c.

131 {
132 return false;
133}

Referenced by client_main(), connection_attempt_tcp(), connection_attempt_websocket(), display_full_reset(), protocol_start_connection(), server_connection_establish(), session_client_like_run(), session_pipeline_run_main(), and session_render_loop().

◆ 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 129 of file misc.c.

129{}

Referenced by client_main(), and session_render_loop().

◆ terminal_stop_resize_detection()

void terminal_stop_resize_detection ( void  )

No-op stub on POSIX platforms (no resize detection thread)

Definition at line 91 of file misc.c.

91{}

Referenced by asciichat_shared_destroy().

◆ ui_mdns_free_results()

void ui_mdns_free_results ( mdns_result_t *  results)

Definition at line 155 of file misc.c.

155 {
156 (void)results;
157}

Referenced by client_main().

◆ ui_mdns_get_best_address()

mdns_result_t * ui_mdns_get_best_address ( mdns_query_t *  query)

Definition at line 144 of file misc.c.

144 {
145 (void)query;
146 return NULL;
147}

Referenced by client_main().

◆ ui_mdns_query()

mdns_query_t * ui_mdns_query ( const char *  service)

Definition at line 139 of file misc.c.

139 {
140 (void)service;
141 return NULL;
142}

Referenced by client_main().

◆ ui_mdns_select()

int ui_mdns_select ( const ui_mdns_server_t *  servers,
int  count 
)

TUI-based server selection with formatted display.

Displays discovered servers in a formatted terminal UI with:

  • Clear screen and boxed display
  • Server list with numbering and addresses
  • "No results" message if no servers available
  • Interactive numeric selection prompt

Display Example (3 servers):

╭─ 🔍 ascii-chat Server Discovery ────────────╮
│
│ Found 3 servers on your local network:
│
│ [1] swift-river-canyon 192.168.1.100:27224
│ [2] quiet-mountain-lake 192.168.1.101:27224
│ [3] gentle-forest-breeze 192.168.1.102:27224
│
╰────────────────────────────────────────────╯
Enter server number (1-3) or press Enter to cancel:

No Results Display:

╭─ 🔍 ascii-chat Server Discovery ─╮
│
│ No servers found on local network
│
│ Make sure an ascii-chat server is running on your LAN
│ Or provide a server address manually: ascii-chat client <address>
│
╰─────────────────────────────────────────╯
Parameters
serversArray of discovered servers
countNumber of servers (0 for "no results")
Returns
0-based index of selected server, or -1 to cancel

Definition at line 149 of file misc.c.

149 {
150 (void)servers;
151 (void)count;
152 return -1;
153}

Referenced by client_main().