Skip to content

Commit 7b23c39

Browse files
committed
improved library usability
1 parent d7084b6 commit 7b23c39

File tree

7 files changed

+20
-9
lines changed

7 files changed

+20
-9
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "silence-core"
3-
version = "0.1.8"
3+
version = "0.1.9"
44
edition = "2021"
55
description = "Core audio I/O abstractions for the silence crate."
66
license = "Apache-2.0"

src/avif/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
//! Provides AV1 encoding for images.
22
//! [AV1](https://en.wikipedia.org/wiki/AV1) (AOMedia Video 1) is a high efficiency video codec. It was originally made to transmit video calls.
33
pub mod encoding;
4+
5+
//Re-export the ravif crate.
6+
pub use ravif;

src/cam/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ use opencv::{
88

99
//Reinport important functions
1010
pub use opencv::imgproc::{cvt_color_def, COLOR_BGR2RGB};
11+
//Re-export the opencv crate.
12+
pub use opencv;
1113

1214
/// Webcam struct definition.
1315
/// The struct wraps the ```VideoCapture``` type, and has custom functions for it.

src/io/mod.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Traits, functions and type definitions for functioning audio I/O.
22
//! The I/O feature provides types and functions for recording and playbacking audio aswell as handling the data.
33
4-
use cpal::{
4+
use ::cpal::{
55
traits::{DeviceTrait, HostTrait},
66
DefaultStreamConfigError, Device, Host, SupportedStreamConfig,
77
};
@@ -15,16 +15,19 @@ pub type OutputDevice = Device;
1515
/// Wrapper type for differentiating [`OutputDevice`] from [`InputDevice`] granted the user passes them in right when creating an [`AudioDevice`].
1616
pub type InputDevice = Device;
1717

18+
//Re-export the cpal crate.
19+
pub use cpal;
20+
1821
/// The host's audio input and output devices.
1922
#[allow(missing_debug_implementations)]
20-
pub struct AudioDevice {
23+
pub struct HostDevice {
2124
/// The output device of the host.
2225
pub output: Option<OutputDevice>,
2326
/// The input device of the host.
2427
pub input: Option<InputDevice>,
2528
}
2629

27-
impl AudioDevice {
30+
impl HostDevice {
2831
/// Creates a new [`AudioDevice`] instance.
2932
pub fn new(output: Option<Device>, input: Option<Device>) -> Self {
3033
Self { output, input }
@@ -52,8 +55,8 @@ impl AudioDevice {
5255
pub use cpal::{available_hosts, default_host, host_from_id};
5356

5457
/// Get the default audio devices of the host. If one doesn't exist it will get initialized with `None`.
55-
pub fn get_audio_device(device: Host) -> AudioDevice {
56-
AudioDevice {
58+
pub fn get_audio_device(device: Host) -> HostDevice {
59+
HostDevice {
5760
input: device.default_input_device(),
5861
output: device.default_output_device(),
5962
}

src/opus/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ use encode::EncoderType;
44
pub mod decode;
55
pub mod encode;
66

7+
/// Re-export the opus crate.
8+
pub use opus;
9+
710
/// The encoded sound packet.
811
/// Contains useful information about the encoded packet.
912
#[derive(Debug)]

src/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ mod tests {
2222
};
2323

2424
#[test]
25-
fn encode() {
25+
fn image_encode() {
2626
let mut webcam = cam::Webcam::new_def(CAP_ANY).unwrap();
2727
let (bytes, size) = webcam.get_frame().unwrap();
2828

@@ -125,7 +125,7 @@ mod tests {
125125
)
126126
.unwrap();
127127

128-
let sound_packets = encode_samples_opus(encoder, &Into::<Vec<f32>>::into(sample), 20, channels).unwrap();
128+
let sound_packets: Vec<crate::opus::SoundPacket> = encode_samples_opus(encoder, &Into::<Vec<f32>>::into(sample), 20, channels).unwrap();
129129

130130
let decoder = create_opus_decoder(48000).unwrap();
131131

0 commit comments

Comments
 (0)