Skip to content

Integrating AFV Native

Chris Collins edited this page Nov 5, 2019 · 1 revision

Responsibilities

The VATSIM Client Author must:

  • Translate their frequencies to correct frequencies in Hz, correcting for any truncation that has occurred due to client limitations. (That is: x.22MHz -> x.225, etc)

  • Apply any HF Aliasing as appropriate

  • Regularly update their client position and radio set information with AFV-Native

  • Manage probing AudioDevice to get audio device information, and offer an interface to end-users so they may pick which devices they want to work.

  • Implement a mic peak meter for set-up that advises users to set their mics to peak in the -12dB to -4dB range. (Look at the standalone AFV client and XSB for recommended styles for this meter)

Integration

The main integration points in AFV-Native at this time are:

  • The afv_native::Client class, which provides a high level abstracted AFV multi-radio stack simulation.
  • The afv_native::audio::AudioDevice class, which has all of the audio hardware enumeration methods directly exported.

note: AFV-Native is not completely threadsafe on it's own (it provides thread-safety across the audio playback boundary, but not across the main API - decisions on how to manage that are left to the integrator).

A VATSIM client using AFV-Native to connect to the AFV servers should:

  • create a libevent2 event_base that it will run to keep data moving. This event_base should be able to service requests with no longer than a 15-20ms interval. (XSB runs the event_base in a dedicated thread to avoid hitching issues created by running it between frames).

  • Instantiate a afv_native::Client with the event_base, path to the resources, URL, and number of radios desired.

  • Attach a ClientEventCallback handler on the Client object that will be called from the event_base thread to notify the client of changes in AFV-Native's state.

  • Set the credentials and callsign on the Client object.

  • Update the radio states on the Client object

  • Call connect() to start the AFV connection.

  • Continue to update the states whilst the client is connected.