@@ -39,6 +39,12 @@ pub extern "C" fn sea_encoder_default_settings() -> CSeaEncoderSettings {
3939}
4040
4141#[ no_mangle]
42+ /// # Safety
43+ ///
44+ /// * `input_samples` must be a valid pointer to an array of `i16` of length `input_length`.
45+ /// * `output_data` must be a valid pointer to a pointer where the output buffer address will be stored.
46+ /// * `output_length` must be a valid pointer where the output length will be stored.
47+ /// * If `settings` is not null, it must point to a valid `CSeaEncoderSettings` struct.
4248pub unsafe extern "C" fn sea_encode (
4349 input_samples : * const i16 ,
4450 input_length : usize ,
@@ -73,6 +79,12 @@ pub unsafe extern "C" fn sea_encode(
7379}
7480
7581#[ no_mangle]
82+ /// # Safety
83+ ///
84+ /// * `encoded_data` must be a valid pointer to a byte array of length `encoded_length`.
85+ /// * `output_samples` must be a valid pointer to a pointer where the decoded samples address will be stored.
86+ /// * `output_sample_count` must be a valid pointer where the sample count will be stored.
87+ /// * `output_sample_rate` and `output_channels` may be null, but if provided must be valid pointers.
7688pub unsafe extern "C" fn sea_decode (
7789 encoded_data : * const u8 ,
7890 encoded_length : usize ,
@@ -109,13 +121,21 @@ pub unsafe extern "C" fn sea_decode(
109121}
110122
111123#[ no_mangle]
124+ /// # Safety
125+ ///
126+ /// * `data` must be a pointer to a memory block allocated by `sea_encode` (or compatible Rust allocator).
127+ /// * `length` must match the length of the allocated block.
112128pub unsafe extern "C" fn sea_free_packet ( data : * mut u8 , length : usize ) {
113129 if !data. is_null ( ) {
114130 let _ = Vec :: from_raw_parts ( data, length, length) ;
115131 }
116132}
117133
118134#[ no_mangle]
135+ /// # Safety
136+ ///
137+ /// * `samples` must be a pointer to a memory block allocated by `sea_decode` (or compatible Rust allocator).
138+ /// * `length` must match the length of the allocated block.
119139pub unsafe extern "C" fn sea_free_samples ( samples : * mut i16 , length : usize ) {
120140 if !samples. is_null ( ) {
121141 let _ = Vec :: from_raw_parts ( samples, length, length) ;
0 commit comments