Merge branch 'sfml'
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
This commit is contained in:
commit
2d16fb6af7
31 changed files with 1112 additions and 1296 deletions
155
src/main.cpp
155
src/main.cpp
|
@ -19,38 +19,25 @@
|
|||
*/
|
||||
|
||||
#include <QApplication>
|
||||
//#include <QMutex>
|
||||
//#include <QMutexLocker>
|
||||
#include "libremediaserver-audio.h"
|
||||
|
||||
// Handler for pipe the stderr to a log file
|
||||
|
||||
bool initMessageHandler = false;
|
||||
QFile outFile;
|
||||
|
||||
void MessageHandler(QtMsgType type, const char *msg)
|
||||
// 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)
|
||||
{
|
||||
QString txt;
|
||||
switch (type) {
|
||||
case QtDebugMsg:
|
||||
txt = QString("Debug: %1").arg(msg);
|
||||
break;
|
||||
case QtWarningMsg:
|
||||
txt = QString("Warning: %1").arg(msg);
|
||||
break;
|
||||
case QtCriticalMsg:
|
||||
txt = QString("Critical: %1").arg(msg);
|
||||
break;
|
||||
case QtFatalMsg:
|
||||
txt = QString("Fatal: %1").arg(msg);
|
||||
abort();
|
||||
}
|
||||
Q_UNUSED(context);
|
||||
// mutex.lock();
|
||||
// Create the log dir and log file
|
||||
if (!initMessageHandler)
|
||||
{
|
||||
if (!initMessageHandler) {
|
||||
QDir dir;
|
||||
if (!dir.exists("log"))
|
||||
{
|
||||
if (!dir.mkdir("log"))
|
||||
{
|
||||
if (!dir.exists("log")) {
|
||||
if (!dir.mkdir("log")) {
|
||||
qDebug()<<"MessageHandler: Can not create log folder";
|
||||
return;
|
||||
}
|
||||
|
@ -62,57 +49,127 @@ void MessageHandler(QtMsgType type, const char *msg)
|
|||
filename.append(date.toString("ddMMyy-"));
|
||||
filename.append(time.toString("hhmmss.txt"));
|
||||
outFile.setFileName(filename);
|
||||
if (!outFile.open(QIODevice::WriteOnly | QIODevice::Append))
|
||||
{
|
||||
qDebug()<<"main/MessageHandler/Qfile::open: can not open log file";
|
||||
if (!outFile.open(QIODevice::WriteOnly | QIODevice::Append)) {
|
||||
qWarning("main/MessageHandler/Qfile::open: can not open log file");
|
||||
return;
|
||||
}
|
||||
initMessageHandler = true;
|
||||
}
|
||||
QTextStream ts(&outFile);
|
||||
ts << txt << endl;
|
||||
}
|
||||
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") > 0)
|
||||
if (args.contains("-v"))
|
||||
{
|
||||
qDebug() << VERSION;
|
||||
qDebug() << COPYRIGHT;
|
||||
qDebug() << LICENSE;
|
||||
return 0;
|
||||
}
|
||||
if (args.contains("-h") > 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() << "-gui show the Pure Data GUI's";
|
||||
qDebug() << "-log write the debug information to a log file instead stderr";
|
||||
qDebug() << "-h this help";
|
||||
return 0;
|
||||
}
|
||||
if (args.contains("-log"))
|
||||
{
|
||||
qInstallMsgHandler(MessageHandler);
|
||||
}
|
||||
if (!args.contains("-gui"))
|
||||
{
|
||||
for (int i=1; i<args.size();i++)
|
||||
{
|
||||
qDebug() << "Option not known: " << args.at(i);
|
||||
}
|
||||
qDebug() <<"Write ./libremediaserver-audio -h for help in command line arguments";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
libreMediaServerAudio libreMediaServerAudio(args);
|
||||
libreMediaServerAudio.show();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue