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
28namespace 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
37class ConsumerListener : public virtual RefBase {
38public:
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
62
63class IConsumerListener : public ConsumerListener, public IInterface
64{
65public:
66    DECLARE_META_INTERFACE(ConsumerListener);
67};
68
69// ----------------------------------------------------------------------------
70
71class BnConsumerListener : public BnInterface<IConsumerListener>
72{
73public:
74    virtual status_t    onTransact( uint32_t code,
75                                    const Parcel& data,
76                                    Parcel* reply,
77                                    uint32_t flags = 0);
78};
79
80// ----------------------------------------------------------------------------
81}; // namespace android
82
83#endif // ANDROID_GUI_ICONSUMERLISTENER_H
84