forked from mozilla/cubeb-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Organise all the FFI stuff into cubeb-sys crate.
- Loading branch information
Showing
22 changed files
with
658 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[submodule "libcubeb-sys/libcubeb"] | ||
path = cubeb-api/libcubeb-sys/libcubeb | ||
[submodule "cubeb-sys/libcubeb"] | ||
path = cubeb-sys/libcubeb | ||
url = https://github.com/kinetiknz/cubeb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,6 @@ | |
members = [ | ||
"cubeb-core", | ||
"cubeb-api", | ||
"cubeb-backend" | ||
"cubeb-backend", | ||
"cubeb-sys" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Submodule libcubeb
deleted from
4c18a8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright © 2017-2018 Mozilla Foundation | ||
// | ||
// This program is made available under an ISC-style license. See the | ||
// accompanying file LICENSE for details. | ||
|
||
use context::cubeb; | ||
use std::os::raw::{c_long, c_void}; | ||
use stream::{cubeb_state, cubeb_stream}; | ||
|
||
pub type cubeb_data_callback = Option< | ||
unsafe extern fn(*mut cubeb_stream, *mut c_void, *const c_void, *mut c_void, c_long) | ||
-> c_long, | ||
>; | ||
pub type cubeb_state_callback = Option< | ||
unsafe extern fn(*mut cubeb_stream, *mut c_void, cubeb_state), | ||
>; | ||
pub type cubeb_device_changed_callback = Option<unsafe extern fn(*mut c_void)>; | ||
pub type cubeb_device_collection_changed_callback = Option< | ||
unsafe extern fn(*mut cubeb, *mut c_void), | ||
>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// Copyright © 2017-2018 Mozilla Foundation | ||
// | ||
// This program is made available under an ISC-style license. See the | ||
// accompanying file LICENSE for details. | ||
|
||
use std::{fmt, mem}; | ||
use std::os::raw::{c_int, c_uint}; | ||
|
||
cubeb_enum! { | ||
pub enum cubeb_channel : c_int { | ||
CHANNEL_INVALID = -1, | ||
CHANNEL_MONO = 0, | ||
CHANNEL_LEFT, | ||
CHANNEL_RIGHT, | ||
CHANNEL_CENTER, | ||
CHANNEL_LS, | ||
CHANNEL_RS, | ||
CHANNEL_RLS, | ||
CHANNEL_RCENTER, | ||
CHANNEL_RRS, | ||
CHANNEL_LFE, | ||
CHANNEL_UNMAPPED, | ||
CHANNEL_MAX = 256, | ||
} | ||
} | ||
|
||
cubeb_enum! { | ||
pub enum cubeb_channel_layout { | ||
CUBEB_LAYOUT_UNDEFINED, | ||
|
||
CUBEB_LAYOUT_DUAL_MONO, | ||
CUBEB_LAYOUT_DUAL_MONO_LFE, | ||
CUBEB_LAYOUT_MONO, | ||
CUBEB_LAYOUT_MONO_LFE, | ||
CUBEB_LAYOUT_STEREO, | ||
CUBEB_LAYOUT_STEREO_LFE, | ||
CUBEB_LAYOUT_3F, | ||
CUBEB_LAYOUT_3F_LFE, | ||
CUBEB_LAYOUT_2F1, | ||
CUBEB_LAYOUT_2F1_LFE, | ||
CUBEB_LAYOUT_3F1, | ||
CUBEB_LAYOUT_3F1_LFE, | ||
CUBEB_LAYOUT_2F2, | ||
CUBEB_LAYOUT_2F2_LFE, | ||
CUBEB_LAYOUT_3F2, | ||
CUBEB_LAYOUT_3F2_LFE, | ||
CUBEB_LAYOUT_3F3R_LFE, | ||
CUBEB_LAYOUT_3F4_LFE, | ||
CUBEB_LAYOUT_MAX, | ||
} | ||
} | ||
|
||
#[repr(C)] | ||
#[derive(Clone, Copy)] | ||
pub struct cubeb_channel_map { | ||
pub channels: c_uint, | ||
pub map: [cubeb_channel; CHANNEL_MAX as usize], | ||
} | ||
|
||
impl Default for cubeb_channel_map { | ||
fn default() -> Self { unsafe { mem::zeroed() } } | ||
} | ||
|
||
// Explicit Debug impl to work around bug in ctest | ||
impl fmt::Debug for cubeb_channel_map { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
f.debug_struct("cubeb_channel_map") | ||
.field("channels", &self.channels) | ||
.field("map", &self.map.iter().take(self.channels as usize)) | ||
.finish() | ||
} | ||
} | ||
|
||
extern { | ||
pub fn cubeb_channel_map_to_layout( | ||
channel_map: *const cubeb_channel_map, | ||
) -> cubeb_channel_layout; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright © 2017-2018 Mozilla Foundation | ||
// | ||
// This program is made available under an ISC-style license. See the | ||
// accompanying file LICENSE for details. | ||
|
||
use callbacks::{cubeb_data_callback, cubeb_state_callback}; | ||
use channel::cubeb_channel_layout; | ||
use device::cubeb_devid; | ||
use std::os::raw::{c_char, c_int, c_uint, c_void}; | ||
use stream::{cubeb_stream, cubeb_stream_params}; | ||
|
||
pub enum cubeb {} | ||
|
||
extern { | ||
pub fn cubeb_init( | ||
context: *mut *mut cubeb, | ||
context_name: *const c_char, | ||
backend_name: *const c_char, | ||
) -> c_int; | ||
pub fn cubeb_get_backend_id(context: *mut cubeb) -> *const c_char; | ||
pub fn cubeb_get_max_channel_count( | ||
context: *mut cubeb, | ||
max_channels: *mut c_uint, | ||
) -> c_int; | ||
pub fn cubeb_get_min_latency( | ||
context: *mut cubeb, | ||
params: *mut cubeb_stream_params, | ||
latency_frames: *mut c_uint, | ||
) -> c_int; | ||
pub fn cubeb_get_preferred_sample_rate(context: *mut cubeb, rate: *mut c_uint) -> c_int; | ||
pub fn cubeb_get_preferred_channel_layout( | ||
context: *mut cubeb, | ||
layout: *mut cubeb_channel_layout, | ||
) -> c_int; | ||
pub fn cubeb_destroy(context: *mut cubeb); | ||
pub fn cubeb_stream_init( | ||
context: *mut cubeb, | ||
stream: *mut *mut cubeb_stream, | ||
stream_name: *const c_char, | ||
input_device: cubeb_devid, | ||
input_stream_params: *mut cubeb_stream_params, | ||
output_device: cubeb_devid, | ||
output_stream_params: *mut cubeb_stream_params, | ||
latency_frames: c_uint, | ||
data_callback: cubeb_data_callback, | ||
state_callback: cubeb_state_callback, | ||
user_ptr: *mut c_void, | ||
) -> c_int; | ||
} |
Oops, something went wrong.