mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-21 15:56:58 +02:00
Fix bugs with sndio.
This commit is contained in:
@@ -17786,6 +17786,7 @@ mal_result mal_device_init_handle__sndio(mal_context* pContext, const mal_device
|
||||
internalBufferSizeInFrames = par.appbufsz;
|
||||
|
||||
if (deviceType == mal_device_type_capture) {
|
||||
pDevice->sndio.handleCapture = handle;
|
||||
pDevice->capture.internalFormat = internalFormat;
|
||||
pDevice->capture.internalChannels = internalChannels;
|
||||
pDevice->capture.internalSampleRate = internalSampleRate;
|
||||
@@ -17793,6 +17794,7 @@ mal_result mal_device_init_handle__sndio(mal_context* pContext, const mal_device
|
||||
pDevice->capture.internalBufferSizeInFrames = internalBufferSizeInFrames;
|
||||
pDevice->capture.internalPeriods = internalPeriods;
|
||||
} else {
|
||||
pDevice->sndio.handlePlayback = handle;
|
||||
pDevice->playback.internalFormat = internalFormat;
|
||||
pDevice->playback.internalChannels = internalChannels;
|
||||
pDevice->playback.internalSampleRate = internalSampleRate;
|
||||
|
||||
+11
-1
@@ -6,6 +6,14 @@
|
||||
#define MINI_AL_IMPLEMENTATION
|
||||
#include "../mini_al.h"
|
||||
|
||||
void on_log(mal_context* pContext, mal_device* pDevice, mal_uint32 logLevel, const char* message)
|
||||
{
|
||||
(void)pContext;
|
||||
(void)pDevice;
|
||||
(void)logLevel;
|
||||
printf("%s\n", message);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
(void)argc;
|
||||
@@ -14,6 +22,9 @@ int main(int argc, char** argv)
|
||||
mal_result result;
|
||||
mal_backend backend = mal_backend_audio4;
|
||||
|
||||
mal_context_config contextConfig = mal_context_config_init();
|
||||
contextConfig.logCallback = on_log;
|
||||
|
||||
mal_device_config deviceConfig = mal_device_config_init(mal_device_type_playback);
|
||||
deviceConfig.playback.format = mal_format_f32;
|
||||
deviceConfig.capture.format = mal_format_f32;
|
||||
@@ -53,7 +64,6 @@ int main(int argc, char** argv)
|
||||
float buffer[1024*32]; float* pBuffer = buffer;
|
||||
//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) {
|
||||
printf("Error occurred while writing to the device.\n");
|
||||
|
||||
Reference in New Issue
Block a user