Added Singleton to AudioWidget Conflicts: lms-audio.xlm puredata/layer_audio.pd src/audiolayerwidget.cpp src/audiolayerwidget.h src/audiomasterwidget.cpp src/audiomasterwidget.h src/audiomotor.cpp src/audiomotor.h src/audiowidget.cpp src/defines.h src/libremediaserver-audio.cpp src/libremediaserver-audio.h src/libremediaserver-audio.pro src/libremediaserver-audio.ui src/medialibrary.cpp src/medialibrary.h src/olathread.cpp src/olathread.h src/settings.cpp src/settings.h
179 lines
6.2 KiB
C++
Executable file
179 lines
6.2 KiB
C++
Executable file
/*
|
|
Libre Media Server - A media server for audio playback in stage arts
|
|
controlled by lingting protocols (DMX, ArtNet, ACN,...)
|
|
|
|
Copyright (C) 2015 Santiago Noreña libremediaserver@gmail.com
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include <QApplication>
|
|
//#include <QMutex>
|
|
//#include <QMutexLocker>
|
|
#include "libremediaserver-audio.h"
|
|
|
|
// Handler for pipe the stderr to a log file and texEdit
|
|
//bool initMessageHandler = false;
|
|
//QFile outFile;
|
|
//QMutex mutex;
|
|
//QMutexLocker mutexLocker(mutex);
|
|
/*
|
|
void MessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
|
{
|
|
Q_UNUSED(context);
|
|
// mutex.lock();
|
|
// Create the log dir and log file
|
|
if (!initMessageHandler) {
|
|
QDir dir;
|
|
if (!dir.exists("log")) {
|
|
if (!dir.mkdir("log")) {
|
|
qDebug()<<"MessageHandler: Can not create log folder";
|
|
return;
|
|
}
|
|
}
|
|
QString filename;
|
|
QDate date = QDate::currentDate();
|
|
QTime time = QTime::currentTime();
|
|
filename.append("./log/log_");
|
|
filename.append(date.toString("ddMMyy-"));
|
|
filename.append(time.toString("hhmmss.txt"));
|
|
outFile.setFileName(filename);
|
|
if (!outFile.open(QIODevice::WriteOnly | QIODevice::Append)) {
|
|
qWarning("main/MessageHandler/Qfile::open: can not open log file");
|
|
return;
|
|
}
|
|
initMessageHandler = true;
|
|
}
|
|
QTextStream ts(&outFile);*/
|
|
/* if (libreMediaServerAudio::textEdit == 0)
|
|
{
|
|
QByteArray localMsg = msg.toLocal8Bit();
|
|
switch (type) {
|
|
case QtDebugMsg:
|
|
fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
|
break;
|
|
case QtWarningMsg:
|
|
fprintf(stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
|
break;
|
|
case QtCriticalMsg:
|
|
fprintf(stderr, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
|
break;
|
|
case QtFatalMsg:
|
|
fprintf(stderr, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
|
abort();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
QString txt;
|
|
switch (type) {
|
|
case QtDebugMsg:
|
|
txt.append("Debug from File: ");
|
|
txt.append(context.file);
|
|
txt.append(" Line: ");
|
|
txt.append(QString::number(context.line));
|
|
// txt.append(" Function: ");
|
|
// txt.append(context.function);
|
|
txt.append(" Message: ");
|
|
txt.append(msg);
|
|
// libreMediaServerAudio::textEdit->append(msg);, context.file, context.line, context.function);
|
|
libreMediaServerAudio::textEdit->append(txt);
|
|
break;
|
|
case QtWarningMsg:
|
|
txt.append("Warning from File: ");
|
|
txt.append(context.file);
|
|
txt.append(" Line: ");
|
|
txt.append(QString::number(context.line));
|
|
txt.append(" Function: ");
|
|
txt.append(context.function);
|
|
txt.append(" Message: ");
|
|
txt.append(msg);
|
|
// libreMediaServerAudio::textEdit->append(msg);, context.file, context.line, context.function);
|
|
libreMediaServerAudio::textEdit->append(txt);
|
|
abort();
|
|
break;
|
|
case QtCriticalMsg:
|
|
// txt.append("Critical from File: ");
|
|
txt.append(context.file);
|
|
txt.append(" Line: ");
|
|
txt.append(QString::number(context.line));
|
|
txt.append(" Function: ");
|
|
txt.append(context.function);
|
|
txt.append(" Message ");
|
|
txt.append(msg);
|
|
// libreMediaServerAudio::textEdit->append(msg);, context.file, context.line, context.function);
|
|
libreMediaServerAudio::textEdit->append(txt);
|
|
abort();
|
|
break;
|
|
case QtFatalMsg:
|
|
// txt.append("Fatal from File: ");
|
|
txt.append(context.file);
|
|
txt.append(" Line: ");
|
|
txt.append(QString::number(context.line));
|
|
txt.append(" Function: ");
|
|
txt.append(context.function);
|
|
txt.append(" Message: ");
|
|
txt.append(msg);
|
|
// libreMediaServerAudio::textEdit->append(msg);, context.file, context.line, context.function);
|
|
libreMediaServerAudio::textEdit->append(txt);// ts << txt << endl;
|
|
abort();
|
|
}
|
|
// outFile.write(txt.toLatin1().constData(), txt.size());
|
|
// ts << txt << endl;
|
|
// libreMediaServerAudio::textEdit->append(txt);
|
|
}
|
|
// mutex.unlock();
|
|
}*/
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
|
|
// ToDo: discriminar niveles de log y log a fichero segúna argumentos
|
|
/*
|
|
if (args.contains("-log"))
|
|
{
|
|
qInstallMessageHandler(MessageHandler);
|
|
}*/
|
|
// qInstallMessageHandler(MessageHandler);
|
|
QApplication app(argc, argv);
|
|
|
|
QStringList args = app.arguments();
|
|
// parse the command line
|
|
if (args.size() > 1)
|
|
{
|
|
if (args.contains("-v"))
|
|
{
|
|
qDebug() << VERSION;
|
|
qDebug() << COPYRIGHT;
|
|
qDebug() << LICENSE;
|
|
return 0;
|
|
}
|
|
if (args.contains("-h"))
|
|
{
|
|
qDebug() << VERSION;
|
|
qDebug() << COPYRIGHT;
|
|
qDebug() << LICENSE;
|
|
qDebug() << "Help for command line options:";
|
|
qDebug() << "-v show the version and exits";
|
|
qDebug() << "-log write the debug information to a log file instead stderr";
|
|
qDebug() << "-h this help";
|
|
return 0;
|
|
}
|
|
}
|
|
libreMediaServerAudio libreMediaServerAudio(args);
|
|
libreMediaServerAudio.show();
|
|
return app.exec();
|
|
}
|
|
|
|
|