• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2014 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_IPRODUCERLISTENER_H
18 #define ANDROID_GUI_IPRODUCERLISTENER_H
19 
20 #include <android/hardware/graphics/bufferqueue/1.0/IProducerListener.h>
21 #include <android/hardware/graphics/bufferqueue/2.0/IProducerListener.h>
22 #include <binder/IInterface.h>
23 #include <hidl/HybridInterface.h>
24 #include <utils/RefBase.h>
25 
26 namespace android {
27 
28 // ProducerListener is the interface through which the BufferQueue notifies the
29 // producer of events that the producer may wish to react to. Because the
30 // producer will generally have a mutex that is locked during calls from the
31 // producer to the BufferQueue, these calls from the BufferQueue to the
32 // producer *MUST* be called only when the BufferQueue mutex is NOT locked.
33 
34 class ProducerListener : public virtual RefBase
35 {
36 public:
ProducerListener()37     ProducerListener() {}
38     virtual ~ProducerListener();
39 
40     // onBufferReleased is called from IGraphicBufferConsumer::releaseBuffer to
41     // notify the producer that a new buffer is free and ready to be dequeued.
42     //
43     // This is called without any lock held and can be called concurrently by
44     // multiple threads.
45     virtual void onBufferReleased() = 0; // Asynchronous
46     virtual bool needsReleaseNotify() = 0;
47 };
48 
49 class IProducerListener : public ProducerListener, public IInterface
50 {
51 public:
52     using HProducerListener1 =
53             ::android::hardware::graphics::bufferqueue::V1_0::IProducerListener;
54     using HProducerListener2 =
55             ::android::hardware::graphics::bufferqueue::V2_0::IProducerListener;
56     DECLARE_HYBRID_META_INTERFACE(
57             ProducerListener,
58             HProducerListener1,
59             HProducerListener2)
60 };
61 
62 class BnProducerListener : public BnInterface<IProducerListener>
63 {
64 public:
65     virtual status_t onTransact(uint32_t code, const Parcel& data,
66             Parcel* reply, uint32_t flags = 0);
67     virtual bool needsReleaseNotify();
68 };
69 
70 class DummyProducerListener : public BnProducerListener
71 {
72 public:
73     virtual ~DummyProducerListener();
onBufferReleased()74     virtual void onBufferReleased() {}
needsReleaseNotify()75     virtual bool needsReleaseNotify() { return false; }
76 };
77 
78 } // namespace android
79 
80 #endif
81