From 0693d097c487a2ec83e62d1e5a5bbd8e99bd31f4 Mon Sep 17 00:00:00 2001 From: Rainer Keller Date: Thu, 17 Oct 2013 16:02:00 +0200 Subject: Add getter functions for audio levels Change-Id: Icba2c03d946768b43503b167890e6d826e4fecc6 Reviewed-by: Yoann Lopes --- src/utils/qdroidutils.cpp | 51 +++++++++++++++++++++++++++++++++++++++++++++++ src/utils/qdroidutils.h | 5 +++++ 2 files changed, 56 insertions(+) (limited to 'src/utils') 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(); -- cgit v1.2.3