• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2020 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 #ifndef COMPUTEPIPE_RUNNER_CLIENT_INTERFACE_DEBUGGERIMPL_H_
16 #define COMPUTEPIPE_RUNNER_CLIENT_INTERFACE_DEBUGGERIMPL_H_
17 #include <aidl/android/automotive/computepipe/runner/BnPipeDebugger.h>
18 
19 #include <condition_variable>
20 #include <memory>
21 #include <mutex>
22 
23 #include "ClientEngineInterface.h"
24 #include "RunnerComponent.h"
25 #include "types/GraphState.h"
26 #include "types/Status.h"
27 #include "Options.pb.h"
28 
29 namespace android {
30 namespace automotive {
31 namespace computepipe {
32 namespace runner {
33 namespace client_interface {
34 namespace aidl_client {
35 
36 // RunnerInterface registers an IPipeRunner interface with computepipe router.
37 // RunnerInterface handles binder IPC calls and invokes appropriate callbacks.
38 class DebuggerImpl : public aidl::android::automotive::computepipe::runner::BnPipeDebugger,
39                      public RunnerComponentInterface  {
40   public:
DebuggerImpl(const proto::Options graphOptions,const std::shared_ptr<ClientEngineInterface> & engine)41     explicit DebuggerImpl(const proto::Options graphOptions,
42                           const std::shared_ptr<ClientEngineInterface>& engine)
43             : mEngine(engine), mGraphOptions(graphOptions) {}
44 
45     // Methods from android::automotive::computepipe::runner::BnPipeDebugger
46     ndk::ScopedAStatus setPipeProfileOptions(
47         aidl::android::automotive::computepipe::runner::PipeProfilingType in_type) override;
48     ndk::ScopedAStatus startPipeProfiling() override;
49     ndk::ScopedAStatus stopPipeProfiling() override;
50     ndk::ScopedAStatus getPipeProfilingInfo(
51         aidl::android::automotive::computepipe::runner::ProfilingData* _aidl_return) override;
52     ndk::ScopedAStatus releaseDebugger() override;
53 
54     // Methods from RunnerComponentInterface
55     Status handleConfigPhase(const ClientConfig& e) override;
56     Status handleExecutionPhase(const RunnerEvent& e) override;
57     Status handleStopWithFlushPhase(const RunnerEvent& e) override;
58     Status handleStopImmediatePhase(const RunnerEvent& e) override;
59     Status handleResetPhase(const RunnerEvent& e) override;
60 
61     Status deliverGraphDebugInfo(const std::string& debugData);
62 
63   private:
64     std::weak_ptr<ClientEngineInterface> mEngine;
65 
66     GraphState mGraphState = GraphState::RESET;
67     aidl::android::automotive::computepipe::runner::PipeProfilingType mProfilingType;
68     proto::Options mGraphOptions;
69     aidl::android::automotive::computepipe::runner::ProfilingData mProfilingData;
70 
71     // Lock for mProfilingData.
72     std::mutex mLock;
73     std::condition_variable mWait;
74     const std::string mProfilingDataDirName = "/data/computepipe/profiling";
75 };
76 
77 }  // namespace aidl_client
78 }  // namespace client_interface
79 }  // namespace runner
80 }  // namespace computepipe
81 }  // namespace automotive
82 }  // namespace android
83 
84 #endif  // COMPUTEPIPE_RUNNER_CLIENT_INTERFACE_DEBUGGERIMPL_H_
85