mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-22 00:06:59 +02:00
Remove dependency on MA_MAX_CHANNELS from ma_noise.
This commit is contained in:
@@ -235,13 +235,12 @@ ma_bool32 try_parse_noise(const char* arg, ma_noise_type* pNoiseType)
|
||||
ma_result print_device_info(ma_context* pContext, ma_device_type deviceType, const ma_device_info* pDeviceInfo)
|
||||
{
|
||||
ma_result result;
|
||||
ma_uint32 iFormat;
|
||||
ma_device_info detailedDeviceInfo;
|
||||
|
||||
MA_ASSERT(pDeviceInfo != NULL);
|
||||
|
||||
#if 1
|
||||
result = ma_context_get_device_info(pContext, deviceType, &pDeviceInfo->id, ma_share_mode_shared, &detailedDeviceInfo);
|
||||
result = ma_context_get_device_info(pContext, deviceType, &pDeviceInfo->id, &detailedDeviceInfo);
|
||||
if (result != MA_SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
@@ -249,17 +248,24 @@ ma_result print_device_info(ma_context* pContext, ma_device_type deviceType, con
|
||||
detailedDeviceInfo = *pDeviceInfo;
|
||||
#endif
|
||||
|
||||
printf("%s\n", pDeviceInfo->name);
|
||||
printf(" Default: %s\n", (detailedDeviceInfo.isDefault) ? "Yes" : "No");
|
||||
printf(" Min Channels: %d\n", detailedDeviceInfo.minChannels);
|
||||
printf(" Max Channels: %d\n", detailedDeviceInfo.maxChannels);
|
||||
printf(" Min Sample Rate: %d\n", detailedDeviceInfo.minSampleRate);
|
||||
printf(" Max Sample Rate: %d\n", detailedDeviceInfo.maxSampleRate);
|
||||
printf(" Format Count: %d\n", detailedDeviceInfo.formatCount);
|
||||
for (iFormat = 0; iFormat < detailedDeviceInfo.formatCount; ++iFormat) {
|
||||
printf(" %s\n", ma_get_format_name(detailedDeviceInfo.formats[iFormat]));
|
||||
/* TODO: Update this to print the new device info structure. */
|
||||
#if 0
|
||||
{
|
||||
ma_uint32 iFormat;
|
||||
|
||||
printf("%s\n", pDeviceInfo->name);
|
||||
printf(" Default: %s\n", (detailedDeviceInfo.isDefault) ? "Yes" : "No");
|
||||
printf(" Min Channels: %d\n", detailedDeviceInfo.minChannels);
|
||||
printf(" Max Channels: %d\n", detailedDeviceInfo.maxChannels);
|
||||
printf(" Min Sample Rate: %d\n", detailedDeviceInfo.minSampleRate);
|
||||
printf(" Max Sample Rate: %d\n", detailedDeviceInfo.maxSampleRate);
|
||||
printf(" Format Count: %d\n", detailedDeviceInfo.formatCount);
|
||||
for (iFormat = 0; iFormat < detailedDeviceInfo.formatCount; ++iFormat) {
|
||||
printf(" %s\n", ma_get_format_name(detailedDeviceInfo.formats[iFormat]));
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
printf("\n");
|
||||
#endif
|
||||
|
||||
return MA_SUCCESS;
|
||||
}
|
||||
@@ -299,10 +305,9 @@ ma_result enumerate_devices(ma_context* pContext)
|
||||
return MA_SUCCESS;
|
||||
}
|
||||
|
||||
void on_log(ma_context* pContext, ma_device* pDevice, ma_uint32 logLevel, const char* message)
|
||||
void on_log(void* pUserData, ma_uint32 logLevel, const char* message)
|
||||
{
|
||||
(void)pContext;
|
||||
(void)pDevice;
|
||||
(void)pUserData;
|
||||
|
||||
printf("%s: %s\n", ma_log_level_to_string(logLevel), message);
|
||||
}
|
||||
@@ -321,11 +326,11 @@ void on_data(ma_device* pDevice, void* pFramesOut, const void* pFramesIn, ma_uin
|
||||
{
|
||||
/* In the playback case we just read from our input source. */
|
||||
if (g_State.sourceType == source_type_decoder) {
|
||||
ma_decoder_read_pcm_frames(&g_State.decoder, pFramesOut, frameCount);
|
||||
ma_decoder_read_pcm_frames(&g_State.decoder, pFramesOut, frameCount, NULL);
|
||||
} else if (g_State.sourceType == source_type_waveform) {
|
||||
ma_waveform_read_pcm_frames(&g_State.waveform, pFramesOut, frameCount);
|
||||
ma_waveform_read_pcm_frames(&g_State.waveform, pFramesOut, frameCount, NULL);
|
||||
} else if (g_State.sourceType == source_type_noise) {
|
||||
ma_noise_read_pcm_frames(&g_State.noise, pFramesOut, frameCount);
|
||||
ma_noise_read_pcm_frames(&g_State.noise, pFramesOut, frameCount, NULL);
|
||||
}
|
||||
} break;
|
||||
|
||||
@@ -333,7 +338,7 @@ void on_data(ma_device* pDevice, void* pFramesOut, const void* pFramesIn, ma_uin
|
||||
case ma_device_type_loopback:
|
||||
{
|
||||
/* In the capture and loopback cases we just output straight to a file. */
|
||||
ma_encoder_write_pcm_frames(&g_State.encoder, pFramesIn, frameCount);
|
||||
ma_encoder_write_pcm_frames(&g_State.encoder, pFramesIn, frameCount, NULL);
|
||||
} break;
|
||||
|
||||
case ma_device_type_duplex:
|
||||
@@ -345,7 +350,7 @@ void on_data(ma_device* pDevice, void* pFramesOut, const void* pFramesIn, ma_uin
|
||||
|
||||
/* Also output to the encoder if necessary. */
|
||||
if (g_State.hasEncoder) {
|
||||
ma_encoder_write_pcm_frames(&g_State.encoder, pFramesIn, frameCount);
|
||||
ma_encoder_write_pcm_frames(&g_State.encoder, pFramesIn, frameCount, NULL);
|
||||
}
|
||||
} break;
|
||||
|
||||
@@ -426,13 +431,14 @@ int main(int argc, char** argv)
|
||||
|
||||
/* Initialize the context first. If no backends were passed into the command line we just use defaults. */
|
||||
contextConfig = ma_context_config_init();
|
||||
contextConfig.logCallback = on_log;
|
||||
result = ma_context_init((backendCount == 0) ? NULL : backends, backendCount, &contextConfig, &g_State.context);
|
||||
if (result != MA_SUCCESS) {
|
||||
printf("Failed to initialize context.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ma_log_register_callback(ma_context_get_log(&g_State.context), ma_log_callback_init(on_log, NULL));
|
||||
|
||||
/* Here we'll print some info about what we're doing. */
|
||||
printf("Backend: %s\n", ma_get_backend_name(g_State.context.backend));
|
||||
printf("Mode: %s\n", get_mode_description(deviceType));
|
||||
@@ -503,7 +509,7 @@ int main(int argc, char** argv)
|
||||
if (g_State.sourceType == source_type_noise) {
|
||||
ma_noise_config noiseConfig;
|
||||
noiseConfig = ma_noise_config_init(g_State.device.playback.format, g_State.device.playback.channels, noiseType, 0, 0.1);
|
||||
result = ma_noise_init(&noiseConfig, &g_State.noise);
|
||||
result = ma_noise_init(&noiseConfig, NULL, &g_State.noise);
|
||||
if (result != MA_SUCCESS) {
|
||||
printf("Failed to initialize noise.\n");
|
||||
ma_device_uninit(&g_State.device);
|
||||
@@ -515,7 +521,7 @@ int main(int argc, char** argv)
|
||||
|
||||
if (deviceType == ma_device_type_capture || deviceType == ma_device_type_loopback || (deviceType == ma_device_type_duplex && pFilePath != NULL && pFilePath[0] != '\0')) {
|
||||
ma_encoder_config encoderConfig;
|
||||
encoderConfig = ma_encoder_config_init(ma_resource_format_wav, g_State.device.capture.format, g_State.device.capture.channels, g_State.device.sampleRate);
|
||||
encoderConfig = ma_encoder_config_init(ma_encoding_format_wav, g_State.device.capture.format, g_State.device.capture.channels, g_State.device.sampleRate);
|
||||
result = ma_encoder_init_file(pFilePath, &encoderConfig, &g_State.encoder);
|
||||
if (result != MA_SUCCESS) {
|
||||
printf("Failed to initialize output file for capture \"%s\".\n", pFilePath);
|
||||
@@ -579,6 +585,12 @@ done:
|
||||
if (g_State.sourceType == source_type_decoder) {
|
||||
ma_decoder_uninit(&g_State.decoder);
|
||||
}
|
||||
if (g_State.sourceType == source_type_waveform) {
|
||||
ma_waveform_uninit(&g_State.waveform);
|
||||
}
|
||||
if (g_State.sourceType == source_type_noise) {
|
||||
ma_noise_uninit(&g_State.noise, NULL);
|
||||
}
|
||||
if (g_State.hasEncoder) {
|
||||
ma_encoder_uninit(&g_State.encoder);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user