summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/audiomanager/AudioManager.h42
-rw-r--r--include/audiomanager/IAudioManager.h127
-rw-r--r--services/audiomanager/Android.bp18
-rw-r--r--services/audiomanager/IAudioManager.cpp103
4 files changed, 290 insertions, 0 deletions
diff --git a/include/audiomanager/AudioManager.h b/include/audiomanager/AudioManager.h
new file mode 100644
index 0000000000..d561594758
--- /dev/null
+++ b/include/audiomanager/AudioManager.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_AUDIOMANAGER_H
+#define ANDROID_AUDIOMANAGER_H
+
+namespace android {
+
+// must be kept in sync with definitions in AudioPlaybackConfiguration.java
+
+#define PLAYER_PIID_INVALID -1
+
+enum {
+ PLAYER_TYPE_SLES_AUDIOPLAYER_BUFFERQUEUE = 11,
+ PLAYER_TYPE_SLES_AUDIOPLAYER_URI_FD = 12,
+};
+
+enum {
+ PLAYER_STATE_UNKNOWN = -1,
+ PLAYER_STATE_RELEASED = 0,
+ PLAYER_STATE_IDLE = 1,
+ PLAYER_STATE_STARTED = 2,
+ PLAYER_STATE_PAUSED = 3,
+ PLAYER_STATE_STOPPED = 4,
+};
+
+}; // namespace android
+
+#endif // ANDROID_AUDIOMANAGER_H
diff --git a/include/audiomanager/IAudioManager.h b/include/audiomanager/IAudioManager.h
new file mode 100644
index 0000000000..f5ea259cce
--- /dev/null
+++ b/include/audiomanager/IAudioManager.h
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_IAUDIOMANAGER_H
+#define ANDROID_IAUDIOMANAGER_H
+
+#include <utils/Errors.h>
+#include <binder/IInterface.h>
+#include <hardware/power.h>
+#include <system/audio.h>
+
+namespace android {
+
+// ----------------------------------------------------------------------------
+
+class IAudioManager : public IInterface
+{
+public:
+ // These transaction IDs must be kept in sync with the method order from
+ // IAudioService.aidl.
+ enum {
+ // transaction IDs for the unsupported methods are commented out
+ /*
+ ADJUSTSUGGESTEDSTREAMVOLUME = IBinder::FIRST_CALL_TRANSACTION,
+ ADJUSTSTREAMVOLUME = IBinder::FIRST_CALL_TRANSACTION + 1,
+ SETSTREAMVOLUME = IBinder::FIRST_CALL_TRANSACTION + 2,
+ ISSTREAMMUTE = IBinder::FIRST_CALL_TRANSACTION + 3,
+ FORCEREMOTESUBMIXFULLVOLUME = IBinder::FIRST_CALL_TRANSACTION + 4,
+ ISMASTERMUTE = IBinder::FIRST_CALL_TRANSACTION + 5,
+ SETMASTERMUTE = IBinder::FIRST_CALL_TRANSACTION + 6,
+ GETSTREAMVOLUME = IBinder::FIRST_CALL_TRANSACTION + 7,
+ GETSTREAMMINVOLUME = IBinder::FIRST_CALL_TRANSACTION + 8,
+ GETSTREAMMAXVOLUME = IBinder::FIRST_CALL_TRANSACTION + 9,
+ GETLASTAUDIBLESTREAMVOLUME = IBinder::FIRST_CALL_TRANSACTION + 10,
+ SETMICROPHONEMUTE = IBinder::FIRST_CALL_TRANSACTION + 11,
+ SETRINGERMODEEXTERNAL = IBinder::FIRST_CALL_TRANSACTION + 12,
+ SETRINGERMODEINTERNAL = IBinder::FIRST_CALL_TRANSACTION + 13,
+ GETRINGERMODEEXTERNAL = IBinder::FIRST_CALL_TRANSACTION + 14,
+ GETRINGERMODEINTERNAL = IBinder::FIRST_CALL_TRANSACTION + 15,
+ ISVALIDRINGERMODE = IBinder::FIRST_CALL_TRANSACTION + 16,
+ SETVIBRATESETTING = IBinder::FIRST_CALL_TRANSACTION + 17,
+ GETVIBRATESETTING = IBinder::FIRST_CALL_TRANSACTION + 18,
+ SHOULDVIBRATE = IBinder::FIRST_CALL_TRANSACTION + 19,
+ SETMODE = IBinder::FIRST_CALL_TRANSACTION + 20,
+ GETMODE = IBinder::FIRST_CALL_TRANSACTION + 21,
+ PLAYSOUNDEFFECT = IBinder::FIRST_CALL_TRANSACTION + 22,
+ PLAYSOUNDEFFECTVOLUME = IBinder::FIRST_CALL_TRANSACTION + 23,
+ LOADSOUNDEFFECTS = IBinder::FIRST_CALL_TRANSACTION + 24,
+ UNLOADSOUNDEFFECTS = IBinder::FIRST_CALL_TRANSACTION + 25,
+ RELOADAUDIOSETTINGS = IBinder::FIRST_CALL_TRANSACTION + 26,
+ AVRCPSUPPORTSABSOLUTEVOLUME = IBinder::FIRST_CALL_TRANSACTION + 27,
+ SETSPEAKERPHONEON = IBinder::FIRST_CALL_TRANSACTION + 28,
+ ISSPEAKERPHONEON = IBinder::FIRST_CALL_TRANSACTION + 29,
+ SETBLUETOOTHSCOON = IBinder::FIRST_CALL_TRANSACTION + 30,
+ ISBLUETOOTHSCOON = IBinder::FIRST_CALL_TRANSACTION + 31,
+ SETBLUETOOTHA2DPON = IBinder::FIRST_CALL_TRANSACTION + 32,
+ ISBLUETOOTHA2DPON = IBinder::FIRST_CALL_TRANSACTION + 33,
+ REQUESTAUDIOFOCUS = IBinder::FIRST_CALL_TRANSACTION + 34,
+ ABANDONAUDIOFOCUS = IBinder::FIRST_CALL_TRANSACTION + 35,
+ UNREGISTERAUDIOFOCUSCLIENT = IBinder::FIRST_CALL_TRANSACTION + 36,
+ GETCURRENTAUDIOFOCUS = IBinder::FIRST_CALL_TRANSACTION + 37,
+ STARTBLUETOOTHSCO = IBinder::FIRST_CALL_TRANSACTION + 38,
+ STARTBLUETOOTHSCOVIRTUALCALL = IBinder::FIRST_CALL_TRANSACTION + 39,
+ STOPBLUETOOTHSCO = IBinder::FIRST_CALL_TRANSACTION + 40,
+ FORCEVOLUMECONTROLSTREAM = IBinder::FIRST_CALL_TRANSACTION + 41,
+ SETRINGTONEPLAYER = IBinder::FIRST_CALL_TRANSACTION + 42,
+ GETRINGTONEPLAYER = IBinder::FIRST_CALL_TRANSACTION + 43,
+ GETUISOUNDSSTREAMTYPE = IBinder::FIRST_CALL_TRANSACTION + 44,
+ SETWIREDDEVICECONNECTIONSTATE = IBinder::FIRST_CALL_TRANSACTION + 45,
+ SETBLUETOOTHA2DPDEVICECONNECTIONSTATE = IBinder::FIRST_CALL_TRANSACTION + 46,
+ HANDLEBLUETOOTHA2DPDEVICECONFIGCHANGE = IBinder::FIRST_CALL_TRANSACTION + 47,
+ STARTWATCHINGROUTES = IBinder::FIRST_CALL_TRANSACTION + 48,
+ ISCAMERASOUNDFORCED = IBinder::FIRST_CALL_TRANSACTION + 49,
+ SETVOLUMECONTROLLER = IBinder::FIRST_CALL_TRANSACTION + 50,
+ NOTIFYVOLUMECONTROLLERVISIBLE = IBinder::FIRST_CALL_TRANSACTION + 51,
+ ISSTREAMAFFECTEDBYRINGERMODE = IBinder::FIRST_CALL_TRANSACTION + 52,
+ ISSTREAMAFFECTEDBYMUTE = IBinder::FIRST_CALL_TRANSACTION + 53,
+ DISABLESAFEMEDIAVOLUME = IBinder::FIRST_CALL_TRANSACTION + 54,
+ SETHDMISYSTEMAUDIOSUPPORTED = IBinder::FIRST_CALL_TRANSACTION + 55,
+ ISHDMISYSTEMAUDIOSUPPORTED = IBinder::FIRST_CALL_TRANSACTION + 56,
+ REGISTERAUDIOPOLICY = IBinder::FIRST_CALL_TRANSACTION + 57,
+ UNREGISTERAUDIOPOLICYASYNC = IBinder::FIRST_CALL_TRANSACTION + 58,
+ SETFOCUSPROPERTIESFORPOLICY = IBinder::FIRST_CALL_TRANSACTION + 59,
+ SETVOLUMEPOLICY = IBinder::FIRST_CALL_TRANSACTION + 60,
+ REGISTERRECORDINGCALLBACK = IBinder::FIRST_CALL_TRANSACTION + 61,
+ UNREGISTERRECORDINGCALLBACK = IBinder::FIRST_CALL_TRANSACTION + 62,
+ GETACTIVERECORDINGCONFIGURATIONS = IBinder::FIRST_CALL_TRANSACTION + 63,
+ REGISTERPLAYBACKCALLBACK = IBinder::FIRST_CALL_TRANSACTION + 64,
+ UNREGISTERPLAYBACKCALLBACK = IBinder::FIRST_CALL_TRANSACTION + 65,
+ GETACTIVEPLAYBACKCONFIGURATIONS = IBinder::FIRST_CALL_TRANSACTION + 66,
+ */
+
+ TRACK_PLAYER = IBinder::FIRST_CALL_TRANSACTION + 67,
+ PLAYER_ATTRIBUTES = IBinder::FIRST_CALL_TRANSACTION + 68,
+ PLAYER_EVENT = IBinder::FIRST_CALL_TRANSACTION + 69,
+ RELEASE_PLAYER = IBinder::FIRST_CALL_TRANSACTION + 70,
+
+ };
+
+ DECLARE_META_INTERFACE(AudioManager)
+
+ // The parcels created by these methods must be kept in sync with the
+ // corresponding methods from IAudioService.aidl and objects it imports.
+ virtual audio_unique_id_t trackPlayer(int playerType, int usage, int content) = 0;
+ /*oneway*/ virtual status_t playerAttributes(audio_unique_id_t piid, int usage, int content)= 0;
+ /*oneway*/ virtual status_t playerEvent(int piid, int event) = 0;
+ /*oneway*/ virtual status_t releasePlayer(int piid) = 0;
+};
+
+// ----------------------------------------------------------------------------
+
+}; // namespace android
+
+#endif // ANDROID_IAUDIOMANAGER_H
diff --git a/services/audiomanager/Android.bp b/services/audiomanager/Android.bp
new file mode 100644
index 0000000000..04dd9670cd
--- /dev/null
+++ b/services/audiomanager/Android.bp
@@ -0,0 +1,18 @@
+cc_library_shared {
+ name: "libaudiomanager",
+
+ srcs: ["IAudioManager.cpp"],
+
+ shared_libs: [
+ "libutils",
+ "libbinder",
+ "liblog",
+ ],
+
+ cflags: [
+ "-Wall",
+ "-Werror",
+ "-Wunused",
+ "-Wunreachable-code",
+ ],
+}
diff --git a/services/audiomanager/IAudioManager.cpp b/services/audiomanager/IAudioManager.cpp
new file mode 100644
index 0000000000..a41804f281
--- /dev/null
+++ b/services/audiomanager/IAudioManager.cpp
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "IAudioManager"
+//#define LOG_NDEBUG 0
+#include <utils/Log.h>
+
+#include <stdint.h>
+#include <sys/types.h>
+
+#include <binder/Parcel.h>
+#include <audiomanager/AudioManager.h>
+#include <audiomanager/IAudioManager.h>
+
+namespace android {
+
+class BpAudioManager : public BpInterface<IAudioManager>
+{
+public:
+ explicit BpAudioManager(const sp<IBinder>& impl)
+ : BpInterface<IAudioManager>(impl)
+ {
+ }
+
+ virtual audio_unique_id_t trackPlayer(int playerType, int usage, int content) {
+ Parcel data, reply;
+ data.writeInterfaceToken(IAudioManager::getInterfaceDescriptor());
+ data.writeInt32(1); // non-null PlayerIdCard parcelable
+ // marshall PlayerIdCard data
+ data.writeInt32((int32_t) playerType);
+ // write attributes of PlayerIdCard
+ data.writeInt32(usage);
+ data.writeInt32(content);
+ data.writeInt32(0 /*source: none here, this is a player*/);
+ data.writeInt32(0 /*flags*/);
+ // write attributes' tags
+ data.writeInt32(1 /*FLATTEN_TAGS*/);
+ data.writeString16(String16("")); // no tags
+ // write attributes' bundle
+ data.writeInt32(-1977 /*ATTR_PARCEL_IS_NULL_BUNDLE*/); // no bundle
+ // get new PIId in reply
+ const status_t res = remote()->transact(TRACK_PLAYER, data, &reply, 0);
+ if (res != OK || reply.readExceptionCode() != 0) {
+ ALOGE("trackPlayer() failed, piid is %d", PLAYER_PIID_INVALID);
+ return PLAYER_PIID_INVALID;
+ } else {
+ const audio_unique_id_t piid = (audio_unique_id_t) reply.readInt32();
+ ALOGV("trackPlayer() returned piid %d", piid);
+ return piid;
+ }
+ }
+
+ virtual status_t playerAttributes(audio_unique_id_t piid, int usage, int content) {
+ Parcel data, reply;
+ data.writeInterfaceToken(IAudioManager::getInterfaceDescriptor());
+ data.writeInt32(piid);
+ data.writeInt32(1); // non-null AudioAttributes parcelable
+ data.writeInt32(usage);
+ data.writeInt32(content);
+ data.writeInt32(0 /*source: none here, this is a player*/);
+ data.writeInt32(0 /*flags*/);
+ // write attributes' tags
+ data.writeInt32(1 /*FLATTEN_TAGS*/);
+ data.writeString16(String16("")); // no tags
+ // write attributes' bundle
+ data.writeInt32(-1977 /*ATTR_PARCEL_IS_NULL_BUNDLE*/); // no bundle
+ return remote()->transact(PLAYER_ATTRIBUTES, data, &reply, IBinder::FLAG_ONEWAY);
+ }
+
+ virtual status_t playerEvent(int piid, int event) {
+ Parcel data, reply;
+ data.writeInterfaceToken(IAudioManager::getInterfaceDescriptor());
+ data.writeInt32(piid);
+ data.writeInt32(event);
+ return remote()->transact(PLAYER_EVENT, data, &reply, IBinder::FLAG_ONEWAY);
+ }
+
+ virtual status_t releasePlayer(int piid) {
+ Parcel data, reply;
+ data.writeInterfaceToken(IAudioManager::getInterfaceDescriptor());
+ data.writeInt32(piid);
+ return remote()->transact(RELEASE_PLAYER, data, &reply, IBinder::FLAG_ONEWAY);
+ }
+};
+
+IMPLEMENT_META_INTERFACE(AudioManager, "android.media.IAudioService");
+
+// ----------------------------------------------------------------------------
+
+}; // namespace android