Skip to content

Commit

Permalink
fixup! refactor: Port to Qt 6
Browse files Browse the repository at this point in the history
  • Loading branch information
ltoenning committed Nov 7, 2024
1 parent 83db1dd commit c0dd32b
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 26 deletions.
3 changes: 3 additions & 0 deletions cmake/install.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ if(UNIX AND NOT APPLE)
install(FILES ${ICU_I18N_ABS} ${ICU_UC_ABS} ${ICU_DATA_ABS} TYPE LIB)
endif()

file(GLOB iconEnginePlugins ${QT_INSTALL_PLUGINS}/iconengines/*.so)
install(FILES ${iconEnginePlugins} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/iconengines)

file(GLOB imageformatsPlugins ${QT_INSTALL_PLUGINS}/imageformats/*.so)
install(FILES ${imageformatsPlugins} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/imageformats)

Expand Down
12 changes: 6 additions & 6 deletions installer/installbuilder/qt6-binaries.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
<distributionFile>
<origin>../../dist/bin/Qt6Core.dll</origin>
</distributionFile>
<distributionFile>
<origin>../../dist/bin/Qt6Core5Compat.dll</origin>
</distributionFile>
<distributionFile>
<origin>../../dist/bin/Qt6Core5Compat.dll</origin>
</distributionFile>
<distributionFile>
<origin>../../dist/bin/Qt6DBus.dll</origin>
</distributionFile>
Expand Down Expand Up @@ -75,9 +75,9 @@
<distributionFile>
<origin>../../dist/lib/libQt6Core.so.6</origin>
</distributionFile>
<distributionFile>
<origin>../../dist/lib/libQt6Core5Compat.so.6</origin>
</distributionFile>
<distributionFile>
<origin>../../dist/lib/libQt6Core5Compat.so.6</origin>
</distributionFile>
<distributionFile>
<origin>../../dist/lib/libQt6DBus.so.6</origin>
</distributionFile>
Expand Down
6 changes: 3 additions & 3 deletions installer/installbuilder/vcredist-x64.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
-->
<component>
<name>vcruntime64</name>
<description>Visual Studio 2019 x64 Redistributables</description>
<description>Visual Studio 2022 x64 Redistributables</description>
<canBeEdited>0</canBeEdited>
<selected>1</selected>
<show>1</show>
Expand All @@ -19,7 +19,7 @@
<abortOnError>0</abortOnError>
<program>${installdir}/vcredist/vc_redist.x64.exe</program>
<programArguments>/install /quiet /norestart</programArguments>
<progressText>Installing Visual Studio 2019 x64 Redistributables</progressText>
<progressText>Installing Visual Studio 2022 x64 Redistributables</progressText>
<showMessageOnError>0</showMessageOnError>
<ruleList>
<platformTest>
Expand All @@ -33,7 +33,7 @@
</ruleList>
</runProgram>
<showWarning>
<text>Installation of MS Visual Studio 2019 x64 Redistributables failed!
<text>Installation of MS Visual Studio 2022 x64 Redistributables failed!
Error Code: ${program_exit_code}
Check if another version was already installed and if not, try to run the installer manually from
${installdir}\vcredist\
Expand Down
13 changes: 13 additions & 0 deletions src/blackcore/afv/audio/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ namespace BlackCore::Afv::Audio
this->setObjectName(on);
}

#ifdef Q_OS_WIN
qint64 CAudioOutputBuffer::bytesAvailable() const
{
// Workaround to mimic the pre-Qt6 behavior.
// With Qt6, the QAudioSink on Windows uses the bytesAvailable function to trigger
// a call to readData() only when data is available. Other platforms still use a
// pull procedure that automatically calls readData() afer a specific period. Until
// a proper solution for the bytesAvailable() is implemented, this uses a fixed number.
// readData() will handle it itself if actually no data is available.
return 3840 + QIODevice::bytesAvailable();
}
#endif

qint64 CAudioOutputBuffer::readData(char *data, qint64 maxlen)
{
const int sampleBytes = m_outputFormat.bytesPerSample();
Expand Down
5 changes: 5 additions & 0 deletions src/blackcore/afv/audio/output.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ namespace BlackCore::Afv::Audio
void outputVolumeStream(const OutputVolumeStreamArgs &args);

protected:
#ifdef Q_OS_WIN
//! \copydoc QIODevice::bytesAvailable
qint64 bytesAvailable() const override;
#endif

//! \copydoc QIODevice::readData
virtual qint64 readData(char *data, qint64 maxlen) override;

Expand Down
17 changes: 0 additions & 17 deletions src/blackcore/afv/clients/afvclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1025,23 +1025,6 @@ namespace BlackCore::Afv::Clients

void CAfvClient::initialize()
{
#ifdef Q_OS_WIN
if (!m_winCoInitialized)
{
HRESULT hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED);

// RPC_E_CHANGED_MODE: CoInitializeEx was already called by someone else in this thread with a different mode.
if (hr == RPC_E_CHANGED_MODE)
{
CLogMessage(this).debug(u"CoInitializeEx was already called with a different mode. Trying again.");
hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
}

// S_OK: The COM library was initialized successfully on this thread.
// S_FALSE: The COM library is already initialized on this thread. Reference count was incremented. This is not an error.
if (hr == S_OK || hr == S_FALSE) { m_winCoInitialized = true; }
}
#endif
CLogMessage(this).info(u"Initialize AFV client in thread %1") << CThreadUtils::currentThreadInfo();
}

Expand Down

0 comments on commit c0dd32b

Please sign in to comment.