Skip to content

Commit

Permalink
Update the CLAP bindings to fix soundpack struct
Browse files Browse the repository at this point in the history
Plugins defining soundpacks might otherwise segfault because the
struct's size was off by 4 bytes.
  • Loading branch information
robbert-vdh committed Feb 19, 2023
1 parent cc9a333 commit 46a3008
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic
Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

### Fixed

- Fixed an incorrect definition of the preset discovery soundpack struct for the
preset discovery draft extension.

## [0.3.0] - 2023-02-08

### Added
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ chrono = { version = "0.4.23", features = ["serde"] }
# All the claps!
clap = { version = "4.1.1", features = ["derive", "wrap_help"] }
# For CLAP 1.1.7 support
clap-sys = { git = "https://github.com/robbert-vdh/clap-sys.git", rev = "88261e494c1ea1e7bc30ec53bf191a0a3111f95c" }
clap-sys = { git = "https://github.com/robbert-vdh/clap-sys.git", rev = "cf5d36e9d1daa4b052c1a9e3d6d623b75734e65d" }
colored = "2.0.0"
crossbeam = "0.8.1"
libloading = "0.7.3"
Expand Down
4 changes: 2 additions & 2 deletions src/commands/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ where
if let Some(homepage_url) = soundpack.homepage_url {
println_wrapped!(wrapper, " homepage url: {homepage_url}");
}
if let Some(image_url) = soundpack.image_url {
println_wrapped!(wrapper, " image url: {image_url}");
if let Some(image_uri) = soundpack.image_uri {
println_wrapped!(wrapper, " image url: {image_uri}");
}
if let Some(release_timestamp) = soundpack.release_timestamp {
println_wrapped!(wrapper, " released: {release_timestamp}");
Expand Down
17 changes: 10 additions & 7 deletions src/plugin/preset_discovery/indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ pub struct Soundpack {
pub description: Option<String>,
pub homepage_url: Option<String>,
pub vendor: Option<String>,
pub image_url: Option<String>,
pub image_uri: Option<String>,
pub release_timestamp: Option<DateTime<Utc>>,
}

Expand All @@ -255,11 +255,14 @@ impl Soundpack {
pub fn from_descriptor(descriptor: &clap_preset_discovery_soundpack) -> Result<Self> {
Ok(Soundpack {
flags: Flags {
is_factory_content: (descriptor.flags & CLAP_PRESET_DISCOVERY_IS_FACTORY_CONTENT)
is_factory_content: (descriptor.flags
& CLAP_PRESET_DISCOVERY_IS_FACTORY_CONTENT as u64)
!= 0,
is_user_content: (descriptor.flags & CLAP_PRESET_DISCOVERY_IS_USER_CONTENT) != 0,
is_demo_content: (descriptor.flags & CLAP_PRESET_DISCOVERY_IS_DEMO_CONTENT) != 0,
is_favorite: (descriptor.flags & CLAP_PRESET_DISCOVERY_IS_FAVORITE) != 0,
is_user_content: (descriptor.flags & CLAP_PRESET_DISCOVERY_IS_USER_CONTENT as u64)
!= 0,
is_demo_content: (descriptor.flags & CLAP_PRESET_DISCOVERY_IS_DEMO_CONTENT as u64)
!= 0,
is_favorite: (descriptor.flags & CLAP_PRESET_DISCOVERY_IS_FAVORITE as u64) != 0,
},

id: unsafe { util::cstr_ptr_to_mandatory_string(descriptor.id) }
Expand All @@ -272,8 +275,8 @@ impl Soundpack {
.context("Error parsing the soundpack's 'homepage_url' field")?,
vendor: unsafe { util::cstr_ptr_to_optional_string(descriptor.vendor) }
.context("Error parsing the soundpack's 'vendor' field")?,
image_url: unsafe { util::cstr_ptr_to_optional_string(descriptor.image_url) }
.context("Error parsing the soundpack's 'image_url' field")?,
image_uri: unsafe { util::cstr_ptr_to_optional_string(descriptor.image_uri) }
.context("Error parsing the soundpack's 'image_uri' field")?,
release_timestamp: util::parse_timestamp(descriptor.release_timestamp)
.context("Error parsing the soundpack's 'release_timestamp' field")?,
})
Expand Down

0 comments on commit 46a3008

Please sign in to comment.