diff options
author | Rainer Keller <rainer.keller@digia.com> | 2013-10-17 16:02:00 +0200 |
---|---|---|
committer | Rainer Keller <rainer.keller@digia.com> | 2013-10-17 17:09:04 +0300 |
commit | 0693d097c487a2ec83e62d1e5a5bbd8e99bd31f4 (patch) | |
tree | 84a179d4709bc0a9de9759196a6396527d4c0e84 | |
parent | 5c15d009309c62646165e074ed49f86c073bf30b (diff) |
Add getter functions for audio levels
Change-Id: Icba2c03d946768b43503b167890e6d826e4fecc6
Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
-rw-r--r-- | src/utils/qdroidutils.cpp | 51 | ||||
-rw-r--r-- | src/utils/qdroidutils.h | 5 |
2 files changed, 56 insertions, 0 deletions
diff --git a/src/utils/qdroidutils.cpp b/src/utils/qdroidutils.cpp index 9a5d18d..4d05937 100644 --- a/src/utils/qdroidutils.cpp +++ b/src/utils/qdroidutils.cpp @@ -238,3 +238,54 @@ bool QDroidUtils::setHostname(QString hostname) #endif return true; } + +float QDroidUtils::masterVolume() const +{ + + qDebug() << android::AudioSystem::NUM_STREAM_TYPES; + + float volume = NAN; +#ifdef Q_OS_ANDROID_NO_SDK + android::status_t rc; + rc = android::AudioSystem::getMasterVolume(&volume); + if (rc != android::NO_ERROR) + qWarning() << Q_FUNC_INFO << "Error while getting audio properties."; +#endif + return volume; +} + +bool QDroidUtils::masterMute() const +{ + bool mute = false; +#ifdef Q_OS_ANDROID_NO_SDK + android::status_t rc; + rc = android::AudioSystem::getMasterMute(&mute); + if (rc != android::NO_ERROR) + qWarning() << Q_FUNC_INFO << "Error while getting audio properties."; +#endif + return mute; +} + +float QDroidUtils::streamVolume(AudioStreamType stream) const +{ + float volume = NAN; +#ifdef Q_OS_ANDROID_NO_SDK + android::status_t rc; + rc = android::AudioSystem::getStreamVolume(audio_stream_type_t(stream), &volume, 0); + if (rc != android::NO_ERROR) + qWarning() << Q_FUNC_INFO << "Error while getting audio properties."; +#endif + return volume; +} + +bool QDroidUtils::streamMute(AudioStreamType stream) const +{ + bool mute = false; +#ifdef Q_OS_ANDROID_NO_SDK + android::status_t rc; + rc = android::AudioSystem::getStreamMute(audio_stream_type_t(stream), &mute); + if (rc != android::NO_ERROR) + qWarning() << Q_FUNC_INFO << "Error while getting audio properties."; +#endif + return mute; +} diff --git a/src/utils/qdroidutils.h b/src/utils/qdroidutils.h index 7f37f70..339a529 100644 --- a/src/utils/qdroidutils.h +++ b/src/utils/qdroidutils.h @@ -41,6 +41,11 @@ public Q_SLOTS: void setStreamVolume(AudioStreamType stream, int volume); void setStreamMute(AudioStreamType stream, bool mute); + float masterVolume() const; + bool masterMute() const; + float streamVolume(AudioStreamType stream) const; + bool streamMute(AudioStreamType stream) const; + bool setDisplayBrightness(quint8 value); QString getIPAddress(); |