From faccdd3e9baa86bdb9fdeca1ec0dbcbdf95981c3 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Sat, 2 Jul 2022 22:41:07 +0300 Subject: [PATCH] Correct the Windows audio dialog rate, add a default file name --- OpenDialog/windows.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/OpenDialog/windows.c b/OpenDialog/windows.c index 13dea8e..e940804 100644 --- a/OpenDialog/windows.c +++ b/OpenDialog/windows.c @@ -65,22 +65,25 @@ char *do_open_folder_dialog(void) char *do_save_recording_dialog(unsigned frequency) { OPENFILENAMEW dialog; - wchar_t filename[MAX_PATH + 5]; - - filename[0] = '\0'; + wchar_t filename[MAX_PATH + 5] = L"recording.wav"; + memset(&dialog, 0, sizeof(dialog)); dialog.lStructSize = sizeof(dialog); dialog.lpstrFile = filename; dialog.nMaxFile = MAX_PATH; - if (frequency == 48000) { - dialog.lpstrFilter = L"RIFF WAVE\0*.wav\0Apple AIFF\0*.aiff;*.aif;*.aifc\0Raw PCM (Stereo 48000Hz, 16-bit LE)\0*.raw;*.pcm;\0All files\0*.*\0\0"; - } - else { - dialog.lpstrFilter = L"RIFF WAVE\0*.wav\0Apple AIFF\0*.aiff;*.aif;*.aifc\0Raw PCM (Stereo 44100Hz, 16-bit LE)\0*.raw;*.pcm;\0All files\0*.*\0\0"; + switch (frequency) { + case 96000: + dialog.lpstrFilter = L"RIFF WAVE\0*.wav\0Apple AIFF\0*.aiff;*.aif;*.aifc\0Raw PCM (Stereo 96000Hz, 16-bit LE)\0*.raw;*.pcm;\0All files\0*.*\0\0"; + break; + case 48000: + dialog.lpstrFilter = L"RIFF WAVE\0*.wav\0Apple AIFF\0*.aiff;*.aif;*.aifc\0Raw PCM (Stereo 48000Hz, 16-bit LE)\0*.raw;*.pcm;\0All files\0*.*\0\0"; + break; + case 44100: + default: + dialog.lpstrFilter = L"RIFF WAVE\0*.wav\0Apple AIFF\0*.aiff;*.aif;*.aifc\0Raw PCM (Stereo 44100Hz, 16-bit LE)\0*.raw;*.pcm;\0All files\0*.*\0\0"; + break; } dialog.nFilterIndex = 1; - dialog.lpstrFileTitle = NULL; - dialog.nMaxFileTitle = 0; dialog.lpstrInitialDir = NULL; dialog.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;