• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2019 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "RunnerComponent.h"
16 
17 #include "ClientConfig.pb.h"
18 #include "types/Status.h"
19 
20 namespace android {
21 namespace automotive {
22 namespace computepipe {
23 namespace runner {
24 
25 /* Is this a notification to enter the phase */
isPhaseEntry() const26 bool RunnerEvent::isPhaseEntry() const {
27     return false;
28 }
29 /* Is this a notification that all components have transitioned to the phase */
isTransitionComplete() const30 bool RunnerEvent::isTransitionComplete() const {
31     return false;
32 }
33 
isAborted() const34 bool RunnerEvent::isAborted() const {
35     return false;
36 }
37 
38 /**
39  * ClientConfig methods
40  */
dispatchToComponent(const std::shared_ptr<RunnerComponentInterface> & iface)41 Status ClientConfig::dispatchToComponent(const std::shared_ptr<RunnerComponentInterface>& iface) {
42     return iface->handleConfigPhase(*this);
43 }
44 
getSerializedClientConfig() const45 std::string ClientConfig::getSerializedClientConfig() const {
46     proto::ClientConfig config;
47     std::string output;
48 
49     config.set_input_config_id(mInputConfigId);
50     config.set_termination_id(mTerminationId);
51     config.set_offload_id(mOffloadId);
52     config.set_profiling_type(mProfilingType);
53     for (auto it : mOutputConfigs) {
54         (*config.mutable_output_options())[it.first] = it.second;
55     }
56     if (!config.SerializeToString(&output)) {
57         return "";
58     }
59     return output;
60 }
61 
getInputConfigId(int * outId) const62 Status ClientConfig::getInputConfigId(int* outId) const {
63     if (mInputConfigId == kInvalidId) {
64         return Status::ILLEGAL_STATE;
65     }
66     *outId = mInputConfigId;
67     return Status::SUCCESS;
68 }
69 
getOffloadId(int * outId) const70 Status ClientConfig::getOffloadId(int* outId) const {
71     if (mOffloadId == kInvalidId) {
72         return Status::ILLEGAL_STATE;
73     }
74     *outId = mOffloadId;
75     return Status::SUCCESS;
76 }
77 
getTerminationId(int * outId) const78 Status ClientConfig::getTerminationId(int* outId) const {
79     if (mTerminationId == kInvalidId) {
80         return Status::ILLEGAL_STATE;
81     }
82     *outId = mTerminationId;
83     return Status::SUCCESS;
84 }
85 
getOutputStreamConfigs(std::map<int,int> & outputConfig) const86 Status ClientConfig::getOutputStreamConfigs(std::map<int, int>& outputConfig) const {
87     if (mOutputConfigs.empty()) {
88         return Status::ILLEGAL_STATE;
89     }
90     outputConfig = mOutputConfigs;
91     return Status::SUCCESS;
92 }
93 
getOptionalConfigs(std::string & outOptional) const94 Status ClientConfig::getOptionalConfigs(std::string& outOptional) const {
95     outOptional = mOptionalConfigs;
96     return Status::SUCCESS;
97 }
98 
getProfilingType(proto::ProfilingType * profilingType) const99 Status ClientConfig::getProfilingType(proto::ProfilingType* profilingType) const {
100     *profilingType = mProfilingType;
101     return Status::SUCCESS;
102 }
103 
104 /**
105  * Methods for ComponentInterface
106  */
107 
108 /* handle a ConfigPhase related event notification from Runner Engine */
handleConfigPhase(const ClientConfig &)109 Status RunnerComponentInterface::handleConfigPhase(const ClientConfig& /* e*/) {
110     return Status::SUCCESS;
111 }
112 /* handle execution phase notification from Runner Engine */
handleExecutionPhase(const RunnerEvent &)113 Status RunnerComponentInterface::handleExecutionPhase(const RunnerEvent& /* e*/) {
114     return SUCCESS;
115 }
116 /* handle a stop with flushing semantics phase notification from the engine */
handleStopWithFlushPhase(const RunnerEvent &)117 Status RunnerComponentInterface::handleStopWithFlushPhase(const RunnerEvent& /* e*/) {
118     return SUCCESS;
119 }
120 /* handle an immediate stop phase notification from the engine */
handleStopImmediatePhase(const RunnerEvent &)121 Status RunnerComponentInterface::handleStopImmediatePhase(const RunnerEvent& /* e*/) {
122     return SUCCESS;
123 }
124 /* handle an engine notification to return to reset state */
handleResetPhase(const RunnerEvent &)125 Status RunnerComponentInterface::handleResetPhase(const RunnerEvent& /* e*/) {
126     return SUCCESS;
127 }
128 
129 }  // namespace runner
130 }  // namespace computepipe
131 }  // namespace automotive
132 }  // namespace android
133