From 663c9851fe367e8c2bdf8bc37e64b9e1668e3fe2 Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Mon, 21 Oct 2013 19:02:31 +0200 Subject: Fix sound on Nexus 7. A behavior change in the HW audio driver for 4.2.2 causes the audio routing to never be set up automatically. Set the audio orientation to force the HW driver to set up audio routing. Task-number: QTRD-2472 Change-Id: I6f76aa299d0bc89c7061c7074dc5780e62045f0a Reviewed-by: Eirik Aavitsland --- src/utils/qdroidutils.cpp | 22 ++++++++++++++++++++++ src/utils/qdroidutils.h | 9 +++++++++ src/utils/utils.pro | 2 +- 3 files changed, 32 insertions(+), 1 deletion(-) (limited to 'src/utils') diff --git a/src/utils/qdroidutils.cpp b/src/utils/qdroidutils.cpp index f2194c4..da443c9 100644 --- a/src/utils/qdroidutils.cpp +++ b/src/utils/qdroidutils.cpp @@ -45,6 +45,28 @@ void QDroidUtils::powerOffSystem() qWarning("powerOff returned"); } +void QDroidUtils::setOrientationForAudioSystem(AudioOrientation orientation) +{ +#ifdef Q_OS_ANDROID_NO_SDK + QString orientationString = QStringLiteral("undefined"); + switch (orientation) { + case LandscapeAudioOrientation: + orientationString = QStringLiteral("landscape"); + break; + case PortraitAudioOrientation: + orientationString = QStringLiteral("portrait"); + break; + case SquareAudioOrientation: + orientationString = QStringLiteral("square"); + break; + default: + break; + } + android::AudioSystem::setParameters(0, android::String8(QStringLiteral("orientation=%2") + .arg(orientationString).toLatin1().constData())); +#endif +} + /*! * Sets the master volume to \a volume. * The volume can range from 0 to 100 and is linear. diff --git a/src/utils/qdroidutils.h b/src/utils/qdroidutils.h index 339a529..b0f9061 100644 --- a/src/utils/qdroidutils.h +++ b/src/utils/qdroidutils.h @@ -8,6 +8,13 @@ class Q_DECL_EXPORT QDroidUtils : public QObject Q_OBJECT Q_ENUMS(AudioStreamType) public: + enum AudioOrientation { + LandscapeAudioOrientation, + PortraitAudioOrientation, + SquareAudioOrientation, + UndefinedAudioOrientation, + }; + enum AudioStreamType { DefaultAudioStream = -1, VoiceCallAudioStream = 0, @@ -36,6 +43,8 @@ public Q_SLOTS: void rebootSystem(); void powerOffSystem(); + void setOrientationForAudioSystem(AudioOrientation orientation); + void setMasterVolume(int volume); void setMasterMute(bool mute); void setStreamVolume(AudioStreamType stream, int volume); diff --git a/src/utils/utils.pro b/src/utils/utils.pro index 5711337..a15231f 100644 --- a/src/utils/utils.pro +++ b/src/utils/utils.pro @@ -11,7 +11,7 @@ QT = core network MODULE = droidutils load(qt_module) -android: LIBS += -lmedia -lhardware -lcutils +android: LIBS += -lmedia -lhardware -lcutils -lutils HEADERS += \ $$PWD/qdroidutils.h -- cgit v1.2.3 From c03fcde202a0dea22e753b3a380081415861d9da Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Fri, 22 Nov 2013 12:04:18 +0100 Subject: Add license headers Add an Enterprise License header to source files. Change-Id: I373886dade31ce00d4c10c64ebaf8ba226d5a62d Reviewed-by: Eirik Aavitsland --- src/utils/qdroidutils.cpp | 18 ++++++++++++++++++ src/utils/qdroidutils.h | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) (limited to 'src/utils') diff --git a/src/utils/qdroidutils.cpp b/src/utils/qdroidutils.cpp index da443c9..2a9c94c 100644 --- a/src/utils/qdroidutils.cpp +++ b/src/utils/qdroidutils.cpp @@ -1,3 +1,21 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc +** All rights reserved. +** For any questions to Digia, please use the contact form at +** http://qt.digia.com/ +** +** This file is part of Qt Enterprise Embedded. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** the contact form at http://qt.digia.com/ +** +****************************************************************************/ #include "qdroidutils.h" #include #include diff --git a/src/utils/qdroidutils.h b/src/utils/qdroidutils.h index b0f9061..9d833bb 100644 --- a/src/utils/qdroidutils.h +++ b/src/utils/qdroidutils.h @@ -1,3 +1,21 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc +** All rights reserved. +** For any questions to Digia, please use the contact form at +** http://qt.digia.com/ +** +** This file is part of Qt Enterprise Embedded. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** the contact form at http://qt.digia.com/ +** +****************************************************************************/ #ifndef QDROIDUTILS_H #define QDROIDUTILS_H -- cgit v1.2.3