Loading...
Searching...
No Matches
EAR-owned survey admission, finalization and generic point completions.
More...
#include "ear_camera_backend.h"
#include "ear_cam_pipe.h"
#include "image_exif.h"
#include <errno.h>
#include <limits.h>
#include <math.h>
#include <pthread.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <unistd.h>
Go to the source code of this file.
|
| static bool | ear_point_valid (const struct ear_loudest_spot *spot) |
| | Guard finite values and integer conversion ranges before marking a wire point valid.
|
| static void | wake_ear_result_owner (void) |
| | Notify the serial owner without blocking; mailbox flags remain authoritative if full.
|
| static void * | finalize_ear_sessions (void *unused) |
| | Drain stopped sessions in admission order until shutdown has no work left.
|
| static bool | ear_poll_result (struct camera_point_result *result) |
| | Consume one completion on the serial owner and convert physical units once.
|
| static bool | ear_start (uint32_t session_id) |
| | Reserve both finalizer capacity and adapter storage before listening.
|
| static bool | ear_stop (uint32_t session_id) |
| | Validate the active token before a zero-copy snapshot handoff.
|
| static void | ear_drain (void) |
| | Close admission and join all admitted stopped-session evidence work.
|
| static bool | ear_listening (void) |
| | Whether the serial owner should admit EAR samples for the current session.
|
| static int | ear_completion_fd (void) |
| | Nonblocking completion descriptor, or -1 before start/after drain.
|
| static void | ear_configure (const struct camera_backend_host *host) |
| | Copy startup-only host callbacks; worker-side queue_analysis must be thread-safe.
|
| static int | ear_init (const char *source) |
| | Initialize supervision, not microphone readiness; hard setup failure stays latched.
|
| static void | ear_deinit (void) |
| | Drain before tearing down audio/storage, then reset quiescent finalizer state.
|
| bool | ear_camera_backend_set_device (const char *device) |
| | Copy an ALSA PCM name before initialization or worker startup.
|
| void | ear_camera_backend_set_simulated_source (double lat_deg, double lon_deg, double level_db_at_1m) |
| | Select deterministic synthetic audio before initialization, bypassing ALSA.
|
| void | ear_camera_backend_set_band (double low_cut_hz, double high_cut_hz) |
| | Forward startup tone-band selection to the audio adapter.
|
| struct camera_backend | ear_camera_backend_get (void) |
| | Return the EAR backend descriptor by value; its session hook table has static lifetime.
|
EAR-owned survey admission, finalization and generic point completions.
USHER's serial owner calls lifecycle/configuration/poll hooks. One joinable worker solves immutable snapshots and writes evidence; it never owns UART or live pose lookup. A small wake channel signals mailbox state, not data.
Definition in file ear_camera_backend.c.
◆ EAR_COMPLETION_DRAIN_BYTES
| #define EAR_COMPLETION_DRAIN_BYTES 16 |
◆ EAR_COMPLETION_ENDPOINT_COUNT
| #define EAR_COMPLETION_ENDPOINT_COUNT 2 |
◆ EAR_COORDINATE_UNITS_PER_DEG
| #define EAR_COORDINATE_UNITS_PER_DEG 1e7 |
◆ EAR_EVIDENCE_PATH_CAPACITY
| #define EAR_EVIDENCE_PATH_CAPACITY 512 |
◆ EAR_FINALIZE_JOB_COUNT
| #define EAR_FINALIZE_JOB_COUNT 2 |
Two jobs match the adapter's two buffers: stopped evidence is never evicted.
Definition at line 43 of file ear_camera_backend.c.
◆ EAR_LATITUDE_LIMIT_DEG
| #define EAR_LATITUDE_LIMIT_DEG 90 |
◆ EAR_LONGITUDE_LIMIT_DEG
| #define EAR_LONGITUDE_LIMIT_DEG 180 |
◆ EAR_METRIC_UNITS_PER_DB
| #define EAR_METRIC_UNITS_PER_DB 100.0 |
◆ EAR_MILLIMETERS_PER_METER
| #define EAR_MILLIMETERS_PER_METER 1000.0 |
◆ EAR_QUALITY_UNITS_PER_SCORE
| #define EAR_QUALITY_UNITS_PER_SCORE 1000.0 |
◆ EAR_SHOT_AGL_UNITS_PER_METER
| #define EAR_SHOT_AGL_UNITS_PER_METER 256.0 |
Legacy dc_shot groundalt carries AGL in Q8 metres, unlike CAM_POINT_RESULT millimetres.
Definition at line 54 of file ear_camera_backend.c.
◆ USHER_SODA
| #define USHER_SODA "./bin/soda" |
◆ ear_camera_backend_get()
Return the EAR backend descriptor by value; its session hook table has static lifetime.
- Returns
- Descriptor advertising point-session capability, not optical still capture.
Definition at line 344 of file ear_camera_backend.c.
◆ ear_camera_backend_set_band()
| void ear_camera_backend_set_band |
( |
double | low_cut_hz, |
|
|
double | high_cut_hz ) |
Forward startup tone-band selection to the audio adapter.
- Parameters
-
| low_cut_hz | Lower band edge, hertz. |
| high_cut_hz | Upper band edge, hertz; valid ordering is the CLI caller's responsibility. |
Definition at line 342 of file ear_camera_backend.c.
◆ ear_camera_backend_set_device()
| bool ear_camera_backend_set_device |
( |
const char * | device | ) |
|
Copy an ALSA PCM name before initialization or worker startup.
- Parameters
-
| device | Nonempty bounded ALSA name, such as default or plughw:CARD=USB,DEV=0. |
- Returns
- True when copied; false for invalid input or active lifecycle state.
Caller memory may be released on return. Simulation is selected separately.
Definition at line 332 of file ear_camera_backend.c.
◆ ear_camera_backend_set_simulated_source()
| void ear_camera_backend_set_simulated_source |
( |
double | lat_deg, |
|
|
double | lon_deg, |
|
|
double | level_db_at_1m ) |
Select deterministic synthetic audio before initialization, bypassing ALSA.
- Parameters
-
| lat_deg | Fixed source latitude, degrees. |
| lon_deg | Fixed source longitude, degrees. |
| level_db_at_1m | Simulated level at one metre; a test model, not measured calibration. |
Definition at line 337 of file ear_camera_backend.c.
◆ ear_completion_fd()
| int ear_completion_fd |
( |
void | | ) |
|
|
static |
Nonblocking completion descriptor, or -1 before start/after drain.
Definition at line 298 of file ear_camera_backend.c.
◆ ear_configure()
Copy startup-only host callbacks; worker-side queue_analysis must be thread-safe.
Definition at line 300 of file ear_camera_backend.c.
◆ ear_deinit()
Drain before tearing down audio/storage, then reset quiescent finalizer state.
Definition at line 317 of file ear_camera_backend.c.
◆ ear_drain()
Close admission and join all admitted stopped-session evidence work.
Completed point mailboxes remain pollable after the wake channel closes. This is orderly draining, not a hard filesystem-I/O deadline or power-loss guarantee.
Definition at line 280 of file ear_camera_backend.c.
◆ ear_init()
| int ear_init |
( |
const char * | source | ) |
|
|
static |
Initialize supervision, not microphone readiness; hard setup failure stays latched.
Definition at line 307 of file ear_camera_backend.c.
◆ ear_listening()
| bool ear_listening |
( |
void | | ) |
|
|
static |
Whether the serial owner should admit EAR samples for the current session.
Definition at line 296 of file ear_camera_backend.c.
◆ ear_point_valid()
Guard finite values and integer conversion ranges before marking a wire point valid.
Definition at line 82 of file ear_camera_backend.c.
◆ ear_poll_result()
Consume one completion on the serial owner and convert physical units once.
- Returns
- True when result receives a correlated valid or invalid point.
Wake bytes may coalesce; scan mailbox flags even after draining the socket. USHER retains responsibility for token correlation and actual UART delivery.
Definition at line 168 of file ear_camera_backend.c.
◆ ear_start()
| bool ear_start |
( |
uint32_t | session_id | ) |
|
|
static |
Reserve both finalizer capacity and adapter storage before listening.
- Returns
- False for zero token, shutdown, exhausted capacity or worker/buffer failure.
Replacing an unfinished active session releases only its reservation; stopped snapshots stay admitted. Generic USHER routing handles duplicate tokens.
Definition at line 210 of file ear_camera_backend.c.
◆ ear_stop()
| bool ear_stop |
( |
uint32_t | session_id | ) |
|
|
static |
Validate the active token before a zero-copy snapshot handoff.
- Returns
- True only when an immutable session was queued for the worker.
Failed detach releases the reservation; a wrong token cannot stop listening.
Definition at line 259 of file ear_camera_backend.c.
◆ finalize_ear_sessions()
| void * finalize_ear_sessions |
( |
void * | unused | ) |
|
|
static |
Drain stopped sessions in admission order until shutdown has no work left.
The point mailbox is published before potentially slow CSV/JPEG/EXIF and optional SODA submission. Never perform UART sends or live pose lookups here.
Definition at line 110 of file ear_camera_backend.c.
◆ wake_ear_result_owner()
| void wake_ear_result_owner |
( |
void | | ) |
|
|
static |
Notify the serial owner without blocking; mailbox flags remain authoritative if full.
Definition at line 96 of file ear_camera_backend.c.
◆ current_ear_job
◆ ear_finalize_available
| pthread_cond_t ear_finalize_available = PTHREAD_COND_INITIALIZER |
|
static |
◆ ear_finalize_jobs
◆ ear_finalize_mutex
| pthread_mutex_t ear_finalize_mutex = PTHREAD_MUTEX_INITIALIZER |
|
static |
◆ ear_finalize_order
| uint64_t ear_finalize_order |
|
static |
◆ ear_finalize_started
| bool ear_finalize_started |
|
static |
◆ ear_finalize_stopping
| bool ear_finalize_stopping |
|
static |
◆ ear_finalize_thread
| pthread_t ear_finalize_thread |
|
static |
◆ ear_finalize_wake
◆ ear_host
◆ earcam_active
◆ earcam_session_active
| bool earcam_session_active |
|
static |
◆ earcam_simulated
◆ earcam_unavailable