Skip to content

Show an example of compliling the sound into the binary. - #787

Merged
yara-blue merged 1 commit into
RustAudio:masterfrom
dcampbell24:include-bytes
Aug 24, 2025
Merged

yara-blue merged 1 commit into
RustAudio:masterfrom
dcampbell24:include-bytes

Conversation

@dcampbell24

Copy link
Copy Markdown
Contributor

Seems like something you would want to do fairly often. It is needed for example to package the software on flathub.

@dcampbell24

Copy link
Copy Markdown
Contributor Author

I was not sure if I should do this everywhere or make a separate example of doing this or how exactly I should handle this change, but it seems fairly important. At least I needed to do it.

@yara-blue

Copy link
Copy Markdown
Member

I was not sure if I should do this everywhere or make a separate example of doing this or how exactly I should handle this change, but it seems fairly important. At least I needed to do it.

I don't think it warrants a separate example, but I like having it in there somewhere 👍

Thanks!

@yara-blue
yara-blue merged commit 5ef7ff2 into RustAudio:master Aug 24, 2025
9 checks passed
@dcampbell24
dcampbell24 deleted the include-bytes branch August 24, 2025 18:42
@roderickvd

Copy link
Copy Markdown
Member

Note that using Decoder::try_from(cursor) will not set is_seekable or byte_len. However, the documentation states:

A Cursor wraps an in-memory buffer and provides it with a Seek implementation.

What would you guys say to changing that?

diff --git a/src/decoder/mod.rs b/src/decoder/mod.rs
index 49647c7..f473b44 100644
--- a/src/decoder/mod.rs
+++ b/src/decoder/mod.rs
@@ -392,7 +392,14 @@ where
     type Error = DecoderError;
 
     fn try_from(data: std::io::Cursor<T>) -> Result<Self, Self::Error> {
-        Self::new(data)
+        let len = data.get_ref().as_ref().len() as u64;
+
+        Self::builder()
+            .with_data(data)
+            .with_byte_len(len)
+            .with_seekable(true)
+            .with_scan_duration(true)
+            .build()
     }
 }

@yara-blue

Copy link
Copy Markdown
Member

Note that using Decoder::try_from(cursor) will not set is_seekable or byte_len. However, the documentation states:

A Cursor wraps an in-memory buffer and provides it with a Seek implementation.

What would you guys say to changing that?

diff --git a/src/decoder/mod.rs b/src/decoder/mod.rs
index 49647c7..f473b44 100644
--- a/src/decoder/mod.rs
+++ b/src/decoder/mod.rs
@@ -392,7 +392,14 @@ where
     type Error = DecoderError;
 
     fn try_from(data: std::io::Cursor<T>) -> Result<Self, Self::Error> {
-        Self::new(data)
+        let len = data.get_ref().as_ref().len() as u64;
+
+        Self::builder()
+            .with_data(data)
+            .with_byte_len(len)
+            .with_seekable(true)
+            .with_scan_duration(true)
+            .build()
     }
 }

Lets do it 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants