Skip to content

Commit 53790d2

Browse files
committed
Ensure that SoundFont type is Send/Sync
1 parent de18ced commit 53790d2

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

  • oxisynth/src/core/soundfont

oxisynth/src/core/soundfont/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,20 @@ pub struct SoundFont {
2222
presets: Vec<Arc<Preset>>,
2323
}
2424

25+
// SondFont::load() might be slow due to IO or SF3 vorbis decompression,
26+
// so we want to allow the font to be loaded on a different thread.
27+
//
28+
// Technically we could also do `load_asnyc()` variant, but IMO that's redundant.
29+
const _: fn() = {
30+
fn assert_send_sync<T: Send + Sync>() {}
31+
assert_send_sync::<SoundFont>
32+
};
33+
2534
impl SoundFont {
35+
/// Load SoundFont™ file, once loaded it can be added to the synth with [crate::Synth::add_font()].
36+
///
37+
/// This operation might be quite slow due to blocking IO operations and potential SF3 vorbis decompression,
38+
/// so you might consider loading on a secondary thread. [SoundFont] is both [Send] and [Sync].
2639
pub fn load<F: Read + Seek>(file: &mut F) -> Result<Self, LoadError> {
2740
let sf2 = soundfont::SoundFont2::load(file)?;
2841

0 commit comments

Comments
 (0)