Commit 683c5312 authored by Matthew Gregan's avatar Matthew Gregan
Browse files

Bug 1724141 - Update audioipc to 8bb1a227. r=chunmin

parent 83fb89d3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ rev = "8ae48c16b637d6d9a841cf4d01de06c16b1318b0"
[source."https://github.com/mozilla/audioipc-2"]
git = "https://github.com/mozilla/audioipc-2"
replace-with = "vendored-sources"
rev = "7537bfadad2e981577eb75e4f13662fc517e1a09"
rev = "8bb1a227fbaa5677458bcd876162b65307df38c2"

[source."https://github.com/mozilla/application-services"]
git = "https://github.com/mozilla/application-services"
+3 −3
Original line number Diff line number Diff line
@@ -169,7 +169,7 @@ dependencies = [
[[package]]
name = "audioipc"
version = "0.2.5"
source = "git+https://github.com/mozilla/audioipc-2?rev=7537bfadad2e981577eb75e4f13662fc517e1a09#7537bfadad2e981577eb75e4f13662fc517e1a09"
source = "git+https://github.com/mozilla/audioipc-2?rev=8bb1a227fbaa5677458bcd876162b65307df38c2#8bb1a227fbaa5677458bcd876162b65307df38c2"
dependencies = [
 "ashmem",
 "audio_thread_priority",
@@ -198,7 +198,7 @@ dependencies = [
[[package]]
name = "audioipc-client"
version = "0.4.0"
source = "git+https://github.com/mozilla/audioipc-2?rev=7537bfadad2e981577eb75e4f13662fc517e1a09#7537bfadad2e981577eb75e4f13662fc517e1a09"
source = "git+https://github.com/mozilla/audioipc-2?rev=8bb1a227fbaa5677458bcd876162b65307df38c2#8bb1a227fbaa5677458bcd876162b65307df38c2"
dependencies = [
 "audio_thread_priority",
 "audioipc",
@@ -212,7 +212,7 @@ dependencies = [
[[package]]
name = "audioipc-server"
version = "0.2.3"
source = "git+https://github.com/mozilla/audioipc-2?rev=7537bfadad2e981577eb75e4f13662fc517e1a09#7537bfadad2e981577eb75e4f13662fc517e1a09"
source = "git+https://github.com/mozilla/audioipc-2?rev=8bb1a227fbaa5677458bcd876162b65307df38c2#8bb1a227fbaa5677458bcd876162b65307df38c2"
dependencies = [
 "audio_thread_priority",
 "audioipc",
+23 −6
Original line number Diff line number Diff line
@@ -43,6 +43,8 @@

#define AUDIOIPC_POOL_SIZE_DEFAULT 1
#define AUDIOIPC_STACK_SIZE_DEFAULT (64 * 4096)
// See also: https://github.com/mozilla/audioipc-2/issues/124
#define AUDIOIPC_SHM_AREA_SIZE_DEFAULT (512 * 4096)

#define PREF_VOLUME_SCALE "media.volume_scale"
#define PREF_CUBEB_BACKEND "media.cubeb.backend"
@@ -59,6 +61,7 @@
#define PREF_CUBEB_SANDBOX "media.cubeb.sandbox"
#define PREF_AUDIOIPC_POOL_SIZE "media.audioipc.pool_size"
#define PREF_AUDIOIPC_STACK_SIZE "media.audioipc.stack_size"
#define PREF_AUDIOIPC_SHM_AREA_SIZE "media.audioipc.shm_area_size"

#if (defined(XP_LINUX) && !defined(MOZ_WIDGET_ANDROID)) || \
    defined(XP_MACOSX) || (defined(XP_WIN) && !defined(_ARM64_))
@@ -108,6 +111,7 @@ bool sRouteOutputAsVoice = false;
bool sCubebSandbox = false;
size_t sAudioIPCPoolSize;
size_t sAudioIPCStackSize;
size_t sAudioIPCShmAreaSize;
#endif
StaticAutoPtr<char> sBrandName;
StaticAutoPtr<char> sCubebBackendName;
@@ -269,6 +273,10 @@ void PrefChanged(const char* aPref, void* aClosure) {
    StaticMutexAutoLock lock(sMutex);
    sAudioIPCStackSize = Preferences::GetUint(PREF_AUDIOIPC_STACK_SIZE,
                                              AUDIOIPC_STACK_SIZE_DEFAULT);
  } else if (strcmp(aPref, PREF_AUDIOIPC_SHM_AREA_SIZE) == 0) {
    StaticMutexAutoLock lock(sMutex);
    sAudioIPCShmAreaSize = Preferences::GetUint(PREF_AUDIOIPC_SHM_AREA_SIZE,
                                                AUDIOIPC_SHM_AREA_SIZE_DEFAULT);
  }
#endif
  else if (strcmp(aPref, PREF_CUBEB_OUTPUT_VOICE_ROUTING) == 0) {
@@ -409,6 +417,7 @@ void InitAudioIPCConnection() {

ipc::FileDescriptor CreateAudioIPCConnection() {
#ifdef MOZ_CUBEB_REMOTING
  StaticMutexAutoLock lock(sMutex);
  MOZ_ASSERT(sCubebSandbox && XRE_IsParentProcess());
  if (!sServerHandle) {
    MOZ_LOG(gCubebLog, LogLevel::Debug, ("Starting cubeb server..."));
@@ -417,9 +426,11 @@ ipc::FileDescriptor CreateAudioIPCConnection() {
      return ipc::FileDescriptor();
    }
  }
  MOZ_LOG(gCubebLog, LogLevel::Debug,
          ("%s: %d", PREF_AUDIOIPC_SHM_AREA_SIZE, (int)sAudioIPCShmAreaSize));
  MOZ_ASSERT(sServerHandle);
  ipc::FileDescriptor::PlatformHandleType rawFD =
      audioipc::audioipc_server_new_client(sServerHandle);
      audioipc::audioipc_server_new_client(sServerHandle, sAudioIPCShmAreaSize);
  ipc::FileDescriptor fd(rawFD);
  if (!fd.IsValid()) {
    MOZ_LOG(gCubebLog, LogLevel::Error, ("audioipc_server_new_client failed"));
@@ -582,11 +593,17 @@ uint32_t GetCubebMTGLatencyInFrames(cubeb_stream_params* params) {
}

static const char* gInitCallbackPrefs[] = {
    PREF_VOLUME_SCALE,           PREF_CUBEB_OUTPUT_DEVICE,
    PREF_CUBEB_LATENCY_PLAYBACK, PREF_CUBEB_LATENCY_MTG,
    PREF_CUBEB_BACKEND,          PREF_CUBEB_FORCE_NULL_CONTEXT,
    PREF_CUBEB_SANDBOX,          PREF_AUDIOIPC_POOL_SIZE,
    PREF_AUDIOIPC_STACK_SIZE,    nullptr,
    PREF_VOLUME_SCALE,
    PREF_CUBEB_OUTPUT_DEVICE,
    PREF_CUBEB_LATENCY_PLAYBACK,
    PREF_CUBEB_LATENCY_MTG,
    PREF_CUBEB_BACKEND,
    PREF_CUBEB_FORCE_NULL_CONTEXT,
    PREF_CUBEB_SANDBOX,
    PREF_AUDIOIPC_POOL_SIZE,
    PREF_AUDIOIPC_STACK_SIZE,
    PREF_AUDIOIPC_SHM_AREA_SIZE,
    nullptr,
};
static const char* gCallbackPrefs[] = {
    PREF_CUBEB_FORCE_SAMPLE_RATE,
+1 −1
Original line number Diff line number Diff line
{"files":{"Cargo.toml":"4020e8c4119327dac49b47391c902eb69bb927c9e7d05f5882ad9e84cff4ec5e","cbindgen.toml":"bd89c5a9f52395b1c703ff04d1c0019dc3c92b691d571ae503c4b85753a44a39","src/context.rs":"7388ee487bc25bbdf5cc6475dfa78674bdd9f49c92968c1b0a8047cdd023476c","src/lib.rs":"7755001c8caf6899ca5ed00a517d7bf1b6425fe17157a97037dae619af567fc9","src/send_recv.rs":"450bdb1d8a346634c0237f2081b424d11e2c19ad81670009303f8a03b3bfb196","src/stream.rs":"a7b32be48f67ef6b7fbcf61b25e02cab1e961ef3146c3ace2f16ced9dab2953e"},"package":null}
 No newline at end of file
{"files":{"Cargo.toml":"4020e8c4119327dac49b47391c902eb69bb927c9e7d05f5882ad9e84cff4ec5e","cbindgen.toml":"bd89c5a9f52395b1c703ff04d1c0019dc3c92b691d571ae503c4b85753a44a39","src/context.rs":"89e2929aa2ba4bddcec6dd4a4511f528c681b7717adbaa7b7df4378c8e3c4d1c","src/lib.rs":"7755001c8caf6899ca5ed00a517d7bf1b6425fe17157a97037dae619af567fc9","src/send_recv.rs":"450bdb1d8a346634c0237f2081b424d11e2c19ad81670009303f8a03b3bfb196","src/stream.rs":"1fb24d5cf51305408068eebee0e367b4f9786f27665c7dba47128defdfadbf5c"},"package":null}
 No newline at end of file
+11 −14
Original line number Diff line number Diff line
@@ -11,8 +11,7 @@ use audio_thread_priority::get_current_thread_info;
#[cfg(not(target_os = "linux"))]
use audio_thread_priority::promote_current_thread_to_real_time;
use audioipc::codec::LengthDelimitedCodec;
use audioipc::frame::{framed, Framed};
use audioipc::platformhandle_passing::{framed_with_platformhandles, FramedWithPlatformHandles};
use audioipc::framing::{framed, Framed};
use audioipc::{core, rpc};
use audioipc::{
    messages, messages::DeviceCollectionReq, messages::DeviceCollectionResp, ClientMessage,
@@ -38,10 +37,8 @@ struct CubebClient;
impl rpc::Client for CubebClient {
    type Request = ServerMessage;
    type Response = ClientMessage;
    type Transport = FramedWithPlatformHandles<
        audioipc::AsyncMessageStream,
        LengthDelimitedCodec<Self::Request, Self::Response>,
    >;
    type Transport =
        Framed<audioipc::AsyncMessageStream, LengthDelimitedCodec<Self::Request, Self::Response>>;
}

pub const CLIENT_OPS: Ops = capi_new!(ClientContext, ClientStream);
@@ -190,7 +187,7 @@ impl ContextOps for ClientContext {
            stream: audioipc::AsyncMessageStream,
            tx_rpc: &mpsc::Sender<rpc::ClientProxy<ServerMessage, ClientMessage>>,
        ) {
            let transport = framed_with_platformhandles(stream, Default::default());
            let transport = framed(stream, Default::default());
            let rpc = rpc::bind_client::<CubebClient>(transport);
            // If send fails then the rx end has closed
            // which is unlikely here.
@@ -206,7 +203,7 @@ impl ContextOps for ClientContext {
        let thread_destroy_callback = params.thread_destroy_callback;

        let server_stream =
            unsafe { audioipc::MessageStream::from_raw_fd(params.server_connection) };
            unsafe { audioipc::MessageStream::from_raw_handle(params.server_connection) };

        let core = core::spawn_thread(
            "AudioIPC Client RPC",
@@ -368,15 +365,15 @@ impl ContextOps for ClientContext {
        assert_not_in_callback();

        if !self.device_collection_rpc {
            let fds = send_recv!(self.rpc(),
            let mut fd = send_recv!(self.rpc(),
                                 ContextSetupDeviceCollectionCallback =>
                                 ContextSetupDeviceCollectionCallback())?;

            // TODO: The lowest comms layer expects exactly 3 PlatformHandles, but we only
            // need one here.  The server sent two dummy valid handles, ignore those (closed on drop)
            // and use the one we need.
            let stream =
                unsafe { audioipc::MessageStream::from_raw_fd(fds.platform_handles[0].into_raw()) };
            let stream = unsafe {
                audioipc::MessageStream::from_raw_handle(
                    fd.platform_handle.take_handle().into_raw(),
                )
            };

            let server = DeviceCollectionServer {
                input_device_callback: self.input_device_callback.clone(),
Loading