Alex Vakulenko | e4eec20 | 2017-01-27 14:41:04 -0800 | [diff] [blame] | 1 | #include "include/private/dvr/vsync_client.h" |
| 2 | |
Alex Vakulenko | 4fe6058 | 2017-02-02 11:35:59 -0800 | [diff] [blame] | 3 | #include <log/log.h> |
Alex Vakulenko | e4eec20 | 2017-01-27 14:41:04 -0800 | [diff] [blame] | 4 | |
| 5 | #include <pdx/default_transport/client_channel_factory.h> |
| 6 | #include <private/dvr/display_rpc.h> |
| 7 | |
| 8 | using android::pdx::Transaction; |
| 9 | |
| 10 | namespace android { |
| 11 | namespace dvr { |
| 12 | |
| 13 | VSyncClient::VSyncClient(long timeout_ms) |
| 14 | : BASE(pdx::default_transport::ClientChannelFactory::Create( |
| 15 | DisplayVSyncRPC::kClientPath), |
| 16 | timeout_ms) {} |
| 17 | |
| 18 | VSyncClient::VSyncClient() |
| 19 | : BASE(pdx::default_transport::ClientChannelFactory::Create( |
| 20 | DisplayVSyncRPC::kClientPath)) {} |
| 21 | |
| 22 | int VSyncClient::Wait(int64_t* timestamp_ns) { |
| 23 | auto status = InvokeRemoteMethod<DisplayVSyncRPC::Wait>(); |
| 24 | if (!status) { |
| 25 | ALOGE("VSyncClient::Wait: Failed to wait for vsync: %s", |
| 26 | status.GetErrorMessage().c_str()); |
| 27 | return -status.error(); |
| 28 | } |
Okan Arikan | b4213f7 | 2017-02-03 15:06:35 -0800 | [diff] [blame^] | 29 | |
| 30 | if (timestamp_ns != nullptr) { |
| 31 | *timestamp_ns = status.get(); |
| 32 | } |
Alex Vakulenko | e4eec20 | 2017-01-27 14:41:04 -0800 | [diff] [blame] | 33 | return 0; |
| 34 | } |
| 35 | |
| 36 | int VSyncClient::GetFd() { return event_fd(); } |
| 37 | |
| 38 | int VSyncClient::GetLastTimestamp(int64_t* timestamp_ns) { |
| 39 | auto status = InvokeRemoteMethod<DisplayVSyncRPC::GetLastTimestamp>(); |
| 40 | if (!status) { |
| 41 | ALOGE("VSyncClient::GetLastTimestamp: Failed to get vsync timestamp: %s", |
| 42 | status.GetErrorMessage().c_str()); |
| 43 | return -status.error(); |
| 44 | } |
| 45 | *timestamp_ns = status.get(); |
| 46 | return 0; |
| 47 | } |
| 48 | |
| 49 | int VSyncClient::GetSchedInfo(int64_t* vsync_period_ns, int64_t* timestamp_ns, |
| 50 | uint32_t* next_vsync_count) { |
| 51 | if (!vsync_period_ns || !timestamp_ns || !next_vsync_count) |
| 52 | return -EINVAL; |
| 53 | |
| 54 | auto status = InvokeRemoteMethod<DisplayVSyncRPC::GetSchedInfo>(); |
| 55 | if (!status) { |
| 56 | ALOGE("VSyncClient::GetSchedInfo:: Failed to get warp timestamp: %s", |
| 57 | status.GetErrorMessage().c_str()); |
| 58 | return -status.error(); |
| 59 | } |
| 60 | |
| 61 | *vsync_period_ns = status.get().vsync_period_ns; |
| 62 | *timestamp_ns = status.get().timestamp_ns; |
| 63 | *next_vsync_count = status.get().next_vsync_count; |
| 64 | return 0; |
| 65 | } |
| 66 | |
| 67 | int VSyncClient::Acknowledge() { |
| 68 | auto status = InvokeRemoteMethod<DisplayVSyncRPC::Acknowledge>(); |
| 69 | ALOGE_IF(!status, "VSuncClient::Acknowledge: Failed to ack vsync because: %s", |
| 70 | status.GetErrorMessage().c_str()); |
| 71 | return ReturnStatusOrError(status); |
| 72 | } |
| 73 | |
| 74 | } // namespace dvr |
| 75 | } // namespace android |