Dan Stoza | f0eaf25 | 2014-03-21 13:05:51 -0700 | [diff] [blame] | 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 | #include <binder/Parcel.h> |
| 18 | |
| 19 | #include <gui/IProducerListener.h> |
| 20 | |
| 21 | namespace android { |
| 22 | |
| 23 | enum { |
| 24 | ON_BUFFER_RELEASED = IBinder::FIRST_CALL_TRANSACTION, |
| 25 | }; |
| 26 | |
| 27 | class BpProducerListener : public BpInterface<IProducerListener> |
| 28 | { |
| 29 | public: |
Chih-Hung Hsieh | e2347b7 | 2016-04-25 15:41:05 -0700 | [diff] [blame^] | 30 | explicit BpProducerListener(const sp<IBinder>& impl) |
Dan Stoza | f0eaf25 | 2014-03-21 13:05:51 -0700 | [diff] [blame] | 31 | : BpInterface<IProducerListener>(impl) {} |
| 32 | |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 33 | virtual ~BpProducerListener(); |
| 34 | |
Dan Stoza | f0eaf25 | 2014-03-21 13:05:51 -0700 | [diff] [blame] | 35 | virtual void onBufferReleased() { |
| 36 | Parcel data, reply; |
| 37 | data.writeInterfaceToken(IProducerListener::getInterfaceDescriptor()); |
| 38 | remote()->transact(ON_BUFFER_RELEASED, data, &reply, IBinder::FLAG_ONEWAY); |
| 39 | } |
| 40 | }; |
| 41 | |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 42 | // Out-of-line virtual method definition to trigger vtable emission in this |
| 43 | // translation unit (see clang warning -Wweak-vtables) |
| 44 | BpProducerListener::~BpProducerListener() {} |
| 45 | |
Dan Stoza | f0eaf25 | 2014-03-21 13:05:51 -0700 | [diff] [blame] | 46 | IMPLEMENT_META_INTERFACE(ProducerListener, "android.gui.IProducerListener") |
| 47 | |
| 48 | status_t BnProducerListener::onTransact(uint32_t code, const Parcel& data, |
| 49 | Parcel* reply, uint32_t flags) { |
| 50 | switch (code) { |
| 51 | case ON_BUFFER_RELEASED: |
| 52 | CHECK_INTERFACE(IProducerListener, data, reply); |
| 53 | onBufferReleased(); |
| 54 | return NO_ERROR; |
| 55 | } |
| 56 | return BBinder::onTransact(code, data, reply, flags); |
| 57 | } |
| 58 | |
| 59 | } // namespace android |