зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1447097 - Vendor in cubeb-rs 0.5.2. r=kamidphish
MozReview-Commit-ID: DK7KB9fzAF5 --HG-- extra : rebase_source : 894ce8dd498ee5f519041104589efb35eecb33f1
This commit is contained in:
Родитель
f14ee0f38e
Коммит
5ad7da2a98
|
@ -54,7 +54,7 @@ version = "0.2.3"
|
|||
dependencies = [
|
||||
"bincode 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bytes 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cubeb 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cubeb 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"iovec 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -90,7 +90,7 @@ version = "0.2.2"
|
|||
dependencies = [
|
||||
"audioipc 0.2.3",
|
||||
"bytes 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cubeb 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cubeb 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazycell 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -407,10 +407,10 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "cubeb"
|
||||
version = "0.5.0"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cubeb-core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cubeb-core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -418,16 +418,16 @@ name = "cubeb-backend"
|
|||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cubeb-core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cubeb-core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cubeb-core"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cubeb-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cubeb-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -442,7 +442,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "cubeb-sys"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cmake 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -740,7 +740,7 @@ dependencies = [
|
|||
"audioipc-server 0.2.2",
|
||||
"cose-c 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cubeb-pulse 0.2.0",
|
||||
"cubeb-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cubeb-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"encoding_c 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"encoding_glue 0.1.0",
|
||||
"geckoservo 0.0.1",
|
||||
|
@ -2264,10 +2264,10 @@ dependencies = [
|
|||
"checksum cssparser-macros 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "079adec4af52bb5275eadd004292028c79eb3c5f5b4ee8086a36d4197032f6df"
|
||||
"checksum cstr 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b6557bdb1dc9647eae1cf7f5601b14cd45fc3c7ccf2df618387416fe542da6ea"
|
||||
"checksum cstr-macros 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f9f316203d1ea36f4f18316822806f6999aa3dc5ed1adf51e35b77e3b3933d78"
|
||||
"checksum cubeb 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7923bed2d5a1a64ba0c3e8b6badc360508ba488d1f2f59f16a688802e755bb85"
|
||||
"checksum cubeb 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8a3502aafa1bf95c524f65d2ba46d8741700c6a8a9543ea52c6da3d8b69a2896"
|
||||
"checksum cubeb-backend 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fdcac95519416d9ec814db2dc40e6293e7da25b906023d93f48b87f0587ab138"
|
||||
"checksum cubeb-core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "169d9a36f5daa60f9c4597905132aef056cf62693addd4a3421492853ccad565"
|
||||
"checksum cubeb-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e405ad4dff2c1a7cbfa6998e5925e8ceafe900feeacfcad35a3e3790bea0f2aa"
|
||||
"checksum cubeb-core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "37f7b20f757a4e4b6aa28863236551bff77682dc6db192eba15af615492b5445"
|
||||
"checksum cubeb-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "653b9e245d35dbe2a2da7c4586275cee75ff656ddeb02d4a73b4afdfa6d67502"
|
||||
"checksum darling 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d3effd06d4057f275cb7858889f4952920bab78dd8ff0f6e7dfe0c8d2e67ed89"
|
||||
"checksum darling_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "167dd3e235c2f1da16a635c282630452cdf49191eb05711de1bcd1d3d5068c00"
|
||||
"checksum darling_macro 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c53edaba455f6073a10c27c72440860eb3f60444f8c8660a391032eeae744d82"
|
||||
|
|
|
@ -8,7 +8,7 @@ authors = [
|
|||
description = "Remote Cubeb IPC"
|
||||
|
||||
[dependencies]
|
||||
cubeb = "0.5"
|
||||
cubeb = "0.5.2"
|
||||
bincode = "1.0"
|
||||
bytes = "0.4"
|
||||
futures = "0.1.18"
|
||||
|
|
|
@ -9,7 +9,7 @@ description = "Remote cubeb server"
|
|||
|
||||
[dependencies]
|
||||
audioipc = { path = "../audioipc" }
|
||||
cubeb = "0.5"
|
||||
cubeb = "0.5.2"
|
||||
bytes = "0.4"
|
||||
lazycell = "^0.4"
|
||||
libc = "0.2"
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"files":{"Cargo.toml":"5cc2013bd01c4f844a0056af1b3a484f39c77b8aeac03c3f15e4598caf9625a9","LICENSE":"8c044baa5d883274736eeece0b955249076c2697b826e576fce59496235b2cf5","src/builders.rs":"ca97e3a3d1f3fc451c17851c8538964ec67f3964dfe29e902d904ee7445becca","src/channel.rs":"c8d5a76ef3ecdd96cd4de516e3d4d139bbb83c4690d1c3f5fd07fffc47be51f1","src/context.rs":"09625b75070ec88d566a907ab2e574e2d85df4c6df295f798b3372df2cdc8f7a","src/device.rs":"490d2e94ecae1e149476c2e8d9aa03c4163987c3efccc962b2d3123e4c09dedf","src/device_collection.rs":"f6d0c1628cc34b524f86b84a1e1c79971c3f64ebc4ac64eeb10a1330bbe8c238","src/error.rs":"855ff3d3597753f832ecea00e403c71129afd80db3d39456cf3e23cb9aeb91e7","src/ffi_types.rs":"d815d7a80895b5e86907e708dc0219fca4ac4668cde114afee434e7d702a145d","src/format.rs":"5513c537a72af1c222ee7c30b26d4de9d368a69772688b95d88b1a99f6892d5c","src/lib.rs":"6010a5e20b836b8e5c9fba382fde819e6f3c18c0ec2016e6e7e118eabedbcd51","src/log.rs":"c46bae3472043fd076df3229c3421d948a87fae8495c1524b41ab2d8608f612a","src/stream.rs":"cd8dccefe88c584264af908169f566b1f65fdab79792a9abf7e38342ca9b8e62","src/try_call.rs":"231bfa3f3448f7531427bb228beb2bcd4fd711f0b13d2d8f412af013470f40c7","src/util.rs":"308cfbaacd615ff600e74415c52daeef007fff34a4a0648a73c0042f6067f84f"},"package":"169d9a36f5daa60f9c4597905132aef056cf62693addd4a3421492853ccad565"}
|
||||
{"files":{"Cargo.toml":"c379f4deb07a056d5d1679f4641c3a29dec6c74a82b2304cbf5ec65488e5a9bc","LICENSE":"8c044baa5d883274736eeece0b955249076c2697b826e576fce59496235b2cf5","src/builders.rs":"ca97e3a3d1f3fc451c17851c8538964ec67f3964dfe29e902d904ee7445becca","src/channel.rs":"c8d5a76ef3ecdd96cd4de516e3d4d139bbb83c4690d1c3f5fd07fffc47be51f1","src/context.rs":"09625b75070ec88d566a907ab2e574e2d85df4c6df295f798b3372df2cdc8f7a","src/device.rs":"490d2e94ecae1e149476c2e8d9aa03c4163987c3efccc962b2d3123e4c09dedf","src/device_collection.rs":"f6d0c1628cc34b524f86b84a1e1c79971c3f64ebc4ac64eeb10a1330bbe8c238","src/error.rs":"855ff3d3597753f832ecea00e403c71129afd80db3d39456cf3e23cb9aeb91e7","src/ffi_types.rs":"d815d7a80895b5e86907e708dc0219fca4ac4668cde114afee434e7d702a145d","src/format.rs":"5513c537a72af1c222ee7c30b26d4de9d368a69772688b95d88b1a99f6892d5c","src/lib.rs":"6010a5e20b836b8e5c9fba382fde819e6f3c18c0ec2016e6e7e118eabedbcd51","src/log.rs":"c46bae3472043fd076df3229c3421d948a87fae8495c1524b41ab2d8608f612a","src/stream.rs":"775b9af0e3d8c1a7a38f96b8365a632a9d52a43541d96ede9a4ed9688c2dc914","src/try_call.rs":"231bfa3f3448f7531427bb228beb2bcd4fd711f0b13d2d8f412af013470f40c7","src/util.rs":"308cfbaacd615ff600e74415c52daeef007fff34a4a0648a73c0042f6067f84f"},"package":"37f7b20f757a4e4b6aa28863236551bff77682dc6db192eba15af615492b5445"}
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
[package]
|
||||
name = "cubeb-core"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
authors = ["Dan Glastonbury <dglastonbury@mozilla.com>"]
|
||||
description = "Common types and definitions for cubeb rust and C bindings. Not intended for direct use.\n"
|
||||
homepage = "https://github.com/djg/cubeb-rs"
|
||||
|
|
|
@ -93,9 +93,14 @@ impl StreamParamsRef {
|
|||
}
|
||||
}
|
||||
|
||||
unsafe fn wrapped_cubeb_stream_destroy(stream: *mut ffi::cubeb_stream) {
|
||||
ffi::cubeb_stream_stop(stream);
|
||||
ffi::cubeb_stream_destroy(stream);
|
||||
}
|
||||
|
||||
ffi_type_heap! {
|
||||
type CType = ffi::cubeb_stream;
|
||||
fn drop = ffi::cubeb_stream_destroy;
|
||||
fn drop = wrapped_cubeb_stream_destroy;
|
||||
pub struct Stream;
|
||||
pub struct StreamRef;
|
||||
}
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -12,7 +12,7 @@
|
|||
|
||||
[package]
|
||||
name = "cubeb-sys"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
authors = ["Dan Glastonbury <dglastonbury@mozilla.com>"]
|
||||
build = "build.rs"
|
||||
links = "cubeb"
|
||||
|
|
|
@ -64,6 +64,18 @@
|
|||
#define C_45DB 0.594603558
|
||||
#define C_60DB 0.5
|
||||
|
||||
static cubeb_channel_layout
|
||||
cubeb_channel_layout_check(cubeb_channel_layout l, uint32_t c)
|
||||
{
|
||||
if (l == CUBEB_LAYOUT_UNDEFINED) {
|
||||
switch (c) {
|
||||
case 1: return CUBEB_LAYOUT_MONO;
|
||||
case 2: return CUBEB_LAYOUT_STEREO;
|
||||
}
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
unsigned int cubeb_channel_layout_nb_channels(cubeb_channel_layout x)
|
||||
{
|
||||
#if __GNUC__ || __clang__
|
||||
|
@ -85,18 +97,8 @@ struct MixerContext {
|
|||
uint32_t out_channels,
|
||||
cubeb_channel_layout out)
|
||||
: _format(f)
|
||||
, _in_ch_layout(in == CUBEB_LAYOUT_UNDEFINED
|
||||
? (in_channels == 1
|
||||
? CUBEB_LAYOUT_MONO
|
||||
: (in_channels == 2 ? CUBEB_LAYOUT_STEREO
|
||||
: CUBEB_LAYOUT_UNDEFINED))
|
||||
: in)
|
||||
, _out_ch_layout(
|
||||
(out == CUBEB_LAYOUT_UNDEFINED
|
||||
? (out_channels == 1 ? CUBEB_LAYOUT_MONO
|
||||
: (out_channels == 2 ? CUBEB_LAYOUT_STEREO
|
||||
: CUBEB_LAYOUT_UNDEFINED))
|
||||
: out))
|
||||
, _in_ch_layout(cubeb_channel_layout_check(in, in_channels))
|
||||
, _out_ch_layout(cubeb_channel_layout_check(out, out_channels))
|
||||
, _in_ch_count(in_channels)
|
||||
, _out_ch_count(out_channels)
|
||||
{
|
||||
|
@ -544,7 +546,7 @@ struct cubeb_mixer
|
|||
}
|
||||
|
||||
int mix(size_t frames,
|
||||
void * input_buffer,
|
||||
const void * input_buffer,
|
||||
size_t input_buffer_size,
|
||||
void * output_buffer,
|
||||
size_t output_buffer_size) const
|
||||
|
@ -575,7 +577,7 @@ struct cubeb_mixer
|
|||
} else {
|
||||
assert(_context._format == CUBEB_SAMPLE_S16NE);
|
||||
copy_and_trunc(frames,
|
||||
static_cast<int16_t*>(input_buffer),
|
||||
static_cast<const int16_t*>(input_buffer),
|
||||
reinterpret_cast<int16_t*>(output_buffer));
|
||||
}
|
||||
return 0;
|
||||
|
@ -651,9 +653,9 @@ void cubeb_mixer_destroy(cubeb_mixer * mixer)
|
|||
|
||||
int cubeb_mixer_mix(cubeb_mixer * mixer,
|
||||
size_t frames,
|
||||
void* input_buffer,
|
||||
const void * input_buffer,
|
||||
size_t input_buffer_size,
|
||||
void* output_buffer,
|
||||
void * output_buffer,
|
||||
size_t output_buffer_size)
|
||||
{
|
||||
return mixer->mix(
|
||||
|
|
|
@ -23,7 +23,7 @@ cubeb_mixer * cubeb_mixer_create(cubeb_sample_format format,
|
|||
void cubeb_mixer_destroy(cubeb_mixer * mixer);
|
||||
int cubeb_mixer_mix(cubeb_mixer * mixer,
|
||||
size_t frames,
|
||||
void * input_buffer,
|
||||
const void * input_buffer,
|
||||
size_t input_buffer_size,
|
||||
void * output_buffer,
|
||||
size_t output_buffer_size);
|
||||
|
|
|
@ -579,6 +579,8 @@ static void pulse_destroy(cubeb * ctx);
|
|||
static int
|
||||
pulse_context_init(cubeb * ctx)
|
||||
{
|
||||
int r;
|
||||
|
||||
if (ctx->context) {
|
||||
assert(ctx->error == 1);
|
||||
pulse_context_destroy(ctx);
|
||||
|
@ -592,9 +594,9 @@ pulse_context_init(cubeb * ctx)
|
|||
WRAP(pa_context_set_state_callback)(ctx->context, context_state_callback, ctx);
|
||||
|
||||
WRAP(pa_threaded_mainloop_lock)(ctx->mainloop);
|
||||
WRAP(pa_context_connect)(ctx->context, NULL, 0, NULL);
|
||||
r = WRAP(pa_context_connect)(ctx->context, NULL, 0, NULL);
|
||||
|
||||
if (wait_until_context_ready(ctx) != 0) {
|
||||
if (r < 0 || wait_until_context_ready(ctx) != 0) {
|
||||
WRAP(pa_threaded_mainloop_unlock)(ctx->mainloop);
|
||||
pulse_context_destroy(ctx);
|
||||
ctx->context = NULL;
|
||||
|
|
|
@ -21,7 +21,7 @@ extern "C" {
|
|||
pub fn cubeb_mixer_mix(
|
||||
mixer: *mut cubeb_mixer,
|
||||
frames: usize,
|
||||
input_buffer: *mut c_void,
|
||||
input_buffer: *const c_void,
|
||||
input_buffer_length: usize,
|
||||
output_buffer: *mut c_void,
|
||||
output_buffer_length: usize,
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"files":{"Cargo.toml":"a2c6655c60b3df90ea552b24c6316cbfdf7b2b915e960ce7c03abdcdb73c92ff","LICENSE":"8c044baa5d883274736eeece0b955249076c2697b826e576fce59496235b2cf5","README.md":"408c573ec240927cf5b9c036098e94e374ec41f71991415422586f450586b214","examples/common/mod.rs":"a5e1b79fc2b4addff1e442879ba3dbcb1cf5973e76b9a62d97dd0042597480db","examples/devices.rs":"89e13542853995d1ae4a49d6829156efb29dd25c6caffdf22496c28c8263ffeb","examples/tone.rs":"8f5f9851b6d99f6f16c597fcb9312e3ef81769cbfb89341d2ea2522ca2e2214e","src/context.rs":"03511fa960a411728163e700edc2fd6cfbfcf09766ffe62ee82a2cbd08fdf243","src/frame.rs":"ed1e8f4576022d0c23106bb115125e5a2967b0375a10d0c54bbe99f04a70cc3f","src/lib.rs":"98e9280890551ac9305f2f808e315b6aa6bcd5781b8e96a078787ded0ef91e2a","src/log.rs":"af1d787754706e34d6b8f4ac88aa89078ae9a16970b168ad8dc17cc4180688c2","src/sample.rs":"e23be3b691052001916f920ce9c1a0051bd097e39c9d34cbcb80ab8120265f45","src/stream.rs":"3e2c7ec590bed0eb740057a89a4dc254fe962f402e6ed316308152d96bd1288a"},"package":"7923bed2d5a1a64ba0c3e8b6badc360508ba488d1f2f59f16a688802e755bb85"}
|
||||
{"files":{"Cargo.toml":"7c56fd36743a0c83f3977d8b24e67abff5ecd34e4e6043742ff331746165c60a","LICENSE":"8c044baa5d883274736eeece0b955249076c2697b826e576fce59496235b2cf5","README.md":"408c573ec240927cf5b9c036098e94e374ec41f71991415422586f450586b214","examples/common/mod.rs":"a5e1b79fc2b4addff1e442879ba3dbcb1cf5973e76b9a62d97dd0042597480db","examples/devices.rs":"89e13542853995d1ae4a49d6829156efb29dd25c6caffdf22496c28c8263ffeb","examples/tone.rs":"8f5f9851b6d99f6f16c597fcb9312e3ef81769cbfb89341d2ea2522ca2e2214e","src/context.rs":"03511fa960a411728163e700edc2fd6cfbfcf09766ffe62ee82a2cbd08fdf243","src/frame.rs":"ed1e8f4576022d0c23106bb115125e5a2967b0375a10d0c54bbe99f04a70cc3f","src/lib.rs":"98e9280890551ac9305f2f808e315b6aa6bcd5781b8e96a078787ded0ef91e2a","src/log.rs":"704faeb31934dad6bc6d02e01caa85118754209bd559d30d03fcfa5cb8c1603c","src/sample.rs":"e23be3b691052001916f920ce9c1a0051bd097e39c9d34cbcb80ab8120265f45","src/stream.rs":"3ee0432f655cd42959cd5d8e75cb4fe2322e1f88fa5d9cc83e615ae229cdeb8a"},"package":"8a3502aafa1bf95c524f65d2ba46d8741700c6a8a9543ea52c6da3d8b69a2896"}
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
[package]
|
||||
name = "cubeb"
|
||||
version = "0.5.0"
|
||||
version = "0.5.2"
|
||||
authors = ["Dan Glastonbury <dglastonbury@mozilla.com>"]
|
||||
description = "Bindings to libcubeb for interacting with system audio from rust.\n"
|
||||
homepage = "https://github.com/djg/cubeb-rs"
|
||||
|
@ -22,7 +22,7 @@ categories = ["api-bindings"]
|
|||
license = "ISC"
|
||||
repository = "https://github.com/djg/cubeb-rs"
|
||||
[dependencies.cubeb-core]
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
|
||||
[features]
|
||||
gecko-in-tree = ["cubeb-core/gecko-in-tree"]
|
||||
|
|
|
@ -9,36 +9,36 @@ macro_rules! cubeb_log_internal {
|
|||
#[allow(unused_unsafe)]
|
||||
unsafe {
|
||||
if $level <= $crate::ffi::g_cubeb_log_level.into() {
|
||||
if let Some(log_callback) = $crate::ffi::g_cubeb_log_callback {
|
||||
let cstr = ::std::ffi::CString::new(concat!("%s:%d: ", $msg, "\n")).unwrap();
|
||||
log_callback(cstr.as_ptr(), file!(), line!());
|
||||
}
|
||||
cubeb_log_internal!(__INTERNAL__ $msg);
|
||||
}
|
||||
}
|
||||
};
|
||||
($level: expr, $fmt: expr, $($arg:tt)+) => {
|
||||
($level: expr, $fmt: expr, $($arg: expr),+) => {
|
||||
#[allow(unused_unsafe)]
|
||||
unsafe {
|
||||
if $level <= $crate::ffi::g_cubeb_log_level.into() {
|
||||
if let Some(log_callback) = $crate::ffi::g_cubeb_log_callback {
|
||||
let cstr = ::std::ffi::CString::new(concat!("%s:%d: ", $fmt, "\n")).unwrap();
|
||||
log_callback(cstr.as_ptr(), file!(), line!(), $($arg)+);
|
||||
}
|
||||
cubeb_log_internal!(__INTERNAL__ format!($fmt, $($arg),*));
|
||||
}
|
||||
}
|
||||
};
|
||||
(__INTERNAL__ $msg: expr) => {
|
||||
if let Some(log_callback) = $crate::ffi::g_cubeb_log_callback {
|
||||
let cstr = ::std::ffi::CString::new(format!("{}:{}: {}\n", file!(), line!(), $msg)).unwrap();
|
||||
log_callback(cstr.as_ptr());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! cubeb_logv {
|
||||
($msg: expr) => (cubeb_log_internal!($crate::LogLevel::Verbose, $msg));
|
||||
($fmt: expr, $($arg: tt)+) => (cubeb_log_internal!($crate::LogLevel::Verbose, $fmt, $($arg)*));
|
||||
($fmt: expr, $($arg: expr),+) => (cubeb_log_internal!($crate::LogLevel::Verbose, $fmt, $($arg),*));
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! cubeb_log {
|
||||
($msg: expr) => (cubeb_log_internal!($crate::LogLevel::Normal, $msg));
|
||||
($fmt: expr, $($arg: tt)+) => (cubeb_log_internal!($crate::LogLevel::Normal, $fmt, $($arg)*));
|
||||
($fmt: expr, $($arg: expr),+) => (cubeb_log_internal!($crate::LogLevel::Normal, $fmt, $($arg),*));
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -46,12 +46,14 @@ mod tests {
|
|||
#[test]
|
||||
fn test_normal_logging() {
|
||||
cubeb_log!("This is log at normal level");
|
||||
cubeb_log!("Formatted log %d", 1);
|
||||
cubeb_log!("{} Formatted log", 1);
|
||||
cubeb_log!("{} Formatted {} log {}", 1, 2, 3);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_verbose_logging() {
|
||||
cubeb_logv!("This is a log at verbose level");
|
||||
cubeb_logv!("Formatted log %d", 1);
|
||||
cubeb_logv!("{} Formatted log", 1);
|
||||
cubeb_logv!("{} Formatted {} log {}", 1, 2, 3);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ use ffi;
|
|||
use std::{ops, panic, ptr};
|
||||
use std::ffi::CString;
|
||||
use std::marker::PhantomData;
|
||||
use std::mem::ManuallyDrop;
|
||||
use std::os::raw::{c_long, c_void};
|
||||
use std::slice::{from_raw_parts, from_raw_parts_mut};
|
||||
|
||||
|
@ -77,17 +78,20 @@ pub struct StreamCallbacks<F> {
|
|||
pub(crate) device_changed: Option<Box<DeviceChangedCallback>>,
|
||||
}
|
||||
|
||||
pub struct Stream<F>(cubeb_core::Stream, PhantomData<*const F>);
|
||||
pub struct Stream<F>(ManuallyDrop<cubeb_core::Stream>,
|
||||
PhantomData<*const F>);
|
||||
|
||||
impl<F> Stream<F> {
|
||||
fn new(s: cubeb_core::Stream) -> Stream<F> {
|
||||
Stream(s, PhantomData)
|
||||
Stream(ManuallyDrop::new(s), PhantomData)
|
||||
}
|
||||
}
|
||||
|
||||
impl<F> Drop for Stream<F> {
|
||||
fn drop(&mut self) {
|
||||
let _ = unsafe { Box::from_raw(self.user_ptr() as *mut StreamCallbacks<F>) };
|
||||
let user_ptr = self.user_ptr();
|
||||
unsafe { ManuallyDrop::drop(&mut self.0) };
|
||||
let _ = unsafe { Box::from_raw(user_ptr as *mut StreamCallbacks<F>) };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче