blob: 121d5a9c2f5df2eb76c9d7dd4cd0ab3339b49828 [file] [log] [blame]
/**
* Copyright (C) 2018 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.
**/
#include <binder/IServiceManager.h>
#include <binder/Parcel.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <system/audio.h>
#include <utils/String16.h>
using namespace android;
enum {
SET_DEVICE_CONNECTION_STATE = IBinder::FIRST_CALL_TRANSACTION,
GET_DEVICE_CONNECTION_STATE,
HANDLE_DEVICE_CONFIG_CHANGE,
SET_PHONE_STATE,
SET_RINGER_MODE,
SET_FORCE_USE,
GET_FORCE_USE,
GET_OUTPUT,
START_OUTPUT,
STOP_OUTPUT,
RELEASE_OUTPUT,
GET_INPUT_FOR_ATTR,
START_INPUT,
STOP_INPUT,
RELEASE_INPUT,
INIT_STREAM_VOLUME,
SET_STREAM_VOLUME,
GET_STREAM_VOLUME,
GET_STRATEGY_FOR_STREAM,
GET_OUTPUT_FOR_EFFECT,
REGISTER_EFFECT,
UNREGISTER_EFFECT,
IS_STREAM_ACTIVE,
IS_SOURCE_ACTIVE,
GET_DEVICES_FOR_STREAM,
QUERY_DEFAULT_PRE_PROCESSING,
SET_EFFECT_ENABLED,
IS_STREAM_ACTIVE_REMOTELY,
IS_OFFLOAD_SUPPORTED,
LIST_AUDIO_PORTS,
GET_AUDIO_PORT,
CREATE_AUDIO_PATCH,
RELEASE_AUDIO_PATCH,
LIST_AUDIO_PATCHES,
SET_AUDIO_PORT_CONFIG,
REGISTER_CLIENT,
GET_OUTPUT_FOR_ATTR,
ACQUIRE_SOUNDTRIGGER_SESSION,
RELEASE_SOUNDTRIGGER_SESSION,
GET_PHONE_STATE,
REGISTER_POLICY_MIXES,
START_AUDIO_SOURCE,
STOP_AUDIO_SOURCE,
SET_AUDIO_PORT_CALLBACK_ENABLED,
SET_MASTER_MONO,
GET_MASTER_MONO,
};
int getOutputForAttr() {
sp<IServiceManager> sm = defaultServiceManager();
sp<IBinder> binder = sm->getService(String16("media.audio_policy"));
Parcel data, reply;
data.writeInterfaceToken(String16("android.media.IAudioPolicyService"));
data.writeInt32(1);
audio_attributes_t attr;
memset(&attr, 0xff, sizeof(attr));
attr.flags = 0;
memset(attr.tags, 0x41, AUDIO_ATTRIBUTES_TAGS_MAX_SIZE);
data.write(&attr, sizeof(attr));
binder->transact(GET_OUTPUT_FOR_ATTR, data, &reply, 0);
return 0;
}
int main() {
getOutputForAttr();
return 0;
}