feat(example): encode audio with Opus#643
Merged
Benoît Cortier (CBenoit) merged 1 commit intoDevolutions:masterfrom Jan 27, 2025
Merged
feat(example): encode audio with Opus#643Benoît Cortier (CBenoit) merged 1 commit intoDevolutions:masterfrom
Benoît Cortier (CBenoit) merged 1 commit intoDevolutions:masterfrom
Conversation
| let mut data = generate_sine_wave(fmt.n_samples_per_sec, 440.0, 20, &mut phase); | ||
|
|
||
| if let Some(ref mut enc) = opus_enc { | ||
| let input = unsafe { slice::from_raw_parts(data.as_ptr() as *const i16, data.len() / 2) }; |
Member
There was a problem hiding this comment.
suggestion: My typical suggestion for this kind of code is to go with the bytemuck crate instead of writing the unsafe code each time; or to make a copy of the data. The latter solution is obviously less performant, but does not require an additional dependency. (I’m almost sure bytemuck is already to be found somewhere in our stack though.)
Otherwise, you need to ensure the alignment is correct and provide a convincing safety comment describing how the code is correct.
error: unsafe block missing a safety comment
--> crates/ironrdp/examples/server.rs:331:33
|
331 | let input = unsafe { slice::from_raw_parts(data.as_ptr() as *const i16, data.len() / 2) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: consider adding a safety comment on the preceding line
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#undocumented_unsafe_blocks
= note: `-D clippy::undocumented-unsafe-blocks` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::undocumented_unsafe_blocks)]`
error: casting from `*const u8` to a more-strictly-aligned pointer (`*const i16`) (1 < 2 bytes)
--> crates/ironrdp/examples/server.rs:331:64
|
331 | let input = unsafe { slice::from_raw_parts(data.as_ptr() as *const i16, data.len() / 2) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_ptr_alignment
= note: `-D clippy::cast-ptr-alignment` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::cast_ptr_alignment)]`
error: could not compile `ironrdp` (example "server") due to 2 previous errors
Member
|
Lints step is failed. |
Demonstrates Opus audio codec support (and also fixes sine wave phase) Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
e9d7eb4 to
6b15b77
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Demonstrates Opus audio codec support (and also fixes sine wave phase)