fix hardware buffer aidl

This commit is contained in:
2025-12-30 13:49:01 +01:00
parent 2ee6543d51
commit e576011ebb
11 changed files with 162 additions and 43 deletions

View File

@@ -3,6 +3,7 @@
#include <android/hardware_buffer.h>
#include <aidl/com/omixlab/mosis/BnMosisService.h>
#include <aidl/com/omixlab/mosis/IMosisListener.h>
#include <aidl/com/omixlab/mosis/BnMosisListener.h>
#include "egl_context.h"
#include "logger.h"
#include <glad/egl.h>
@@ -10,6 +11,7 @@
#include <thread>
using namespace aidl::com::omixlab::mosis;
using namespace aidl::android::hardware;
class Texture
{
@@ -91,9 +93,9 @@ public:
return status;
}
[[nodiscard]] long hardware_buffer()
[[nodiscard]] AHardwareBuffer* hardware_buffer()
{
return reinterpret_cast<long>(hardwareBuffer);
return hardwareBuffer;
}
void bind()
{
@@ -115,6 +117,7 @@ class Kernel
std::unique_ptr<egl::Context> m_egl_context;
std::unique_ptr<RenderTarget> m_render_target;
std::shared_ptr<IMosisListener> m_listener;
HardwareBuffer m_aidl_buffer;
std::thread m_main_loop_thread;
void main_loop()
{
@@ -132,13 +135,15 @@ class Kernel
}
m_render_target->bind();
m_listener->onServiceInitialized(true);
m_aidl_buffer.reset(m_render_target->hardware_buffer());
m_listener->onBufferAvailable(m_aidl_buffer);
while (true)
{
glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glFinish();
m_listener->onFrameAvailable(m_render_target->hardware_buffer());
m_listener->onFrameAvailable();
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
}