diff options
Diffstat (limited to 'cros_gralloc/aidl/Main.cpp')
-rw-r--r-- | cros_gralloc/aidl/Main.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/cros_gralloc/aidl/Main.cpp b/cros_gralloc/aidl/Main.cpp new file mode 100644 index 0000000..c2c4c5c --- /dev/null +++ b/cros_gralloc/aidl/Main.cpp @@ -0,0 +1,44 @@ +/* + * Copyright 2022 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "Allocator.h" + +#include <android-base/logging.h> +#include <android/binder_manager.h> +#include <android/binder_process.h> +#include <log/log.h> + +using aidl::android::hardware::graphics::allocator::impl::Allocator; + +int main(int /*argc*/, char** /*argv*/) { + ALOGI("Minigbm AIDL allocator starting up..."); + + // same as SF main thread + struct sched_param param = {0}; + param.sched_priority = 2; + if (sched_setscheduler(0, SCHED_FIFO | SCHED_RESET_ON_FORK, ¶m) != 0) { + ALOGI("%s: failed to set priority: %s", __FUNCTION__, strerror(errno)); + } + + auto allocator = ndk::SharedRefBase::make<Allocator>(); + CHECK(allocator != nullptr); + + if (!allocator->init()) { + ALOGE("Failed to initialize Minigbm AIDL allocator."); + return EXIT_FAILURE; + } + + const std::string instance = std::string() + Allocator::descriptor + "/default"; + binder_status_t status = + AServiceManager_addService(allocator->asBinder().get(), instance.c_str()); + CHECK_EQ(status, STATUS_OK); + + ABinderProcess_setThreadPoolMaxThreadCount(4); + ABinderProcess_startThreadPool(); + ABinderProcess_joinThreadPool(); + + return EXIT_FAILURE; +}
\ No newline at end of file |