summaryrefslogtreecommitdiff
path: root/AudioManagerPoC/business_logic/src/main.cpp
diff options
context:
space:
mode:
authorAdrian Scarlat <adrian.scarlat@windriver.com>2015-02-04 11:47:48 +0100
committerJames Thomas <james.thomas@codethink.co.uk>2015-04-07 14:42:08 +0000
commit849d751ba71d038b3428b6337bb2ba0e42b666d5 (patch)
tree8f2f3c704faab53e2b4db2e4eb75a2a51b69d438 /AudioManagerPoC/business_logic/src/main.cpp
parent00caae1e41e8891d9a1bafa76028e8119f06fd8a (diff)
downloadaudiomanager-849d751ba71d038b3428b6337bb2ba0e42b666d5.tar.gz
AudioManagerPoC: GENIVI Alliance Audio Manager proof-of-concept
The Audio Manager Proof of Concept (AM PoC) is an application that uses the GENIVI AudioManager capabilities to demonstrate how audio sources are managed based on mixing rules that are defined in the configuration file for AM Control Plugin "libPluginControlInterface.conf". For a details description please consult the "libPluginControlInterface.conf", "libPluginRoutingInterfacePulse.conf" and AudioManager documentation. This AudioManager PoC is based on AM ver 3.0 and Qt 5. It will be a simple application that will demonstrate a few of the AM capabilities: 1. source playing; 2. volume changing; 3. source switching based on source priorities; 4. automatic volume handeling based on source priorities. Signed-off-by: Adrian Scarlat <adrian.scarlat@windriver.com> Signed-off-by: Holger Behrens <holger.behrens@windriver.com>
Diffstat (limited to 'AudioManagerPoC/business_logic/src/main.cpp')
-rw-r--r--AudioManagerPoC/business_logic/src/main.cpp87
1 files changed, 87 insertions, 0 deletions
diff --git a/AudioManagerPoC/business_logic/src/main.cpp b/AudioManagerPoC/business_logic/src/main.cpp
new file mode 100644
index 0000000..3bdd518
--- /dev/null
+++ b/AudioManagerPoC/business_logic/src/main.cpp
@@ -0,0 +1,87 @@
+/**
+ * SPDX license identifier: MPL-2.0
+ *
+ * Copyright (C) 2011-2014, Wind River Systems
+ * Copyright (C) 2014, GENIVI Alliance
+ *
+ * This file is part of GENIVI AudioManager PoC.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License (MPL), v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * For further information see http://www.genivi.org/.
+ *
+ * List of changes:
+ *
+ * 21.09.2014, Adrian Scarlat, First version of the code;
+ * Added Copyright and License information;
+ *
+ * 28.11.2014, Adrian Scarlat, Added code to allow only one instance of
+ * AM PoC to run; This was achieved by creating
+ * a file in /var/run and placing an advisory
+ * lock on it, using flock(). When another
+ * instance is created, it can't create the advisory
+ * lock on the same file since the first instance
+ * owns it and it will quit with an appropriate
+ * message.
+ */
+
+#include <QApplication>
+#include <QQuickView>
+#include <QQmlContext>
+#include <QDebug>
+#include <QGraphicsObject>
+#include <QTimer>
+#include <QQmlEngine>
+#include <QQuickItem>
+
+#include <sys/file.h>
+#include <errno.h>
+
+#include "business_logic/include/qmlbuttoneventsreceiver.h"
+#include "business_logic/include/volumechart.h"
+#include "business_logic/include/audioManagerInterface.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ int pid_file = open("/var/run/AudioManager_PoC.pid", O_CREAT | O_RDWR, 0666);
+ if(pid_file != -1)
+ {
+ int rc = flock(pid_file, LOCK_EX | LOCK_NB);
+ if(rc)
+ {
+ if(EWOULDBLOCK == errno)
+ {
+ qDebug() << "Only one instance of AudioManager_PoC is allowed. Quitting!";
+ return 0;
+ }
+ }
+ else
+ {
+ QQuickView view;
+ QMLButtonEventsReceiver rec(&view);
+ view.rootContext()->setContextProperty("QMLButtonEventsReceiver", &rec);
+ view.engine()->addImageProvider(QLatin1String("volumes"), new volumechart());
+ view.setSource(QUrl("qrc:/presentation_layer/main.qml"));
+ view.showMaximized();
+
+ qDebug() << "Show maximized";
+
+ QTimer *timer = new QTimer(&rec);
+ QObject::connect(timer, SIGNAL(timeout()), &rec, SLOT(slotRefreshInfo()));
+ timer->start(500);
+
+ QObject *sliderVolume = view.rootObject()->findChild<QObject*>("sliderVolume");
+ sliderVolume->setProperty("value", 100.0);
+
+ return app.exec();
+ }
+ }
+ else
+ {
+ qDebug() << "Couldn't create /var/run/AudioManager_PoC.pid file.";
+ return 0;
+ }
+}