diff --git a/mini_al.h b/mini_al.h index 1e6376dd..15ff43c0 100644 --- a/mini_al.h +++ b/mini_al.h @@ -19025,8 +19025,8 @@ mal_result mal_device_init_fd__oss(mal_context* pContext, const mal_device_confi ossFragmentSizePower += 1; } - ossFragment = (int)((pDevice->periods << 16) | ossFragmentSizePower); - ossResult = ioctl(pDevice->oss.fd, SNDCTL_DSP_SETFRAGMENT, &ossFragment); + ossFragment = (int)((pConfig->periods << 16) | ossFragmentSizePower); + ossResult = ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &ossFragment); if (ossResult == -1) { close(fd); return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[OSS] Failed to set fragment size and period count.", MAL_FORMAT_NOT_SUPPORTED); diff --git a/tests/mal_blocking.c b/tests/mal_blocking.c index bbc37fe2..c93f3fca 100644 --- a/tests/mal_blocking.c +++ b/tests/mal_blocking.c @@ -14,29 +14,29 @@ int main(int argc, char** argv) mal_result result; mal_backend backend = mal_backend_oss; - mal_device_config deviceConfig = mal_device_config_init_default(NULL); - deviceConfig.format = mal_format_f32; + mal_device_config deviceConfig = mal_device_config_init(mal_device_type_playback); + deviceConfig.playback.format = mal_format_f32; + deviceConfig.capture.format = mal_format_f32; deviceConfig.bufferSizeInFrames = 1024*8; //deviceConfig.bufferSizeInMilliseconds = 80; deviceConfig.periods = 2; - deviceConfig.shareMode = mal_share_mode_shared; -#if 1 +#if 0 /* Playback */ mal_device device; - result = mal_device_init_ex(&backend, 1, NULL, mal_device_type_playback, NULL, &deviceConfig, &device); + result = mal_device_init_ex(&backend, 1, NULL, &deviceConfig, &device); if (result != MAL_SUCCESS) { printf("Failed to initialize device.\n"); return -1; } - printf("Is Passthrough: %s\n", device.dsp.isPassthrough ? "YES" : "NO"); - printf("Format: %s -> %s\n", mal_get_format_name(device.format), mal_get_format_name(device.internalFormat)); - printf("Channels: %d -> %d\n", device.channels, device.internalChannels); - printf("Sample Rate: %d -> %d\n", device.sampleRate, device.internalSampleRate); - printf("Buffer Size In Frames: %d\n", device.bufferSizeInFrames); + printf("Is Passthrough: %s\n", device.playback.converter.isPassthrough ? "YES" : "NO"); + printf("Format: %s -> %s\n", mal_get_format_name(device.playback.format), mal_get_format_name(device.playback.internalFormat)); + printf("Channels: %d -> %d\n", device.playback.channels, device.playback.internalChannels); + printf("Sample Rate: %d -> %d\n", device.sampleRate, device.playback.internalSampleRate); + printf("Buffer Size In Frames: %d\n", device.playback.internalBufferSizeInFrames); - mal_decoder_config decoderConfig = mal_decoder_config_init(mal_format_f32, device.channels, device.sampleRate); + mal_decoder_config decoderConfig = mal_decoder_config_init(mal_format_f32, device.playback.channels, device.sampleRate); mal_decoder decoder; printf("LOADING DECODER\n"); result = mal_decoder_init_file("res/sine_s16_mono_48000.wav", &decoderConfig, &decoder); @@ -51,8 +51,8 @@ int main(int argc, char** argv) mal_bool32 stopped = MAL_FALSE; while (!stopped) { float buffer[1024*32]; float* pBuffer = buffer; - //mal_uint32 frameCount = (mal_uint32)mal_sine_wave_read_f32_ex(&sineWave, mal_countof(buffer) / device.channels, device.channels, mal_stream_layout_interleaved, &pBuffer); - mal_uint32 frameCount = (mal_uint32)mal_decoder_read_pcm_frames(&decoder, mal_countof(buffer) / device.channels, pBuffer); + //mal_uint32 frameCount = (mal_uint32)mal_sine_wave_read_f32_ex(&sineWave, mal_countof(buffer) / device.playback.channels, device.playback.channels, mal_stream_layout_interleaved, &pBuffer); + mal_uint32 frameCount = (mal_uint32)mal_decoder_read_pcm_frames(&decoder, mal_countof(buffer) / device.playback.channels, pBuffer); result = mal_device_write(&device, pBuffer, frameCount); if (result != MAL_SUCCESS) { @@ -62,22 +62,24 @@ int main(int argc, char** argv) printf("TESTING: frameCount=%d\n", frameCount); } + + mal_decoder_uninit(&decoder); #else /* Capture */ mal_device device; - result = mal_device_init_ex(&backend, 1, NULL, mal_device_type_capture, NULL, &deviceConfig, &device); + result = mal_device_init_ex(&backend, 1, NULL, &deviceConfig, &device); if (result != MAL_SUCCESS) { printf("Failed to initialize device.\n"); return -1; } - printf("Is Passthrough: %s\n", device.dsp.isPassthrough ? "YES" : "NO"); - printf("Format: %s\n", mal_get_format_name(device.format)); + printf("Is Passthrough: %s\n", device.capture.converter.isPassthrough ? "YES" : "NO"); + printf("Format: %s\n", mal_get_format_name(device.capture.format)); drwav_data_format format; format.container = drwav_container_riff; format.format = DR_WAVE_FORMAT_IEEE_FLOAT; - format.channels = device.channels; + format.channels = device.capture.channels; format.sampleRate = device.sampleRate; format.bitsPerSample = 32; drwav* pWav = drwav_open_file_write("recording.wav", &format); @@ -90,7 +92,7 @@ int main(int argc, char** argv) mal_bool32 stopped = MAL_FALSE; while (!stopped) { float buffer[1024*4]; - mal_uint32 frameCount = mal_countof(buffer) / device.channels; + mal_uint32 frameCount = mal_countof(buffer) / device.capture.channels; result = mal_device_read(&device, buffer, frameCount); if (result != MAL_SUCCESS) { @@ -105,8 +107,6 @@ int main(int argc, char** argv) break; } } - - mal_decoder_uninit(&decoder); #endif printf("DONE\n");