Cubeb Audio Remoting For Gecko
Перейти к файлу
Andreas Pehrson e6f44a2bd1 Handle data callbacks of size zero
The client side does not allow CallbackData::Req of size zero. This
handles it on the server side by returning early.

The background for this is https://bugzilla.mozilla.org/show_bug.cgi?id=1907367
where something is causing data callbacks of size zero and tripping an
assertion, but we have not reproduced and an audit is not conclusive as
to where the root cause is.
2024-08-08 09:00:46 +12:00
.github/workflows Switch to windows-sys. 2023-10-25 19:47:44 +13:00
audioipc Update mio to 1.0 2024-07-30 12:16:45 +12:00
client Update cubeb dependencies to 0.13 2024-05-15 13:51:25 +02:00
ipctest Update cubeb dependencies to 0.13 2024-05-15 13:51:25 +02:00
server Handle data callbacks of size zero 2024-08-08 09:00:46 +12:00
.gitignore Add .gitignore 2017-07-10 18:44:47 +10:00
Cargo.toml Temporarily switch to local fork of tokio-uds's stream.rs until upstream PR 1294 is resolved. 2019-07-24 09:41:07 +12:00
README.md Use a separate EventLoopThread for device_collection_change callbacks. 2021-12-16 13:45:14 +13:00
rustfmt.toml cargo fmt pass. 2019-07-25 11:44:12 +12:00

README.md

cubeb audio remoting for Gecko

An IPC client/server providing inter-process remoting of the cubeb audio API.

A single server running in a parent or server process interfaces with cubeb on behalf of multiple client or child processes.

On the server side, the external interface is a small set of C FFI functions to initialize and destroy the server (audioipc_server_start/audioipc_server_stop) and create new server connections (audioipc_server_new_client). On the client side, the external interface consists of a single C FFI function (audioipc_client_init), replacing a call to cubeb_init and returning a cubeb context that transparently remotes the cubeb API to the server; aside from this the client uses the cubeb API and remoting is handled transparently. audioipc_server_new_client returns a handle that must be supplied to audioipc_client_init to establish the client-server connection. Transferring this handle from the server process to the client process is done externally, in Gecko code.

  • The client side remoting layer (located in the client crate) contains ClientContext and ClientStream, which adapts the cubeb context and cubeb stream APIs (respectively) to the RPC layer. This is driven by one "Client RPC" EventLoopThread per ClientContext and one "Client Callback" EventLoopThread per ClientStream.
  • The server side remoting layer (located in the server crate) contains CubebServer, which adapts both context and stream RPCs to native cubeb API calls. This is driven by a single trio of "Server RPC", "Server Callback", and "Server DeviceCollection RPC) EventLoopThreads servicing all CubebServer instances.
  • Core RPC and IPC functionality and support code is located in the audioipc crate.
    • The RPC interface provides a Client trait specifying message types the client implementation will use, and a Server trait specifying message types the server implementation will use and a process function that handles incoming messages and produces responses. Server and Client implementations work as pairs, with one on each side of the IPC connection. Server and Client implementations are driven by an EventLoopThread once bound to the event loop with a connection via bind_server or bind_client. Each Server implementation may have multiple associated Client implementations in one or more remote process.
    • The RPC interface also provides Proxy and ProxyResponse objects, providing a blocking thread-safe mechanism to send and receive RPC messages from arbitrary threads.
    • The IPC interface provides the core EventLoopThread object, responsible for driving inter-process communication on each end of previously bound Client and Server implementations (and their associated connections).
    • The IPC interface also provides a cloneable, sendable EventLoopHandle object associated with an EventLoopThread that allows arbitrary threads to bind Client and Server implementations and signal the EventLoopThread to shut down.