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() {} ~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 }; 45 46 class IProducerListener : public ProducerListener, public IInterface 47 { 48 public: 49 DECLARE_META_INTERFACE(ProducerListener) 50 }; 51 52 class BnProducerListener : public BnInterface<IProducerListener> 53 { 54 public: 55 virtual status_t onTransact(uint32_t code, const Parcel& data, 56 Parcel* reply, uint32_t flags = 0); 57 }; 58 59 class DummyProducerListener : public BnProducerListener 60 { 61 public: onBufferReleased()62 virtual void onBufferReleased() {} 63 }; 64 65 } // namespace android 66 67 #endif 68