Home | History | Annotate | Download | only in gui
      1 /*
      2  * Copyright (C) 2013 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef ANDROID_GUI_ICONSUMERLISTENER_H
     18 #define ANDROID_GUI_ICONSUMERLISTENER_H
     19 
     20 #include <stdint.h>
     21 #include <sys/types.h>
     22 
     23 #include <utils/Errors.h>
     24 #include <utils/RefBase.h>
     25 
     26 #include <binder/IInterface.h>
     27 
     28 namespace android {
     29 // ----------------------------------------------------------------------------
     30 
     31 // ConsumerListener is the interface through which the BufferQueue notifies
     32 // the consumer of events that the consumer may wish to react to.  Because
     33 // the consumer will generally have a mutex that is locked during calls from
     34 // the consumer to the BufferQueue, these calls from the BufferQueue to the
     35 // consumer *MUST* be called only when the BufferQueue mutex is NOT locked.
     36 
     37 class ConsumerListener : public virtual RefBase {
     38 public:
     39     ConsumerListener() { }
     40     virtual ~ConsumerListener() { }
     41 
     42     // onFrameAvailable is called from queueBuffer each time an additional
     43     // frame becomes available for consumption. This means that frames that
     44     // are queued while in asynchronous mode only trigger the callback if no
     45     // previous frames are pending. Frames queued while in synchronous mode
     46     // always trigger the callback.
     47     //
     48     // This is called without any lock held and can be called concurrently
     49     // by multiple threads.
     50     virtual void onFrameAvailable() = 0; /* Asynchronous */
     51 
     52     // onBuffersReleased is called to notify the buffer consumer that the
     53     // BufferQueue has released its references to one or more GraphicBuffers
     54     // contained in its slots.  The buffer consumer should then call
     55     // BufferQueue::getReleasedBuffers to retrieve the list of buffers
     56     //
     57     // This is called without any lock held and can be called concurrently
     58     // by multiple threads.
     59     virtual void onBuffersReleased() = 0; /* Asynchronous */
     60 
     61     // onSidebandStreamChanged is called to notify the buffer consumer that the
     62     // BufferQueue's sideband buffer stream has changed. This is called when a
     63     // stream is first attached and when it is either detached or replaced by a
     64     // different stream.
     65     virtual void onSidebandStreamChanged() = 0; /* Asynchronous */
     66 };
     67 
     68 
     69 class IConsumerListener : public ConsumerListener, public IInterface
     70 {
     71 public:
     72     DECLARE_META_INTERFACE(ConsumerListener);
     73 };
     74 
     75 // ----------------------------------------------------------------------------
     76 
     77 class BnConsumerListener : public BnInterface<IConsumerListener>
     78 {
     79 public:
     80     virtual status_t    onTransact( uint32_t code,
     81                                     const Parcel& data,
     82                                     Parcel* reply,
     83                                     uint32_t flags = 0);
     84 };
     85 
     86 // ----------------------------------------------------------------------------
     87 }; // namespace android
     88 
     89 #endif // ANDROID_GUI_ICONSUMERLISTENER_H
     90