jsbindings/jsbindings.cpp
/**
 * @brief Callback invoked when an object of AAMP is finalized
 *
 * @param[in] thisObj JSObject being finalized
 */
@brief Callback invoked when an object of AAMP is finalized
@param[in] thisObj JSObject being finalized
@brief Callback invoked when an object of AAMP is finalized @param [ in ] thisObj JSObject being finalized
static void AAMP_finalize(JSObjectRef thisObject)
{
	LOG("[AAMP_JS] %s(): object=%p", __FUNCTION__, thisObject);
	AAMP_JS* pAAMP = (AAMP_JS*)JSObjectGetPrivate(thisObject); 
	if (pAAMP == NULL)
	{
		ERROR("[AAMP_JS] %s() Error: JSObjectGetPrivate returned NULL!", __FUNCTION__);
		return;
	}
	JSObjectSetPrivate(thisObject, NULL);
	while (pAAMP->_listeners != NULL)
	{
		AAMPEventType eventType = pAAMP->_listeners->_type;
		JSObjectRef   jsCallback  = pAAMP->_listeners->_jsCallback;
		AAMP_JSListener::RemoveEventListener(pAAMP, eventType, jsCallback);
	}
	if (pAAMP->_ctx != NULL) {
		JSValueUnprotect(pAAMP->_ctx, pAAMP->_eventType);
		if(pAAMP->_subscribedTags) {
			JSValueUnprotect(pAAMP->_ctx, pAAMP->_subscribedTags);
		}
	}
	pthread_mutex_lock(&mutex);
	if (NULL != _allocated_aamp)
	{
		_allocated_aamp->Stop();
		LOG("[AAMP_JS] %s:%d delete aamp %p\n", __FUNCTION__, __LINE__, _allocated_aamp);
		delete _allocated_aamp;
		_allocated_aamp = NULL;
	}
	pthread_mutex_unlock(&mutex);
	delete pAAMP;
}
static void AAMP_finalize ( JSObjectRef thisObject ) { LOG ( " " , __FUNCTION__ , thisObject ) ; AAMP_JS * pAAMP = ( AAMP_JS * ) JSObjectGetPrivate ( thisObject ) ; if ( pAAMP == NULL ) { ERROR ( " " , __FUNCTION__ ) ; return ; } JSObjectSetPrivate ( thisObject , NULL ) ; while ( pAAMP -> _listeners != NULL ) { AAMPEventType eventType = pAAMP -> _listeners -> _type ; JSObjectRef jsCallback = pAAMP -> _listeners -> _jsCallback ; AAMP_JSListener :: RemoveEventListener ( pAAMP , eventType , jsCallback ) ; } if ( pAAMP -> _ctx != NULL ) { JSValueUnprotect ( pAAMP -> _ctx , pAAMP -> _eventType ) ; if ( pAAMP -> _subscribedTags ) { JSValueUnprotect ( pAAMP -> _ctx , pAAMP -> _subscribedTags ) ; } } pthread_mutex_lock ( & mutex ) ; if ( NULL != _allocated_aamp ) { _allocated_aamp -> Stop ( ) ; LOG ( " \n " , __FUNCTION__ , __LINE__ , _allocated_aamp ) ; delete _allocated_aamp ; _allocated_aamp = NULL ; } pthread_mutex_unlock ( & mutex ) ; delete pAAMP ; }
@brief Callback invoked when an object of AAMP is finalized
 @param[in] thisObj JSObject being finalized
@brief Callback invoked when an object of AAMP is finalized @param [ in ] thisObj JSObject being finalized