blob: aeb9983b880bcb43a05ef79d791f552c48598e10 [file] [log] [blame]
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +00001/*
2 * Copyright (C) 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "core-impl/Config.h"
18#include "core-impl/Module.h"
19
20#include <android-base/logging.h>
21#include <android/binder_manager.h>
22#include <android/binder_process.h>
23
24using aidl::android::hardware::audio::core::Config;
25using aidl::android::hardware::audio::core::Module;
26
27int main() {
Mikhail Naganov16db9b72022-06-17 21:36:18 +000028 // This is a debug implementation, always enable debug logging.
29 android::base::SetMinimumLogSeverity(::android::base::DEBUG);
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +000030 ABinderProcess_setThreadPoolMaxThreadCount(16);
31
Mikhail Naganov16db9b72022-06-17 21:36:18 +000032 // Make the default config service
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +000033 auto config = ndk::SharedRefBase::make<Config>();
34 const std::string configName = std::string() + Config::descriptor + "/default";
35 binder_status_t status =
36 AServiceManager_addService(config->asBinder().get(), configName.c_str());
Mikhail Naganov16db9b72022-06-17 21:36:18 +000037 CHECK_EQ(STATUS_OK, status);
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +000038
Mikhail Naganov16db9b72022-06-17 21:36:18 +000039 // Make the default module
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +000040 auto moduleDefault = ndk::SharedRefBase::make<Module>();
41 const std::string moduleDefaultName = std::string() + Module::descriptor + "/default";
42 status = AServiceManager_addService(moduleDefault->asBinder().get(), moduleDefaultName.c_str());
Mikhail Naganov16db9b72022-06-17 21:36:18 +000043 CHECK_EQ(STATUS_OK, status);
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +000044
45 ABinderProcess_joinThreadPool();
46 return EXIT_FAILURE; // should not reach
47}