mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-22 00:06:59 +02:00
Another potential fix for some full-duplex glitching.
This change makes it so reading and writing is done on the smaller of the period sizes between capture and playback devices.
This commit is contained in:
+8
-7
@@ -31,7 +31,7 @@ void data_callback(mal_device* pDevice, void* pOutput, const void* pInput, mal_u
|
||||
/* In this test the format and channel count are the same for both input and output which means we can just memcpy(). */
|
||||
mal_copy_memory(pOutput, pInput, frameCount * mal_get_bytes_per_frame(pDevice->capture.format, pDevice->capture.channels));
|
||||
|
||||
#if 0
|
||||
#if 1
|
||||
/* Also write to a wav file for debugging. */
|
||||
drwav* pWav = (drwav*)pDevice->pUserData;
|
||||
mal_assert(pWav != NULL);
|
||||
@@ -44,7 +44,7 @@ int main(int argc, char** argv)
|
||||
{
|
||||
mal_result result;
|
||||
|
||||
#if 0
|
||||
#if 1
|
||||
drwav_data_format wavFormat;
|
||||
wavFormat.container = drwav_container_riff;
|
||||
wavFormat.format = DR_WAVE_FORMAT_PCM;
|
||||
@@ -60,7 +60,7 @@ int main(int argc, char** argv)
|
||||
#endif
|
||||
|
||||
|
||||
mal_backend backend = mal_backend_wasapi;
|
||||
mal_backend backend = mal_backend_dsound;
|
||||
|
||||
mal_context_config contextConfig = mal_context_config_init();
|
||||
contextConfig.logCallback = log_callback;
|
||||
@@ -81,11 +81,12 @@ int main(int argc, char** argv)
|
||||
deviceConfig.playback.channels = 2;
|
||||
deviceConfig.playback.shareMode = mal_share_mode_shared;
|
||||
deviceConfig.sampleRate = 44100;
|
||||
deviceConfig.bufferSizeInMilliseconds = 100;
|
||||
deviceConfig.periods = 2;
|
||||
//deviceConfig.bufferSizeInMilliseconds = 60;
|
||||
deviceConfig.bufferSizeInFrames = 4096;
|
||||
//deviceConfig.periods = 3;
|
||||
deviceConfig.dataCallback = data_callback;
|
||||
deviceConfig.stopCallback = stop_callback;
|
||||
deviceConfig.pUserData = NULL/*&wav*/;
|
||||
deviceConfig.pUserData = &wav;
|
||||
|
||||
mal_device device;
|
||||
result = mal_device_init(&context, &deviceConfig, &device);
|
||||
@@ -107,7 +108,7 @@ int main(int argc, char** argv)
|
||||
#endif
|
||||
|
||||
mal_device_uninit(&device);
|
||||
/*drwav_uninit(&wav);*/
|
||||
drwav_uninit(&wav);
|
||||
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
Reference in New Issue
Block a user