Home | History | Annotate | Download | only in dvr
      1 #ifndef ANDROID_DVR_VSYNC_SERVICE_H_
      2 #define ANDROID_DVR_VSYNC_SERVICE_H_
      3 
      4 #include <binder/IInterface.h>
      5 
      6 namespace android {
      7 namespace dvr {
      8 
      9 class IVsyncCallback : public IInterface {
     10  public:
     11   DECLARE_META_INTERFACE(VsyncCallback)
     12 
     13   enum {
     14     ON_VSYNC = IBinder::FIRST_CALL_TRANSACTION
     15   };
     16 
     17   virtual status_t onVsync(int64_t vsync_timestamp) = 0;
     18 };
     19 
     20 class BnVsyncCallback : public BnInterface<IVsyncCallback> {
     21  public:
     22   virtual status_t onTransact(uint32_t code, const Parcel& data,
     23                               Parcel* reply, uint32_t flags = 0);
     24 };
     25 
     26 // Register a callback with IVsyncService to be notified of vsync events and
     27 // timestamps. There's also a shared memory vsync buffer defined in
     28 // dvr_shared_buffers.h. IVsyncService has advantages over the vsync shared
     29 // memory buffer that make it preferable in certain situations:
     30 //
     31 // 1. The shared memory buffer lifetime is controlled by VrCore. IVsyncService
     32 // is always available as long as surface flinger is running.
     33 //
     34 // 2. IVsyncService will make a binder callback when a vsync event occurs. This
     35 // allows the client to not write code to implement periodic "get the latest
     36 // vsync" calls, which is necessary with the vsync shared memory buffer.
     37 //
     38 // 3. The IVsyncService provides the real vsync timestamp reported by hardware
     39 // composer, whereas the vsync shared memory buffer only has predicted vsync
     40 // times.
     41 class IVsyncService : public IInterface {
     42 public:
     43   DECLARE_META_INTERFACE(VsyncService)
     44 
     45   static const char* GetServiceName() { return "vrflinger_vsync"; }
     46 
     47   enum {
     48     REGISTER_CALLBACK = IBinder::FIRST_CALL_TRANSACTION,
     49     UNREGISTER_CALLBACK
     50   };
     51 
     52   virtual status_t registerCallback(const sp<IVsyncCallback> callback) = 0;
     53   virtual status_t unregisterCallback(const sp<IVsyncCallback> callback) = 0;
     54 };
     55 
     56 class BnVsyncService : public BnInterface<IVsyncService> {
     57  public:
     58   virtual status_t onTransact(uint32_t code, const Parcel& data,
     59                               Parcel* reply, uint32_t flags = 0);
     60 };
     61 
     62 }  // namespace dvr
     63 }  // namespace android
     64 
     65 #endif  // ANDROID_DVR_VSYNC_SERVICE_H_
     66