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 <binder/IInterface.h> 21 22 #include <utils/RefBase.h> 23 24 namespace android { 25 26 // ProducerListener is the interface through which the BufferQueue notifies the 27 // producer of events that the producer may wish to react to. Because the 28 // producer will generally have a mutex that is locked during calls from the 29 // producer to the BufferQueue, these calls from the BufferQueue to the 30 // producer *MUST* be called only when the BufferQueue mutex is NOT locked. 31 32 class ProducerListener : public virtual RefBase 33 { 34 public: ProducerListener()35 ProducerListener() {} 36 virtual ~ProducerListener(); 37 38 // onBufferReleased is called from IGraphicBufferConsumer::releaseBuffer to 39 // notify the producer that a new buffer is free and ready to be dequeued. 40 // 41 // This is called without any lock held and can be called concurrently by 42 // multiple threads. 43 virtual void onBufferReleased() = 0; // Asynchronous 44 virtual bool needsReleaseNotify() = 0; 45 }; 46 47 class IProducerListener : public ProducerListener, public IInterface 48 { 49 public: 50 DECLARE_META_INTERFACE(ProducerListener) 51 }; 52 53 class BnProducerListener : public BnInterface<IProducerListener> 54 { 55 public: 56 virtual status_t onTransact(uint32_t code, const Parcel& data, 57 Parcel* reply, uint32_t flags = 0); 58 virtual bool needsReleaseNotify(); 59 }; 60 61 class DummyProducerListener : public BnProducerListener 62 { 63 public: 64 virtual ~DummyProducerListener(); onBufferReleased()65 virtual void onBufferReleased() {} needsReleaseNotify()66 virtual bool needsReleaseNotify() { return false; } 67 }; 68 69 } // namespace android 70 71 #endif 72