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
|
||||
set(LUAJIT_INCLUDE_DIRS ${LuaJIT_SOURCE_DIR}/src)
|
||||
|
||||
CPMAddPackage("gh:mackron/miniaudio#0.11.22")
|
||||
|
||||
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PREV_BIN_PATH})
|
|
@ -37,7 +37,7 @@ set(PROJECT_SOURCES
|
|||
|
||||
qt_add_executable(editor MANUAL_FINALIZATION ${PROJECT_SOURCES})
|
||||
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
|
||||
WIN32_EXECUTABLE ON
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
#include <QSurfaceFormat>
|
||||
#include <qfont.h>
|
||||
#include <qsurfaceformat.h>
|
||||
#include <miniaudio.h>
|
||||
|
||||
ma_engine miniaudio;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
@ -23,10 +26,17 @@ int main(int argc, char *argv[])
|
|||
|
||||
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;
|
||||
w.show();
|
||||
int result = a.exec();
|
||||
|
||||
ma_engine_uninit(&miniaudio);
|
||||
Logger::finish();
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
#include <glm/common.hpp>
|
||||
#include <glm/vector_relational.hpp>
|
||||
#include <memory>
|
||||
#include <miniaudio.h>
|
||||
#include <qnamespace.h>
|
||||
#include <qsoundeffect.h>
|
||||
#include <string>
|
||||
#include "./ui_mainwindow.h"
|
||||
#include "mainglwidget.h"
|
||||
|
@ -45,12 +45,10 @@ void MainGLWidget::initializeGL() {
|
|||
renderInit(width(), height());
|
||||
}
|
||||
|
||||
extern ma_engine miniaudio;
|
||||
inline void playSound(QString path) {
|
||||
return; // TODO: Fix pulseaudio bug causing stutters
|
||||
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; });
|
||||
ma_engine_stop(&miniaudio);
|
||||
ma_engine_play_sound(&miniaudio, path.toStdString().c_str(), NULL);
|
||||
}
|
||||
|
||||
extern int vpx, vpy;
|
||||
|
|
|
@ -20,13 +20,13 @@
|
|||
#include <qmessagebox.h>
|
||||
#include <qmimedata.h>
|
||||
#include <qnamespace.h>
|
||||
#include <qsoundeffect.h>
|
||||
#include <qstylefactory.h>
|
||||
#include <qstylehints.h>
|
||||
#include <qmdisubwindow.h>
|
||||
#include <pugixml.hpp>
|
||||
#include <qtextcursor.h>
|
||||
#include <qtextedit.h>
|
||||
#include <miniaudio.h>
|
||||
#include <vector>
|
||||
|
||||
#ifdef _NDEBUG
|
||||
|
@ -58,12 +58,9 @@ void logQtMessage(QtMsgType type, const QMessageLogContext &context, const QStri
|
|||
// if (defaultMessageHandler) defaultMessageHandler(type, context, msg);
|
||||
}
|
||||
|
||||
extern ma_engine miniaudio;
|
||||
inline void playSound(QString path) {
|
||||
return; // TODO: Fix pulseaudio bug causing stutters
|
||||
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; });
|
||||
ma_engine_play_sound(&miniaudio, path.toStdString().c_str(), NULL);
|
||||
}
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
|
|
Loading…
Add table
Reference in a new issue