Skip to content

Commit 1af0f08

Browse files
committed
Fix WAV exporting on Windows
1 parent ddcae47 commit 1af0f08

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

Diff for: include/AudioFileDevice.h

+4
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ class AudioFileDevice : public AudioDevice
5656
return m_outputFile.isOpen();
5757
}
5858

59+
inline int outputFileHandle() const
60+
{
61+
return m_outputFile.handle();
62+
}
5963

6064
private:
6165
QFile m_outputFile;

Diff for: src/core/audio/AudioFileWave.cpp

+12-7
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
#include "endian_handling.h"
2828
#include "Mixer.h"
2929

30+
#include <QFile>
31+
#include <QDebug>
32+
3033

3134
AudioFileWave::AudioFileWave( OutputSettings const & outputSettings,
3235
const ch_cnt_t channels, bool & successful,
@@ -72,13 +75,15 @@ bool AudioFileWave::startEncoding()
7275
m_si.format |= SF_FORMAT_PCM_16;
7376
break;
7477
}
75-
m_sf = sf_open(
76-
#ifdef LMMS_BUILD_WIN32
77-
outputFile().toLocal8Bit().constData(),
78-
#else
79-
outputFile().toUtf8().constData(),
80-
#endif
81-
SFM_WRITE, &m_si );
78+
79+
// Use file handle to handle unicode file name on Windows
80+
m_sf = sf_open_fd( outputFileHandle(), SFM_WRITE, &m_si, false );
81+
82+
if (!m_sf)
83+
{
84+
qWarning("Error: AudioFileWave::startEncoding: %s", sf_strerror(nullptr));
85+
return false;
86+
}
8287

8388
// Prevent fold overs when encountering clipped data
8489
sf_command(m_sf, SFC_SET_CLIPPING, NULL, SF_TRUE);

0 commit comments

Comments
 (0)