Skip to content

Commit 7fb2aea

Browse files
authored
Allow passing PCM data as slices instead of Vec (#18)
* Allow passing PCM data as slices instead of Vec * version bump
1 parent 81bc141 commit 7fb2aea

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[package]
22
name = "projectm"
3-
version = "2.0.2"
3+
version = "3.0.0"
44
edition = "2021"
55
rust-version = "1.65"
66
authors = ["AnomieVision <[email protected]>", "Mischa Spiegelmock <[email protected]>"]
77
description = "Bindings for ProjectM"
88
license = " LGPL-3.0-or-later"
9-
repository = "https://github.com/projectM-visualizer/projectm-rs" #https://github.com/anomievision/projectm-rs
9+
repository = "https://github.com/projectM-visualizer/projectm-rs"
1010
keywords = ["visualization", "audio", "sound", "projectm"]
1111
categories = ["multimedia", "multimedia::video", "multimedia::audio"]
1212
readme = "README.md"

src/core.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ impl Projectm {
370370
unsafe { ffi::projectm_pcm_get_max_samples() }
371371
}
372372

373-
fn pcm_add_float(instance: ProjectMHandle, samples: Vec<f32>, channels: ProjectMChannels) {
373+
fn pcm_add_float(instance: ProjectMHandle, samples: &[f32], channels: ProjectMChannels) {
374374
assert!(
375375
samples.len() <= Self::pcm_get_max_samples() as usize,
376376
"Number of samples is greater than max samples"
@@ -386,7 +386,7 @@ impl Projectm {
386386
}
387387
}
388388

389-
fn pcm_add_int16(instance: ProjectMHandle, samples: Vec<i16>, channels: ProjectMChannels) {
389+
fn pcm_add_int16(instance: ProjectMHandle, samples: &[i16], channels: ProjectMChannels) {
390390
assert!(
391391
samples.len() <= Self::pcm_get_max_samples() as usize,
392392
"Number of samples is greater than max samples"
@@ -402,7 +402,7 @@ impl Projectm {
402402
}
403403
}
404404

405-
fn pcm_add_uint8(instance: ProjectMHandle, samples: Vec<u8>, channels: ProjectMChannels) {
405+
fn pcm_add_uint8(instance: ProjectMHandle, samples: &[u8], channels: ProjectMChannels) {
406406
assert!(
407407
samples.len() <= Self::pcm_get_max_samples() as usize,
408408
"Number of samples is greater than max samples"
@@ -762,23 +762,23 @@ impl ProjectM {
762762
Projectm::pcm_get_max_samples()
763763
}
764764

765-
pub fn pcm_add_float(&self, samples: Vec<f32>, channels: ProjectMChannels) {
765+
pub fn pcm_add_float(&self, samples: &[f32], channels: ProjectMChannels) {
766766
if let Ok(instance) = self.instance.try_borrow() {
767767
Projectm::pcm_add_float(*instance, samples, channels);
768768
} else {
769769
panic!("Failed to borrow instance");
770770
}
771771
}
772772

773-
pub fn pcm_add_int16(&self, samples: Vec<i16>, channels: ProjectMChannels) {
773+
pub fn pcm_add_int16(&self, samples: &[i16], channels: ProjectMChannels) {
774774
if let Ok(instance) = self.instance.try_borrow() {
775775
Projectm::pcm_add_int16(*instance, samples, channels);
776776
} else {
777777
panic!("Failed to borrow instance");
778778
}
779779
}
780780

781-
pub fn pcm_add_uint8(&self, samples: Vec<u8>, channels: ProjectMChannels) {
781+
pub fn pcm_add_uint8(&self, samples: &[u8], channels: ProjectMChannels) {
782782
if let Ok(instance) = self.instance.try_borrow() {
783783
Projectm::pcm_add_uint8(*instance, samples, channels);
784784
} else {

tests/playlist.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ mod playlist {
66
#[test]
77
fn playlist() {
88
let projectm = ProjectM::create();
9-
let playlist = Playlist::create(projectm);
9+
let playlist = Playlist::create(&projectm);
1010
assert_eq!(playlist.is_empty(), true);
1111

1212
// add ../presets to playlist

0 commit comments

Comments
 (0)