Correct the Windows audio dialog rate, add a default file name

This commit is contained in:
Lior Halphon 2022-07-02 22:41:07 +03:00
parent e466c3c5b1
commit faccdd3e9b

View File

@ -65,22 +65,25 @@ char *do_open_folder_dialog(void)
char *do_save_recording_dialog(unsigned frequency) char *do_save_recording_dialog(unsigned frequency)
{ {
OPENFILENAMEW dialog; OPENFILENAMEW dialog;
wchar_t filename[MAX_PATH + 5]; wchar_t filename[MAX_PATH + 5] = L"recording.wav";
filename[0] = '\0';
memset(&dialog, 0, sizeof(dialog)); memset(&dialog, 0, sizeof(dialog));
dialog.lStructSize = sizeof(dialog); dialog.lStructSize = sizeof(dialog);
dialog.lpstrFile = filename; dialog.lpstrFile = filename;
dialog.nMaxFile = MAX_PATH; dialog.nMaxFile = MAX_PATH;
if (frequency == 48000) { switch (frequency) {
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"; 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";
else { break;
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"; 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.nFilterIndex = 1;
dialog.lpstrFileTitle = NULL;
dialog.nMaxFileTitle = 0;
dialog.lpstrInitialDir = NULL; dialog.lpstrInitialDir = NULL;
dialog.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; dialog.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;