blob: 15874a04899aacfd9a54e454786d8e05fe2df9dd [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
Mikhail Naganov4f5d3f12022-07-22 23:23:25 +000017#include <cstdlib>
18#include <ctime>
19
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +000020#include "core-impl/Config.h"
21#include "core-impl/Module.h"
22
23#include <android-base/logging.h>
24#include <android/binder_manager.h>
25#include <android/binder_process.h>
26
27using aidl::android::hardware::audio::core::Config;
28using aidl::android::hardware::audio::core::Module;
29
30int main() {
Mikhail Naganov4f5d3f12022-07-22 23:23:25 +000031 // Random values are used in the implementation.
32 std::srand(std::time(nullptr));
33
Mikhail Naganov16db9b72022-06-17 21:36:18 +000034 // This is a debug implementation, always enable debug logging.
35 android::base::SetMinimumLogSeverity(::android::base::DEBUG);
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +000036 ABinderProcess_setThreadPoolMaxThreadCount(16);
37
Mikhail Naganov16db9b72022-06-17 21:36:18 +000038 // Make the default config service
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +000039 auto config = ndk::SharedRefBase::make<Config>();
40 const std::string configName = std::string() + Config::descriptor + "/default";
41 binder_status_t status =
42 AServiceManager_addService(config->asBinder().get(), configName.c_str());
Mikhail Naganov16db9b72022-06-17 21:36:18 +000043 CHECK_EQ(STATUS_OK, status);
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +000044
Mikhail Naganov16db9b72022-06-17 21:36:18 +000045 // Make the default module
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +000046 auto moduleDefault = ndk::SharedRefBase::make<Module>();
47 const std::string moduleDefaultName = std::string() + Module::descriptor + "/default";
48 status = AServiceManager_addService(moduleDefault->asBinder().get(), moduleDefaultName.c_str());
Mikhail Naganov16db9b72022-06-17 21:36:18 +000049 CHECK_EQ(STATUS_OK, status);
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +000050
51 ABinderProcess_joinThreadPool();
52 return EXIT_FAILURE; // should not reach
53}