bool CXadillaXVideoPlayer::Stop()
{
    {
        LockScope oScope(m_CS);

        /** 若未载入 */
        /** If not loaded */
        if(!m_bLoaded)
        {
            return false;
        }

        /** 若已暂停 */
        /** If paused of stopped */
        if(m_bStopped)
        {
            return true;
        }

        if(m_pMediaControl == NULL)
        {
            return true;
        }
        m_nCurPlayID = -1;
    }

    __Release();
    return true;
}
Example #2
0
SQBool sq_release(HSQUIRRELVM v,HSQOBJECT *po)
{
	if(!ISREFCOUNTED(type(*po))) return SQTrue;
#ifdef NO_GARBAGE_COLLECTOR
	__Release(po->_type,po->_unVal);
	return SQFalse; //the ret val doesn't work(and cannot be fixed)
#else
	return _ss(v)->_refs_table.Release(*po);
#endif
}
Example #3
0
SQBool sq_release(HSQUIRRELVM v,HSQOBJECT *po)
{
	if(!ISREFCOUNTED(sqobjtype(*po))) return SQTrue;
#ifdef NO_GARBAGE_COLLECTOR
	bool ret = (po->_unVal.pRefCounted->_uiRef <= 1) ? SQTrue : SQFalse;
	__Release(po->_type,po->_unVal);
	return ret; //the ret val doesn't work(and cannot be fixed)
#else
	return _ss(v)->_refs_table.Release(*po);
#endif
}
Example #4
0
void SQVM::ClearStack(SQInteger last_top)
{
	SQObjectType tOldType;
	SQObjectValue unOldVal;
	while (last_top >= _top) {
		SQObjectPtr &o = _stack._vals[last_top--];
		tOldType = o._type;
		unOldVal = o._unVal;
		o._type = OT_NULL;
		o._unVal.pUserPointer = NULL;
		__Release(tOldType,unOldVal);
	}
}
CXadillaXVideoPlayer::~CXadillaXVideoPlayer()
{
    /** 进入全局临界区 */
    /** Go into the "global" critical section */
    LockScope oScope(_cs);

    /** 从播放器列表中删除自己(线程中会用到) */
    /** delete itself from the player list. (because it will be used by thread) */
    _pPlayer[m_nPlayerID] = NULL;

    /** 释放资源 */
    /** release resources */
    __Release();

    /** 退出全局临界区 */
    /** leave critical section */
}
bool CXadillaXVideoPlayer::LoadFile(const char* filename, RECT rect, HWND hWnd, bool bLoop)
{
    /** 释放上一次资源 */
    /** release the resource of previous time */
    __Release();

    LockScope oScope(m_CS);

    /** 创建Graph */
    /** create the graph */
    CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC,
        IID_IGraphBuilder, (void**)&m_pGraph);

    /** 初始化m_pGraph */
    /** init the graph */
    m_pGraph->QueryInterface(IID_IVideoWindow, (void**)&m_pVidWnd);
    m_pGraph->QueryInterface(IID_IMediaEventEx, (void**)&m_pEvent);
    m_pEvent->SetNotifyWindow((OAHWND)hWnd, WM_GRAPHNOTIFY, 0);
    m_pGraph->QueryInterface(IID_IMediaControl, (void**)&m_pMediaControl);

    /** 载入文件 */
    /** load file */
    m_hWnd = hWnd;
    WCHAR szFilename[1024];
    memcpy(szFilename, CA2WEX<1024>(filename), sizeof(szFilename));
    HRESULT hRes = m_pGraph->RenderFile(szFilename, NULL);

    /** 载入失败 */
    /** load failed */
    if(hRes != S_OK && hRes != VFW_S_AUDIO_NOT_RENDERED && hRes != VFW_S_DUPLICATE_NAME &&
        hRes != VFW_S_PARTIAL_RENDER && hRes != VFW_S_VIDEO_NOT_RENDERED)
    {
        m_bLoaded = false;

        m_pVidWnd->put_Visible(OAFALSE);
        m_pGraph->Release();
        m_pMediaControl->Release();
        m_pVidWnd->Release();
        m_pEvent->Release();

        m_pVidWnd = NULL;
        m_pGraph = NULL;
        m_pMediaControl = NULL;
        m_pEvent = NULL;

        return false;
    }

    /** 播放窗口位置 */
    /** position of the player window */
    m_pVidWnd->SetWindowPosition(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
    m_pVidWnd->put_Owner((OAHWND)hWnd);
    m_pVidWnd->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);

    m_bPlaying = true;
    m_bStopped = false;
    m_bLoop = bLoop;
    m_tagRect = rect;
    strcpy(m_szFilename, filename);
    m_bLoaded = true;
    m_nCurPlayID = -1;

    /** 刷新窗口,解决播放时黑屏问题 */
    GetClientRect(hWnd, &rect);
    InvalidateRect(hWnd, &rect, TRUE);

    return true;
}