Fixed: When a file was selected for the Convolution command in the Configuration Editor that was not readable by the audio service, no warning appeared.

This commit is contained in:
jthedering committed 2016-01-03 17:24:33 +00:00
1 parent 420b7f0e11
commit b0671221e5
9 files changed
+141 -62

No files matched your search

+33 -14
View File
@@ -21,6 +21,7 @@
#define ENABLE_SNDFILE_WINDOWS_PROTOTYPES 1
#include <sndfile.h>
#include "helpers/RegistryHelper.h"
#include "ConvolutionFilterGUI.h"
#include "ui_ConvolutionFilterGUI.h"
@@ -102,27 +103,45 @@ void ConvolutionFilterGUI::updateFileInfo()
}
else
{
path = fileInfo.absoluteFilePath();
path = QDir::toNativeSeparators(fileInfo.absoluteFilePath());
SF_INFO info;
SNDFILE* file = sf_wchar_open(path.toStdWString().c_str(), SFM_READ, &info);
if (file == NULL)
ACCESS_MASK mask = GENERIC_READ;
try
{
error = tr("Unsupported file format");
mask = RegistryHelper::getFileAccessForUser(path.toStdWString(), SECURITY_LOCAL_SERVICE_RID);
}
catch (RegistryException e)
{
// ignore
}
if ((mask & GENERIC_READ) != GENERIC_READ && (mask & FILE_GENERIC_READ) != FILE_GENERIC_READ)
{
error = tr("The file is not readable for the audio service.\nChange the file permissions or copy the file to the config directory.");
labelsVisible = false;
}
else
{
int sampleRate = info.samplerate;
double length = info.frames * 1000.0 / sampleRate;
ui->labelLengthValue->setText(tr("%0 ms (%1 samples)").arg(length).arg(info.frames));
ui->labelSampleRateValue->setText(tr("%0 Hz").arg(sampleRate));
sf_close(file);
if (sampleRate != deviceSampleRate)
SF_INFO info;
SNDFILE* file = sf_wchar_open(path.toStdWString().c_str(), SFM_READ, &info);
if (file == NULL)
{
error = tr("The file sample rate does not match the device sample rate (%0 Hz)!\nSelect a different file or change the device configuration.").arg(deviceSampleRate);
error = tr("Unsupported file format");
labelsVisible = false;
}
else
{
int sampleRate = info.samplerate;
double length = info.frames * 1000.0 / sampleRate;
ui->labelLengthValue->setText(tr("%0 ms (%1 samples)").arg(length).arg(info.frames));
ui->labelSampleRateValue->setText(tr("%0 Hz").arg(sampleRate));
sf_close(file);
if (sampleRate != deviceSampleRate)
{
error = tr("The file sample rate does not match the device sample rate (%0 Hz)!\nSelect a different file or change the device configuration.").arg(deviceSampleRate);
}
}
}
}