IAndroidBufferQueue.c revision bb832e853d4afb11b0a3287b2eb0cad87696d631
1fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi/* 2fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi * Copyright (C) 2010 The Android Open Source Project 3fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi * 4fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi * Licensed under the Apache License, Version 2.0 (the "License"); 5fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi * you may not use this file except in compliance with the License. 6fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi * You may obtain a copy of the License at 7fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi * 8fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi * http://www.apache.org/licenses/LICENSE-2.0 9fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi * 10fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi * Unless required by applicable law or agreed to in writing, software 11fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi * distributed under the License is distributed on an "AS IS" BASIS, 12fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi * See the License for the specific language governing permissions and 14fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi * limitations under the License. 15fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi */ 16fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi 17fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi/* AndroidBufferQueue implementation */ 18fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi 19bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi//#define USE_LOG SLAndroidLogLevel_Verbose 20fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi 21bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi#include "sles_allinclusive.h" 22bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi// for AAC ADTS verification on enqueue: 23bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi#include "android/include/AacBqToPcmCbRenderer.h" 24d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi 2570c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi/** 2670c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi * Determine the state of the audio player or audio recorder associated with a buffer queue. 27d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi * Note that PLAYSTATE and RECORDSTATE values are equivalent (where PLAYING == RECORDING). 28d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi */ 29d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi 30d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivistatic SLuint32 getAssociatedState(IAndroidBufferQueue *thiz) 31d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi{ 32d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi SLuint32 state; 33d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi switch (InterfaceToObjectID(thiz)) { 3470c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi case XA_OBJECTID_MEDIAPLAYER: 35d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi state = ((CMediaPlayer *) thiz->mThis)->mPlay.mState; 36d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi break; 3770c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi case SL_OBJECTID_AUDIOPLAYER: 38d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi state = ((CAudioPlayer *) thiz->mThis)->mPlay.mState; 39d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi break; 4070c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi case SL_OBJECTID_AUDIORECORDER: 41d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi state = ((CAudioRecorder *) thiz->mThis)->mRecord.mState; 42d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi break; 4370c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi default: 44d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi // unreachable, but just in case we will assume it is stopped 45d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi assert(SL_BOOLEAN_FALSE); 46d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi state = SL_PLAYSTATE_STOPPED; 47d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi break; 48d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi } 49d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi return state; 50d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi} 51d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi 52d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi 5370c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi/** 5470c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi * parse and set the items associated with the given buffer, based on the buffer type, 5570c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi * which determines the set of authorized items and format 5670c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi */ 5770c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivistatic void setItems(const SLAndroidBufferItem *pItems, SLuint32 itemsLength, 5870c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi SLuint16 bufferType, AdvancedBufferHeader *pBuff) 5970c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi{ 6070c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi if ((NULL == pItems) || (0 == itemsLength)) { 6170c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi // no item data, reset item structure based on type 6270c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi switch (bufferType) { 6370c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi case kAndroidBufferTypeMpeg2Ts: 6470c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi pBuff->mItems.mTsCmdData.mTsCmdCode = ANDROID_MP2TSEVENT_NONE; 6570c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi pBuff->mItems.mTsCmdData.mPts = 0; 6670c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi break; 6770c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi case kAndroidBufferTypeInvalid: 6870c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi default: 6970c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi return; 7070c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi } 7170c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi } else { 7270c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi // parse item data based on type 7370c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi switch (bufferType) { 7470c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi 7570c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi case kAndroidBufferTypeMpeg2Ts: { 7670c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi SLuint32 index = 0; 7770c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi // supported Mpeg2Ts commands are mutually exclusive 786f0f5640d190b0187c356eb53bd96d9f9e49da60Jean-Michel Trivi switch (pItems->itemKey) { 796f0f5640d190b0187c356eb53bd96d9f9e49da60Jean-Michel Trivi 806f0f5640d190b0187c356eb53bd96d9f9e49da60Jean-Michel Trivi case SL_ANDROID_ITEMKEY_EOS: 8170c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi pBuff->mItems.mTsCmdData.mTsCmdCode |= ANDROID_MP2TSEVENT_EOS; 82a8179ea15c4ff78db589d742b135649f0eda7ef2Glenn Kasten //SL_LOGD("Found EOS event=%d", pBuff->mItems.mTsCmdData.mTsCmdCode); 836f0f5640d190b0187c356eb53bd96d9f9e49da60Jean-Michel Trivi break; 846f0f5640d190b0187c356eb53bd96d9f9e49da60Jean-Michel Trivi 856f0f5640d190b0187c356eb53bd96d9f9e49da60Jean-Michel Trivi case SL_ANDROID_ITEMKEY_DISCONTINUITY: 8670c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi if (pItems->itemSize == 0) { 8770c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi pBuff->mItems.mTsCmdData.mTsCmdCode |= ANDROID_MP2TSEVENT_DISCONTINUITY; 88a8179ea15c4ff78db589d742b135649f0eda7ef2Glenn Kasten //SL_LOGD("Found DISCONTINUITYevent=%d", pBuff->mItems.mTsCmdData.mTsCmdCode); 89e9236d046fdb5cac0696c42e03443a2439188146Jean-Michel Trivi } else if (pItems->itemSize == sizeof(SLAuint64)) { 9070c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi pBuff->mItems.mTsCmdData.mTsCmdCode |= ANDROID_MP2TSEVENT_DISCON_NEWPTS; 91e9236d046fdb5cac0696c42e03443a2439188146Jean-Michel Trivi pBuff->mItems.mTsCmdData.mPts = *((SLAuint64*)pItems->itemData); 9270c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi //SL_LOGD("Found PTS=%lld", pBuff->mItems.mTsCmdData.mPts); 9370c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi } else { 9470c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi SL_LOGE("Invalid size for MPEG-2 PTS, ignoring value"); 9570c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi pBuff->mItems.mTsCmdData.mTsCmdCode |= ANDROID_MP2TSEVENT_DISCONTINUITY; 9670c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi } 976f0f5640d190b0187c356eb53bd96d9f9e49da60Jean-Michel Trivi break; 986f0f5640d190b0187c356eb53bd96d9f9e49da60Jean-Michel Trivi 996f0f5640d190b0187c356eb53bd96d9f9e49da60Jean-Michel Trivi case SL_ANDROID_ITEMKEY_FORMAT_CHANGE: 1006f0f5640d190b0187c356eb53bd96d9f9e49da60Jean-Michel Trivi pBuff->mItems.mTsCmdData.mTsCmdCode |= ANDROID_MP2TSEVENT_FORMAT_CHANGE; 1016f0f5640d190b0187c356eb53bd96d9f9e49da60Jean-Michel Trivi if (pItems->itemSize != 0) { 1026f0f5640d190b0187c356eb53bd96d9f9e49da60Jean-Michel Trivi SL_LOGE("Invalid item parameter size for format change, ignoring value"); 1036f0f5640d190b0187c356eb53bd96d9f9e49da60Jean-Michel Trivi } 1046f0f5640d190b0187c356eb53bd96d9f9e49da60Jean-Michel Trivi break; 1056f0f5640d190b0187c356eb53bd96d9f9e49da60Jean-Michel Trivi 1066f0f5640d190b0187c356eb53bd96d9f9e49da60Jean-Michel Trivi default: 1076f0f5640d190b0187c356eb53bd96d9f9e49da60Jean-Michel Trivi // no event with this buffer 10870c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi pBuff->mItems.mTsCmdData.mTsCmdCode = ANDROID_MP2TSEVENT_NONE; 1096f0f5640d190b0187c356eb53bd96d9f9e49da60Jean-Michel Trivi break; 1106f0f5640d190b0187c356eb53bd96d9f9e49da60Jean-Michel Trivi }// switch (pItems->itemKey) 1116f0f5640d190b0187c356eb53bd96d9f9e49da60Jean-Michel Trivi } break; 11270c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi 11370c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi default: 11470c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi return; 1156f0f5640d190b0187c356eb53bd96d9f9e49da60Jean-Michel Trivi }// switch (bufferType) 11670c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi } 11770c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi} 11870c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi 11970c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi 1201c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivistatic SLresult IAndroidBufferQueue_RegisterCallback(SLAndroidBufferQueueItf self, 121fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi slAndroidBufferQueueCallback callback, void *pContext) 122fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi{ 123fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi SL_ENTER_INTERFACE 124fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi 125bcc5c7225e3b7a1dbf2e9e830987f69167acf06fGlenn Kasten IAndroidBufferQueue *thiz = (IAndroidBufferQueue *) self; 126fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi 127bcc5c7225e3b7a1dbf2e9e830987f69167acf06fGlenn Kasten interface_lock_exclusive(thiz); 128fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi 129fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi // verify pre-condition that media object is in the SL_PLAYSTATE_STOPPED state 13070c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi if (SL_PLAYSTATE_STOPPED == getAssociatedState(thiz)) { 131bcc5c7225e3b7a1dbf2e9e830987f69167acf06fGlenn Kasten thiz->mCallback = callback; 132bcc5c7225e3b7a1dbf2e9e830987f69167acf06fGlenn Kasten thiz->mContext = pContext; 133eae4df541ba1d46f65d37e959baf2127aa632c93Jean-Michel Trivi 134bcc5c7225e3b7a1dbf2e9e830987f69167acf06fGlenn Kasten switch (InterfaceToObjectID(thiz)) { 13570c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi case SL_OBJECTID_AUDIOPLAYER: 136bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi result = android_audioPlayer_androidBufferQueue_registerCallback_l( 137bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi (CAudioPlayer*) thiz->mThis); 138eae4df541ba1d46f65d37e959baf2127aa632c93Jean-Michel Trivi break; 13970c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi case XA_OBJECTID_MEDIAPLAYER: 140ecc4fe22e076c4e5c891d823b01db1a683ba6690Glenn Kasten SL_LOGV("IAndroidBufferQueue_RegisterCallback()"); 141eae4df541ba1d46f65d37e959baf2127aa632c93Jean-Michel Trivi result = SL_RESULT_SUCCESS; 142bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi //FIXME return error code 143bcc5c7225e3b7a1dbf2e9e830987f69167acf06fGlenn Kasten android_Player_androidBufferQueue_registerCallback_l((CMediaPlayer*) thiz->mThis); 144bdb08965172949ae07fefc8f3d46cbcffb77b0bdJean-Michel Trivi break; 14570c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi default: 146eae4df541ba1d46f65d37e959baf2127aa632c93Jean-Michel Trivi result = SL_RESULT_PARAMETER_INVALID; 147eae4df541ba1d46f65d37e959baf2127aa632c93Jean-Michel Trivi } 148eae4df541ba1d46f65d37e959baf2127aa632c93Jean-Michel Trivi 14970c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi } else { 15070c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi result = SL_RESULT_PRECONDITIONS_VIOLATED; 15170c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi } 152fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi 153bcc5c7225e3b7a1dbf2e9e830987f69167acf06fGlenn Kasten interface_unlock_exclusive(thiz); 154fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi 155fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi SL_LEAVE_INTERFACE 156fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi} 157fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi 158fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi 1591c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivistatic SLresult IAndroidBufferQueue_Clear(SLAndroidBufferQueueItf self) 160fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi{ 161fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi SL_ENTER_INTERFACE 162e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi result = SL_RESULT_SUCCESS; 163fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi 164bcc5c7225e3b7a1dbf2e9e830987f69167acf06fGlenn Kasten IAndroidBufferQueue *thiz = (IAndroidBufferQueue *) self; 165fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi 166bcc5c7225e3b7a1dbf2e9e830987f69167acf06fGlenn Kasten interface_lock_exclusive(thiz); 167fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi 168e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi // reset the queue pointers 169e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi thiz->mFront = &thiz->mBufferArray[0]; 170e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi thiz->mRear = &thiz->mBufferArray[0]; 171e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi // reset the queue state 172e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi thiz->mState.count = 0; 173e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi thiz->mState.index = 0; 174e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi // reset the individual buffers 175e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi for (XAuint16 i=0 ; i<(thiz->mNumBuffers + 1) ; i++) { 176e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi thiz->mBufferArray[i].mDataBuffer = NULL; 177e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi thiz->mBufferArray[i].mDataSize = 0; 178e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi thiz->mBufferArray[i].mDataSizeConsumed = 0; 17937dc2fccf3f122b79ebd554de209d0a3c94ae161Jean-Michel Trivi thiz->mBufferArray[i].mBufferContext = NULL; 1801c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi thiz->mBufferArray[i].mBufferState = SL_ANDROIDBUFFERQUEUEEVENT_NONE; 181e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi switch (thiz->mBufferType) { 182e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi case kAndroidBufferTypeMpeg2Ts: 183e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi thiz->mBufferArray[i].mItems.mTsCmdData.mTsCmdCode = ANDROID_MP2TSEVENT_NONE; 184e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi thiz->mBufferArray[i].mItems.mTsCmdData.mPts = 0; 185e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi break; 186e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi default: 187e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi result = SL_RESULT_CONTENT_UNSUPPORTED; 188e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi } 189e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi } 190e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi 191e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi if (SL_RESULT_SUCCESS == result) { 192e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi // object-specific behavior for a clear 193e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi switch (InterfaceToObjectID(thiz)) { 194e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi case SL_OBJECTID_AUDIOPLAYER: 195e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi result = SL_RESULT_SUCCESS; 196e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi android_audioPlayer_androidBufferQueue_clear_l((CAudioPlayer*) thiz->mThis); 197e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi break; 198e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi case XA_OBJECTID_MEDIAPLAYER: 199e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi result = SL_RESULT_SUCCESS; 200e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi android_Player_androidBufferQueue_clear_l((CMediaPlayer*) thiz->mThis); 201e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi break; 202e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi default: 203e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi result = SL_RESULT_PARAMETER_INVALID; 204e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi } 205e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi } 206fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi 207bcc5c7225e3b7a1dbf2e9e830987f69167acf06fGlenn Kasten interface_unlock_exclusive(thiz); 208fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi 209fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi SL_LEAVE_INTERFACE 210fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi} 211fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi 212fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi 2131c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivistatic SLresult IAndroidBufferQueue_Enqueue(SLAndroidBufferQueueItf self, 21437dc2fccf3f122b79ebd554de209d0a3c94ae161Jean-Michel Trivi void *pBufferContext, 21537dc2fccf3f122b79ebd554de209d0a3c94ae161Jean-Michel Trivi void *pData, 216d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi SLuint32 dataLength, 217d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi const SLAndroidBufferItem *pItems, 218d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi SLuint32 itemsLength) 219fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi{ 220fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi SL_ENTER_INTERFACE 221bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi SL_LOGD("IAndroidBufferQueue_Enqueue pData=%p dataLength=%d", pData, dataLength); 222fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi 223d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi if ( ((NULL == pData) || (0 == dataLength)) 224d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi && ((NULL == pItems) || (0 == itemsLength))) { 225d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi // no data and no msg 226d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi SL_LOGE("Enqueue failure: trying to enqueue buffer with no data and no items."); 227d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi result = SL_RESULT_PARAMETER_INVALID; 228d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi } else { 229d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi IAndroidBufferQueue *thiz = (IAndroidBufferQueue *) self; 230fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi 23170c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi // buffer size check, can be done outside of lock because buffer type can't change 23270c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi switch (thiz->mBufferType) { 23370c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi case kAndroidBufferTypeMpeg2Ts: 23470c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi if (dataLength % MPEG2_TS_BLOCK_SIZE == 0) { 23570c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi break; 23670c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi } 237e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi SL_LOGE("Error enqueueing MPEG-2 TS data: size must be a multiple of %d (block size)", 23870c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi MPEG2_TS_BLOCK_SIZE); 239bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi result = SL_RESULT_PARAMETER_INVALID; 240bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi SL_LEAVE_INTERFACE 241bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi break; 242bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi case kAndroidBufferTypeAacadts: 243bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi // FIXME allow commands as for mp2ts 244bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi if (!android::AacBqToPcmCbRenderer::validateBufferStartEndOnFrameBoundaries( 245bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi pData, dataLength)) { 246bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi SL_LOGE("Error enqueueing ADTS data: data must start and end on frame boundaries"); 247bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi result = SL_RESULT_PARAMETER_INVALID; 248bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi SL_LEAVE_INTERFACE 249bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi } 250bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi break; 25170c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi case kAndroidBufferTypeInvalid: 25270c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi default: 25370c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi result = SL_RESULT_PARAMETER_INVALID; 25470c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi SL_LEAVE_INTERFACE 25570c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi } 25670c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi 257d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi interface_lock_exclusive(thiz); 258fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi 259d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi AdvancedBufferHeader *oldRear = thiz->mRear, *newRear; 260d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi if ((newRear = oldRear + 1) == &thiz->mBufferArray[thiz->mNumBuffers + 1]) { 261d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi newRear = thiz->mBufferArray; 262d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi } 263d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi if (newRear == thiz->mFront) { 264d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi result = SL_RESULT_BUFFER_INSUFFICIENT; 265d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi } else { 266d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi oldRear->mDataBuffer = pData; 267d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi oldRear->mDataSize = dataLength; 268d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi oldRear->mDataSizeConsumed = 0; 26937dc2fccf3f122b79ebd554de209d0a3c94ae161Jean-Michel Trivi oldRear->mBufferContext = pBufferContext; 2701c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi oldRear->mBufferState = SL_ANDROIDBUFFERQUEUEEVENT_NONE; 271d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi thiz->mRear = newRear; 272d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi ++thiz->mState.count; 27370c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi setItems(pItems, itemsLength, thiz->mBufferType, oldRear); 274d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi result = SL_RESULT_SUCCESS; 275d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi } 276d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi // set enqueue attribute if state is PLAYING and the first buffer is enqueued 277d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi interface_unlock_exclusive_attributes(thiz, ((SL_RESULT_SUCCESS == result) && 278d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi (1 == thiz->mState.count) && (SL_PLAYSTATE_PLAYING == getAssociatedState(thiz))) ? 27970c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi ATTR_ABQ_ENQUEUE : ATTR_NONE); 280eae4df541ba1d46f65d37e959baf2127aa632c93Jean-Michel Trivi } 281fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi 282fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi SL_LEAVE_INTERFACE 283fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi} 284fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi 285fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi 2861c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivistatic SLresult IAndroidBufferQueue_GetState(SLAndroidBufferQueueItf self, 287e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi SLAndroidBufferQueueState *pState) 288e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi{ 289e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi SL_ENTER_INTERFACE 290e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi 291e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi // Note that GetState while a Clear is pending is equivalent to GetState before the Clear 292e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi 293e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi if (NULL == pState) { 294e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi result = SL_RESULT_PARAMETER_INVALID; 295e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi } else { 296e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi IAndroidBufferQueue *thiz = (IAndroidBufferQueue *) self; 297e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi 298e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi interface_lock_shared(thiz); 299e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi 300e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi pState->count = thiz->mState.count; 301e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi pState->index = thiz->mState.index; 302e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi 303e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi interface_unlock_shared(thiz); 304e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi 305e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi result = SL_RESULT_SUCCESS; 306e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi } 307e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi 308e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi SL_LEAVE_INTERFACE 309e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi} 310e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi 311e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi 3121c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivistatic SLresult IAndroidBufferQueue_SetCallbackEventsMask(SLAndroidBufferQueueItf self, 3131c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi SLuint32 eventFlags) 3141c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi{ 3151c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi SL_ENTER_INTERFACE 3161c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi 3171c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi IAndroidBufferQueue *thiz = (IAndroidBufferQueue *) self; 3181c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi interface_lock_exclusive(thiz); 3191c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi // FIXME only supporting SL_ANDROIDBUFFERQUEUEEVENT_PROCESSED in this implementation 3201c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi if ((SL_ANDROIDBUFFERQUEUEEVENT_PROCESSED == eventFlags) || 3211c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi (SL_ANDROIDBUFFERQUEUEEVENT_NONE == eventFlags)) { 3221c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi thiz->mCallbackEventsMask = eventFlags; 3231c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi result = SL_RESULT_SUCCESS; 3241c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi } else { 3251c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi result = SL_RESULT_FEATURE_UNSUPPORTED; 3261c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi } 3271c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi interface_unlock_exclusive(thiz); 3281c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi 3291c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi SL_LEAVE_INTERFACE 3301c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi} 3311c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi 3321c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi 3331c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivistatic SLresult IAndroidBufferQueue_GetCallbackEventsMask(SLAndroidBufferQueueItf self, 3341c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi SLuint32 *pEventFlags) 3351c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi{ 3361c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi SL_ENTER_INTERFACE 3371c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi 3381c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi if (NULL == pEventFlags) { 3391c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi result = SL_RESULT_PARAMETER_INVALID; 3401c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi } else { 3411c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi IAndroidBufferQueue *thiz = (IAndroidBufferQueue *) self; 3421c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi interface_lock_peek(thiz); 3431c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi SLuint32 callbackEventsMask = thiz->mCallbackEventsMask; 3441c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi interface_unlock_peek(thiz); 3451c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi *pEventFlags = callbackEventsMask; 3461c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi result = SL_RESULT_SUCCESS; 3471c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi } 3481c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi 3491c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi SL_LEAVE_INTERFACE 3501c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi} 3511c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi 3521c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi 353fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivistatic const struct SLAndroidBufferQueueItf_ IAndroidBufferQueue_Itf = { 354fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi IAndroidBufferQueue_RegisterCallback, 355fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi IAndroidBufferQueue_Clear, 356e7bfcdc183454ec959ff51342f0973cabba219b2Jean-Michel Trivi IAndroidBufferQueue_Enqueue, 3571c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi IAndroidBufferQueue_GetState, 3581c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi IAndroidBufferQueue_SetCallbackEventsMask, 3591c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi IAndroidBufferQueue_GetCallbackEventsMask 360fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi}; 361fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi 362d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi 363fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivivoid IAndroidBufferQueue_init(void *self) 364fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi{ 365bcc5c7225e3b7a1dbf2e9e830987f69167acf06fGlenn Kasten IAndroidBufferQueue *thiz = (IAndroidBufferQueue *) self; 366bcc5c7225e3b7a1dbf2e9e830987f69167acf06fGlenn Kasten thiz->mItf = &IAndroidBufferQueue_Itf; 367fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi 368d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi thiz->mState.count = 0; 369d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi thiz->mState.index = 0; 370d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi 371bcc5c7225e3b7a1dbf2e9e830987f69167acf06fGlenn Kasten thiz->mCallback = NULL; 372bcc5c7225e3b7a1dbf2e9e830987f69167acf06fGlenn Kasten thiz->mContext = NULL; 3731c853a41d9d9886e60618a7c878ce3912f46bf3cJean-Michel Trivi thiz->mCallbackEventsMask = SL_ANDROIDBUFFERQUEUEEVENT_PROCESSED; 374d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi 37570c49ae2867094072a4365423417ea452bf82231Jean-Michel Trivi thiz->mBufferType = kAndroidBufferTypeInvalid; 376d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi thiz->mBufferArray = NULL; 377d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi thiz->mFront = NULL; 378d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi thiz->mRear = NULL; 379d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi} 380d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi 381d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi 382d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivivoid IAndroidBufferQueue_deinit(void *self) 383d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi{ 384d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi IAndroidBufferQueue *thiz = (IAndroidBufferQueue *) self; 385d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi if (NULL != thiz->mBufferArray) { 386d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi free(thiz->mBufferArray); 387d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi thiz->mBufferArray = NULL; 388d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi } 389fa62f9f2c20b446178c05e3e92407fe5dfdbf8a1Jean-Michel Trivi} 390