fix(editor): replaced QSoundEffect with Miniaudio
This commit is contained in:
parent
62743d8998
commit
52cfa69a6e
5 changed files with 20 additions and 13 deletions
|
@ -27,4 +27,6 @@ CPMAddPackage("gh:nothings/stb#8cfb1605c02aee9fb6eb5d8ea559017745bd9a16") # 2.14
|
||||||
CPMAddPackage("gh:WohlSoft/LuaJIT#a5da8f4a31972b74254f00969111b8b7a07cf584") # v2.1
|
CPMAddPackage("gh:WohlSoft/LuaJIT#a5da8f4a31972b74254f00969111b8b7a07cf584") # v2.1
|
||||||
set(LUAJIT_INCLUDE_DIRS ${LuaJIT_SOURCE_DIR}/src)
|
set(LUAJIT_INCLUDE_DIRS ${LuaJIT_SOURCE_DIR}/src)
|
||||||
|
|
||||||
|
CPMAddPackage("gh:mackron/miniaudio#0.11.22")
|
||||||
|
|
||||||
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PREV_BIN_PATH})
|
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PREV_BIN_PATH})
|
|
@ -37,7 +37,7 @@ set(PROJECT_SOURCES
|
||||||
|
|
||||||
qt_add_executable(editor MANUAL_FINALIZATION ${PROJECT_SOURCES})
|
qt_add_executable(editor MANUAL_FINALIZATION ${PROJECT_SOURCES})
|
||||||
target_include_directories(editor PRIVATE .)
|
target_include_directories(editor PRIVATE .)
|
||||||
target_link_libraries(editor PRIVATE openblocks Qt6::Widgets Qt6::OpenGLWidgets ${QSCINTILLA_LIBRARY})
|
target_link_libraries(editor PRIVATE openblocks Qt6::Widgets Qt6::OpenGLWidgets ${QSCINTILLA_LIBRARY} miniaudio)
|
||||||
|
|
||||||
set_target_properties(editor PROPERTIES
|
set_target_properties(editor PROPERTIES
|
||||||
WIN32_EXECUTABLE ON
|
WIN32_EXECUTABLE ON
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
#include <QSurfaceFormat>
|
#include <QSurfaceFormat>
|
||||||
#include <qfont.h>
|
#include <qfont.h>
|
||||||
#include <qsurfaceformat.h>
|
#include <qsurfaceformat.h>
|
||||||
|
#include <miniaudio.h>
|
||||||
|
|
||||||
|
ma_engine miniaudio;
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
@ -23,10 +26,17 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
Logger::init();
|
Logger::init();
|
||||||
|
|
||||||
|
ma_result res = ma_engine_init(NULL, &miniaudio);
|
||||||
|
if (res != MA_SUCCESS) {
|
||||||
|
Logger::fatalErrorf("Failed to initialize Miniaudio withe error [%d]", res);
|
||||||
|
panic();
|
||||||
|
}
|
||||||
|
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
w.show();
|
w.show();
|
||||||
int result = a.exec();
|
int result = a.exec();
|
||||||
|
|
||||||
|
ma_engine_uninit(&miniaudio);
|
||||||
Logger::finish();
|
Logger::finish();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
#include <glm/common.hpp>
|
#include <glm/common.hpp>
|
||||||
#include <glm/vector_relational.hpp>
|
#include <glm/vector_relational.hpp>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <miniaudio.h>
|
||||||
#include <qnamespace.h>
|
#include <qnamespace.h>
|
||||||
#include <qsoundeffect.h>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "./ui_mainwindow.h"
|
#include "./ui_mainwindow.h"
|
||||||
#include "mainglwidget.h"
|
#include "mainglwidget.h"
|
||||||
|
@ -45,12 +45,10 @@ void MainGLWidget::initializeGL() {
|
||||||
renderInit(width(), height());
|
renderInit(width(), height());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern ma_engine miniaudio;
|
||||||
inline void playSound(QString path) {
|
inline void playSound(QString path) {
|
||||||
return; // TODO: Fix pulseaudio bug causing stutters
|
ma_engine_stop(&miniaudio);
|
||||||
QSoundEffect *sound = new QSoundEffect;
|
ma_engine_play_sound(&miniaudio, path.toStdString().c_str(), NULL);
|
||||||
sound->setSource(QUrl::fromLocalFile(path));
|
|
||||||
sound->play();
|
|
||||||
sound->connect(sound, &QSoundEffect::playingChanged, [=]() { /* Thank you QSound source code! */ sound->deleteLater(); return false; });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int vpx, vpy;
|
extern int vpx, vpy;
|
||||||
|
|
|
@ -20,13 +20,13 @@
|
||||||
#include <qmessagebox.h>
|
#include <qmessagebox.h>
|
||||||
#include <qmimedata.h>
|
#include <qmimedata.h>
|
||||||
#include <qnamespace.h>
|
#include <qnamespace.h>
|
||||||
#include <qsoundeffect.h>
|
|
||||||
#include <qstylefactory.h>
|
#include <qstylefactory.h>
|
||||||
#include <qstylehints.h>
|
#include <qstylehints.h>
|
||||||
#include <qmdisubwindow.h>
|
#include <qmdisubwindow.h>
|
||||||
#include <pugixml.hpp>
|
#include <pugixml.hpp>
|
||||||
#include <qtextcursor.h>
|
#include <qtextcursor.h>
|
||||||
#include <qtextedit.h>
|
#include <qtextedit.h>
|
||||||
|
#include <miniaudio.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#ifdef _NDEBUG
|
#ifdef _NDEBUG
|
||||||
|
@ -58,12 +58,9 @@ void logQtMessage(QtMsgType type, const QMessageLogContext &context, const QStri
|
||||||
// if (defaultMessageHandler) defaultMessageHandler(type, context, msg);
|
// if (defaultMessageHandler) defaultMessageHandler(type, context, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern ma_engine miniaudio;
|
||||||
inline void playSound(QString path) {
|
inline void playSound(QString path) {
|
||||||
return; // TODO: Fix pulseaudio bug causing stutters
|
ma_engine_play_sound(&miniaudio, path.toStdString().c_str(), NULL);
|
||||||
QSoundEffect *sound = new QSoundEffect;
|
|
||||||
sound->setSource(QUrl::fromLocalFile(path));
|
|
||||||
sound->play();
|
|
||||||
sound->connect(sound, &QSoundEffect::playingChanged, [=]() { /* Thank you QSound source code! */ sound->deleteLater(); return false; });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent)
|
MainWindow::MainWindow(QWidget *parent)
|
||||||
|
|
Loading…
Add table
Reference in a new issue