aboutsummaryrefslogtreecommitdiffstats
path: root/src/app.cpp
diff options
context:
space:
mode:
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-05-18 19:49:26 +0900
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-05-18 19:49:56 +0900
commit807c2bc45bf19059021eb3d94e2c1693a9c940b6 (patch)
tree8d463795e262f976016ebc2fc44b77bb5c259a86 /src/app.cpp
parent5529ff5051d8da4acb6157c6c6fa0043de2e685b (diff)
[Local]:4th step for blocking sequence
Change-Id: If4f01a177f4947780d448aaa214f863af2124b0f Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
Diffstat (limited to 'src/app.cpp')
-rw-r--r--src/app.cpp90
1 files changed, 59 insertions, 31 deletions
diff --git a/src/app.cpp b/src/app.cpp
index 8038f4c..ce41827 100644
--- a/src/app.cpp
+++ b/src/app.cpp
@@ -38,6 +38,10 @@
#include "windowmanager-client.hpp"
#include "allocate_queue.hpp"
+extern "C" {
+ #include <systemd/sd-event.h>
+}
+
#define TIME_OUT 1000000UL /* 1s */
namespace wm {
@@ -62,8 +66,9 @@ const char kKeyHeightPixel[] = "height_pixel";
const char kKeyWidthMm[] = "width_mm";
const char kKeyHeightMm[] = "height_mm";
-static const std::string task_allocate = "allocate"
-static const std::string task_release = "release"
+static const std::string task_allocate = "allocate";
+static const std::string task_release = "release";
+static sd_event_source *timer_ev_src = nullptr;
static AllocateRequestList allocate_list;
@@ -97,17 +102,19 @@ struct result<layer_map> load_layer_map(char const *filename) {
return to_layer_map(jids);
}
-} // namespace
-static int App::processTimerHandler(sd_event_source *s, uint64_t usec, void *userdata){
- HMI_NOTICE("Time out occurs because the client replys endDraw slow, so revert the request");
+static int processTimerHandler(sd_event_source *s, uint64_t usec, void *userdata){
+ HMI_NOTICE("wm", "Time out occurs because the client replys endDraw slow, so revert the request");
reinterpret_cast<wm::App *>(userdata)->timerHandler();
+ return 0;
}
+} // namespace
+
void App::timerHandler(){
// TODO: write reset process
- unsigned seq = allocate_list.curerntSequenceNumber();
- allocate_list.resetRequest(seq);
+ unsigned seq = allocate_list.currentSequenceNumber();
+ allocate_list.removeRequest(seq);
}
/**
@@ -355,21 +362,24 @@ void App::do_allocate_window_resource(unsigned sequence_number){
do {
// TODO: Tasks will be changed according to policy manager result
// do task(onTransition (activate))
- }while (!allocate_list.requestFinished())
+ }while (!allocate_list.requestFinished());
// lm_.updateLayout(jobj);
// TODO: emit syncDraw with application
do{
- client->emit_syncdraw(role);
+ //client->emit_syncdraw(role);
}while (!allocate_list.requestFinished());
- // is this needed?
+ // is the below necessary?
//allocate_list.setAllocated(sequence_number);
if(timer_ev_src != nullptr){
// firsttime set into sd_event
int ret = sd_event_add_time(afb_daemon_get_event_loop(), &timer_ev_src,
CLOCK_BOOTTIME, time(NULL) + TIME_OUT, 0, processTimerHandler, this);
+ if(ret < 0){
+ HMI_ERROR("wm", "Can't set timer");
+ }
}
else{
// update timer limitation after second time
@@ -386,12 +396,13 @@ void App::api_activate_surface(char const *appid, char const *drawing_name, char
*/
auto const &surface_id = this->lookup_id(drawing_name);
- std::string role = std::string(drawing_name);
- std::string area = std::string(drawing_area);
+ std::string id = appid;
+ std::string role = drawing_name;
+ std::string area = drawing_area;
- const WMClient* client = allocate_list.loopUpClient(appid);
+ WMClient* client = allocate_list.lookUpClient(id);
if(!client){
- reply("%d doesn't request 'requestSurface' yet", appid);
+ reply("app doesn't request 'requestSurface' yet");
return;
}
@@ -415,21 +426,22 @@ void App::api_activate_surface(char const *appid, char const *drawing_name, char
/*
* Queueing Phase
*/
- unsigned current = allocate_list.curerntSequenceNumber();
- unsigned requested_num = getSequenceNumber(appid, role, area);
+ unsigned current = allocate_list.currentSequenceNumber();
+ unsigned requested_num = allocate_list.getSequenceNumber(id, role, area);
if(requested_num != 0){
- HMI_SEQ_INFO(requested_num, "%s %s %s request is already queued", appid, role, area);
+ HMI_SEQ_INFO(requested_num, "%s %s %s request is already queued", id.c_str(), role.c_str(), area.c_str());
reply("already requested");
return;
}
- static unsigned ++sequence_number;
- HMI_SEQ_DEBUG(sequence_number, "%s start sequence with %s, %s", appid, role, area);
+ WMRequest req = WMRequest(id, role, area, Task::TASK_ALLOCATE);
+ unsigned new_req = allocate_list.addAllocateRequest(req);
- if(sequence_number != current){
+ HMI_SEQ_DEBUG(new_req, "%s start sequence with %s, %s", id.c_str(), role.c_str(), area.c_str());
+
+ if(new_req != current){
// Add request, then invoked after the previous task is finished
- allocate_list.addAllocateRequest(client, sequence_number, task_allocate);
- HMI_SEQ_DEBUG(sequence_number, "request is accepted");
+ HMI_SEQ_DEBUG(new_req, "request is accepted");
reply(nullptr);
return;
}
@@ -437,7 +449,7 @@ void App::api_activate_surface(char const *appid, char const *drawing_name, char
/*
* Do allocate tasks
*/
- this->do_allocate_window_resource(sequence_number);
+ this->do_allocate_window_resource(new_req);
if (!surface_id)
{
@@ -591,7 +603,13 @@ void App::api_activate_surface(char const *appid, char const *drawing_name, char
void App::api_deactivate_surface(char const *appid, char const *drawing_name, const reply_func &reply) {
ST();
auto const &surface_id = this->lookup_id(drawing_name);
- WMClient* client = allocate_list.lookupClient(appid);
+
+ std::string id = appid;
+ WMClient* client = allocate_list.lookUpClient(id);
+
+ if(!client){
+ HMI_ERROR("wm", "client %s is not registered", appid);
+ }
if (!surface_id) {
reply ("Surface does not exist");
@@ -706,12 +724,16 @@ void App::do_enddraw(unsigned sequence_number){
}while(!allocate_list.requestFinished());
}
+void App::process_request(){
+
+}
+
void App::api_enddraw(char const *appid, char const *drawing_name) {
unsigned request_seq = allocate_list.lookUpAllocatingApp(appid);
- unsigned current_seq = allocate_list.currentSequence();
+ unsigned current_seq = allocate_list.currentSequenceNumber();
if(current_seq != request_seq){
if(request_seq == 0){
- HMI_ERROR("You don't have Window Resource");
+ HMI_ERROR("wm", "You don't have Window Resource");
}
else{
HMI_ERROR("wm", "unknown error. Application may not obey the sequence manner. please call endDraw after syncDraw");
@@ -720,7 +742,7 @@ void App::api_enddraw(char const *appid, char const *drawing_name) {
}
std::string role = drawing_name;
- std::string area = drawing_area;
+ //std::string area = drawing_area;
allocate_list.setEndDrawFinished(request_seq, role);
if(allocate_list.endDrawFullfilled(request_seq)){
@@ -818,7 +840,12 @@ void App::surface_removed(uint32_t surface_id) {
} else {
auto drawing_name = this->lookup_name(surface_id);
if (drawing_name) {
- this->api_deactivate_surface(drawing_name->c_str(), [](const char*){});
+ std::string appid = "";
+ /* const WMClient *client = lookUpClient(surface_id);
+ appid = client->appID();
+
+ */
+ this->api_deactivate_surface(appid.c_str(), drawing_name->c_str(), [](const char*){});
}
}
@@ -852,7 +879,7 @@ void App::emit_invisible(char const *label) {
void App::emit_visible(char const *label) { return emit_visible(label, true); }
-result<int> App::api_request_surface(char const *drawing_name, char const * appid, int flag) {
+result<int> App::api_request_surface(char const * appid, char const *drawing_name) {
auto lid = this->layers.get_layer_id(std::string(drawing_name));
if (!lid) {
/**
@@ -889,7 +916,7 @@ result<int> App::api_request_surface(char const *drawing_name, char const * appi
return Err<int>("Surface already present");
}
-char const *App::api_request_surface(char const *drawing_name,
+char const *App::api_request_surface(char const *appid, char const *drawing_name,
char const *ivi_id) {
ST();
@@ -1063,7 +1090,8 @@ void App::deactivate(int id) {
void App::deactivate_main_surface() {
this->layers.main_surface = -1;
- this->api_deactivate_surface(this->layers.main_surface_name.c_str(), [](const char*){});
+ std::string appid = "HomeScreen";
+ this->api_deactivate_surface(appid.c_str(), this->layers.main_surface_name.c_str(), [](const char*){});
}
bool App::can_split(struct LayoutState const &state, int new_id) {