Skip to content

Commit 8cf3eca

Browse files
- Added Missing Functions For DataConverter
After the test, it turns out the config init Functions are missing in the type, so I have added it such that we can have a more convenient way to declare the converter.
1 parent 38098b0 commit 8cf3eca

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

src/zaudio.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,11 @@ void zaudioDataConverterConfigInit(
689689
*out_config = ma_data_converter_config_init(formatIn, formatOut, channelsIn, channelsOut, sampleRateIn, sampleRateOut);
690690
}
691691

692+
void zaudioDataConverterConfigInitDefault(ma_data_converter_config* out_config){
693+
assert(out_config != NULL);
694+
*out_config = ma_data_converter_config_init_default();
695+
}
696+
692697
// ma_data_converter
693698
ma_result zaudioDataConverterCreate(
694699
ma_data_converter_config* config,

src/zaudio.zig

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,43 @@ pub const DataConverter = opaque {
874874
channel_weighs_io_ptr: [*][*]f32, // [in][out]. Only used when mixingMode is set to ma_channel_mix_mode_custom_weights.
875875
allow_dynamic_sample_rate: u32,
876876
resampling: Resampler.Config,
877+
878+
pub fn initDefault() Config {
879+
var config: Config = undefined;
880+
zaudioDataConverterConfigInitDefault(&config);
881+
return config;
882+
}
883+
extern fn zaudioDataConverterConfigInitDefault(out_config: *Config) void;
884+
885+
pub fn init(
886+
format_in: Format,
887+
format_out: Format,
888+
channels_in: u32,
889+
channels_out: u32,
890+
sample_rate_in: u32,
891+
sample_rate_out: u32,
892+
) Config {
893+
var config: Config = undefined;
894+
zaudioDataConverterConfigInit(
895+
format_in,
896+
format_out,
897+
channels_in,
898+
channels_out,
899+
sample_rate_in,
900+
sample_rate_out,
901+
&config,
902+
);
903+
return config;
904+
}
905+
extern fn zaudioDataConverterConfigInit(
906+
format_in: Format,
907+
format_out: Format,
908+
channels_in: u32,
909+
channels_out: u32,
910+
sample_rate_in: u32,
911+
sample_rate_out: u32,
912+
out_config: *Config,
913+
) void;
877914
};
878915
};
879916

0 commit comments

Comments
 (0)