Skip to content

Commit

Permalink
ControlSurface
Browse files Browse the repository at this point in the history
  • Loading branch information
Levitanus committed May 25, 2024
1 parent f97d24c commit d06d91f
Show file tree
Hide file tree
Showing 9 changed files with 888 additions and 35 deletions.
12 changes: 6 additions & 6 deletions low/src/control_surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ use std::ptr::{null, null_mut, NonNull};
///
/// [`create_cpp_to_rust_control_surface()`]: fn.create_cpp_to_rust_control_surface.html
pub trait IReaperControlSurface: Debug + Downcast {
fn GetTypeString(&self) -> *const ::std::os::raw::c_char {
fn GetTypeString(&mut self) -> *const ::std::os::raw::c_char {
null()
}

fn GetDescString(&self) -> *const ::std::os::raw::c_char {
fn GetDescString(&mut self) -> *const ::std::os::raw::c_char {
null()
}

fn GetConfigString(&self) -> *const ::std::os::raw::c_char {
fn GetConfigString(&mut self) -> *const ::std::os::raw::c_char {
null()
}

Expand Down Expand Up @@ -215,23 +215,23 @@ pub unsafe fn delete_cpp_control_surface(
extern "C" fn cpp_to_rust_IReaperControlSurface_GetTypeString(
callback_target: *mut Box<dyn IReaperControlSurface>,
) -> *const ::std::os::raw::c_char {
firewall(|| unsafe { &*callback_target }.GetTypeString())
firewall(|| unsafe { &mut *callback_target }.GetTypeString())
.unwrap_or(null_mut())
}

#[no_mangle]
extern "C" fn cpp_to_rust_IReaperControlSurface_GetDescString(
callback_target: *mut Box<dyn IReaperControlSurface>,
) -> *const ::std::os::raw::c_char {
firewall(|| unsafe { &*callback_target }.GetDescString())
firewall(|| unsafe { &mut *callback_target }.GetDescString())
.unwrap_or(null_mut())
}

#[no_mangle]
extern "C" fn cpp_to_rust_IReaperControlSurface_GetConfigString(
callback_target: *mut Box<dyn IReaperControlSurface>,
) -> *const ::std::os::raw::c_char {
firewall(|| unsafe { &*callback_target }.GetConfigString())
firewall(|| unsafe { &mut *callback_target }.GetConfigString())
.unwrap_or(null_mut())
}

Expand Down
4 changes: 2 additions & 2 deletions low/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ mod reaper;
pub use reaper::*;

mod reaper_impl;
pub use reaper_impl::*;
// pub use reaper_impl::*;

mod swell;
pub use swell::*;
Expand All @@ -98,7 +98,7 @@ pub use static_context::*;
mod swell_impl;

mod midi;
pub use midi::*;
// pub use midi::*;

mod resample;
pub use resample::*;
Expand Down
7 changes: 5 additions & 2 deletions low/src/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ pub use super::bindings::root::{
MIDI_event_t, MIDI_eventlist, MediaItem, MediaItem_Take, MediaTrack,
PCM_sink, PCM_source, PCM_source_peaktransfer_t, PCM_source_transfer_t,
ProjectStateContext, REAPER_Resample_Interface, ReaProject, ReaSample,
TrackEnvelope, WDL_HeapBuf, CSURF_EXT_RESET, CSURF_EXT_SETBPMANDPLAYRATE,
TrackEnvelope, WDL_HeapBuf, CSURF_EXT_MIDI_DEVICE_REMAP, CSURF_EXT_RESET,
CSURF_EXT_SETAUTORECARM, CSURF_EXT_SETBPMANDPLAYRATE,
CSURF_EXT_SETFOCUSEDFX, CSURF_EXT_SETFXCHANGE, CSURF_EXT_SETFXENABLED,
CSURF_EXT_SETFXOPEN, CSURF_EXT_SETFXPARAM, CSURF_EXT_SETFXPARAM_RECFX,
CSURF_EXT_SETINPUTMONITOR, CSURF_EXT_SETLASTTOUCHEDFX,
CSURF_EXT_SETPAN_EX, CSURF_EXT_SETPROJECTMARKERCHANGE,
CSURF_EXT_SETLASTTOUCHEDTRACK, CSURF_EXT_SETMETRONOME,
CSURF_EXT_SETMIXERSCROLL, CSURF_EXT_SETPAN_EX,
CSURF_EXT_SETPROJECTMARKERCHANGE, CSURF_EXT_SETRECMODE,
CSURF_EXT_SETRECVPAN, CSURF_EXT_SETRECVVOLUME, CSURF_EXT_SETSENDPAN,
CSURF_EXT_SETSENDVOLUME, CSURF_EXT_SUPPORTS_EXTENDED_TOUCH,
CSURF_EXT_TRACKFX_PRESET_CHANGED, PCM_SOURCE_EXT_EXPORTTOFILE,
Expand Down
22 changes: 11 additions & 11 deletions rea-rs-test/src/integration_test.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use fs_extra::dir::CopyOptions;
use std::error::Error;
use std::fs::File;
use std::io::{Cursor, Write};
use std::io::Write;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
use std::time::Duration;
Expand Down Expand Up @@ -141,16 +141,16 @@ fn build_on_macos(
}

/// Download file only if it is not exists.
fn download_file(url: impl Into<String>, path: PathBuf) -> Result<()> {
if path.exists() {
return Ok(());
}
let resp = reqwest::blocking::get(url.into())?;
let mut f = File::create(path.clone())?;
let mut content = Cursor::new(resp.bytes()?);
std::io::copy(&mut content, &mut f)?;
Ok(())
}
// fn download_file(url: impl Into<String>, path: PathBuf) -> Result<()> {
// if path.exists() {
// return Ok(());
// }
// let resp = reqwest::blocking::get(url.into())?;
// let mut f = File::create(path.clone())?;
// let mut content = Cursor::new(resp.bytes()?);
// std::io::copy(&mut content, &mut f)?;
// Ok(())
// }

fn install_plugin(
target_dir_path: &Path,
Expand Down
6 changes: 4 additions & 2 deletions rea-rs-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@
use rea_rs::{PluginContext, Reaper, Timer};
use rea_rs_low::register_plugin_destroy_hook;
use std::{error::Error, fmt::Debug, panic, process};
use std::{
cell::RefCell, error::Error, fmt::Debug, panic, process, sync::Arc,
};

pub mod integration_test;
pub use integration_test::*;
Expand Down Expand Up @@ -172,7 +174,7 @@ impl ReaperTest {
.expect("Can not reigister test action");
Self::make_available_globally(instance);
if integration {
reaper.register_timer(Box::new(IntegrationTimer {}))
reaper.register_timer(Arc::new(RefCell::new(IntegrationTimer {})))
}
ReaperTest::get_mut()
}
Expand Down
8 changes: 8 additions & 0 deletions rea-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ serde_derive = "1.0"
serde_json = "1.0"
chrono = {version="0.4", features=["serde"]}
strum = { version = "0.26", features = ["derive"] }
thiserror = "1.0.5"
anyhow = "1.0.8"

# tungstenite = "0.21.0"
# tokio-tungstenite = "0.21.0"
# tokio = {version="1.37.0"}
# futures-util = "0.3.30"
# url = "2.5.0"
ws = "0.9.2"

[dev-dependencies]
Expand Down
Loading

0 comments on commit d06d91f

Please sign in to comment.