int AmSuperPlayer::initThread() { { // Mutex::Autolock l(mMutex); mRenderTid = myTid(); mCondition.signal(); } mPlayer=CreatePlayer(); if (mPlayer!=NULL && mNotify!=NULL) { int i; Mutex::Autolock N(mNotifyMutex); for(i=0;i<oldmsg_num;i++){ mNotify(mCookie, oldmsg[i].msg,oldmsg[i].ext1,oldmsg[i].ext2); } oldmsg_num=0; subplayer_inited=true; }else{ if(mNotify!=NULL) mNotify(mCookie, MEDIA_ERROR,MEDIA_ERROR_UNKNOWN,-1); } Mutex::Autolock l(mMutex); mRenderTid = -1; mCondition.signal(); TRACE(); return 0; }
void HDMIListerner::sendState() { ALOGV("sendState"); Mutex::Autolock autoLock(mNotifyLock); if (mNotify) { mNotify(mCookie, mHDMIPlugged); } }
void PlaneControlet::injectMouseMove(int _absx, int _absy, int _absz){ if( mPick && (_absx!=mMouseX || _absy!=mMouseY) ){ Game& game = Game::getSingleton(); int sx = game.getScreenWidth(); int sy = game.getScreenHeight(); Ogre::Vector3 eye = game.getCamera()->getPosition(); Ogre::Ray A = game.getCamera()->getCameraToViewportRay( (Ogre::Real)mMouseX/(Ogre::Real)sx, (Ogre::Real)mMouseY/(Ogre::Real)sy ); Ogre::Ray B = game.getCamera()->getCameraToViewportRay( (Ogre::Real)_absx/(Ogre::Real)sx, (Ogre::Real)_absy/(Ogre::Real)sy ); /*求射线A和B在平面mPlane上的两个交点 */ Math3d::CalcResult result1 = Math3d::CalcRayPlanePoint( A,mPlane ); Math3d::CalcResult result2 = Math3d::CalcRayPlanePoint( B,mPlane ); if( result1.first && result2.first ) { mNotify( mName,result2.second-result1.second ); } mMouseX = _absx; mMouseY = _absy; } }
void RaduisControlet::injectMouseMove(int _absx, int _absy, int _absz) { if( mPick && (_absx!=mMouseX || _absy!=mMouseY) ){ Game& game = Game::getSingleton(); int sx = game.getScreenWidth(); int sy = game.getScreenHeight(); Ogre::Vector3 eye = game.getCamera()->getPosition(); Ogre::Ray B = game.getCamera()->getCameraToViewportRay( (Ogre::Real)_absx/(Ogre::Real)sx, (Ogre::Real)_absy/(Ogre::Real)sy ); Ogre::Matrix3 m3 = mNode->getLocalAxes(); Ogre::Vector3 v3 = mNode->getPosition(); Math3d::CalcResult result = Math3d::CalcRayPlanePoint( B, Ogre::Plane(m3.GetColumn(2),v3) ); if( result.first ){ Ogre::Real r = v3.distance( result.second ); Ogre::Real R = r-2*mScale; if( R <= 1 ) R = 1; setRaduis( v3,m3.GetColumn(2),R,mScale ); mNotify( mName,R ); } mMouseX = _absx; mMouseY = _absy; } mouseFocus( _absx,_absy ); }
void AmSuperPlayer::Notify(void* cookie, int msg, int ext1, int ext2) { TRACE(); Mutex::Autolock N(mNotifyMutex); LOGV("cookie=%p,msg=%x,ext1=%x,ext2=%x\n",cookie,msg,ext1,ext2); switch(msg){ case MEDIA_NOP: break; case 0x11000:/*Amlogic File type ready*/ TRACE(); mTypeReady=true; mCondition.signal(); break; break; case MEDIA_BUFFERING_UPDATE: if (mPlayer!=NULL && mNotify!=NULL) mNotify(mCookie, msg, ext1, ext2); break; case MEDIA_PREPARED: Prepared=true; case MEDIA_PLAYBACK_COMPLETE: case MEDIA_SEEK_COMPLETE: case MEDIA_SET_VIDEO_SIZE: case MEDIA_INFO: case MEDIA_ERROR: if(!mTypeReady){ mTypeReady=true; mCondition.signal(); } if(mPlayer==NULL && oldmsg_num<9 && !subplayer_inited){ oldmsg[oldmsg_num].msg=msg; oldmsg[oldmsg_num].ext1=ext1; oldmsg[oldmsg_num].ext2=ext2; oldmsg_num++; } default: if (mPlayer!=NULL && mNotify!=NULL) { mNotify(mCookie, msg, ext1, ext2); } } }
void RotateControlet::injectMouseMove(int _absx, int _absy, int _absz){ if( mPick && (_absx!=mMouseX || _absy!=mMouseY) ){ /*上一个鼠标位置和眼睛组成的射线A,新的鼠标位置和眼睛组成的射线B 它们和旋转盘相交,交点和旋转盘中心组成的矢量的角度,既是旋转角 */ Game& game = Game::getSingleton(); int sx = game.getScreenWidth(); int sy = game.getScreenHeight(); Ogre::Vector3 eye = game.getCamera()->getPosition(); Ogre::Ray A = game.getCamera()->getCameraToViewportRay( (Ogre::Real)mMouseX/(Ogre::Real)sx, (Ogre::Real)mMouseY/(Ogre::Real)sy ); Ogre::Ray B = game.getCamera()->getCameraToViewportRay( (Ogre::Real)_absx/(Ogre::Real)sx, (Ogre::Real)_absy/(Ogre::Real)sy ); //计算和旋转盘的交点,旋转盘是一个平面 //平面的法向量是Local Z轴,平面通过Local原点 Ogre::Matrix3 m3 = mNode->getLocalAxes(); Ogre::Vector3 v3 = mNode->getPosition(); Ogre::Vector3 axis(m3[0][2],m3[1][2],m3[2][2]); Ogre::Plane P(axis,v3 ); //旋转盘平面 Math3d::CalcResult result1 = Math3d::CalcRayPlanePoint( A,P ); Math3d::CalcResult result2 = Math3d::CalcRayPlanePoint( B,P ); if( result1.first && result2.first ){ //方程都有解 Ogre::Vector3 a,b; a = result1.second; b = result2.second; a -= v3;b -= v3; a.normalise(); b.normalise(); Ogre::Vector3 c = b.crossProduct(a); Ogre::Real sinv = c.length(); Ogre::Real ang = asinf(sinv); if( axis.dotProduct( c ) > 0 ) ang = -ang; mNode->rotate( axis,Ogre::Radian(ang),Ogre::Node::TS_WORLD ); mNotify( mName,axis,ang ); } mMouseX = _absx; mMouseY = _absy; } mouseFocus( _absx,_absy ); }
void OrientationControlet::injectMouseMove(int _absx, int _absy, int _absz){ if( mPick && (_absx!=mMouseX || _absy!=mMouseY) ){ /*计算和摇杆球面的交点 */ Game& game = Game::getSingleton(); int sx = game.getScreenWidth(); int sy = game.getScreenHeight(); Ogre::Vector3 eye = game.getCamera()->getPosition(); Ogre::Ray A = game.getCamera()->getCameraToViewportRay( (Ogre::Real)mMouseX/(Ogre::Real)sx, (Ogre::Real)mMouseY/(Ogre::Real)sy ); Ogre::Ray B = game.getCamera()->getCameraToViewportRay( (Ogre::Real)_absx/(Ogre::Real)sx, (Ogre::Real)_absy/(Ogre::Real)sy ); //计算和旋转盘的交点,旋转盘是一个平面 //平面的法向量是Local Z轴,平面通过Local原点 Ogre::Matrix3 m3 = mNode->getLocalAxes(); Ogre::Vector3 v3 = mNode->getPosition(); Ogre::Vector3 axis = m3.GetColumn(2); Ogre::Sphere S(v3,mRaduis); Math3d::CalcResult result1 = Math3d::CalcRaySphereNearFarPoint(A,S,mNearFar); Math3d::CalcResult result2 = Math3d::CalcRaySphereNearFarPoint(B,S,mNearFar); if( result1.first && result2.first ){//都相交 //然后使用直线的参数方程计算出具体的焦点 Ogre::Vector3 a = result1.second; Ogre::Vector3 b = result2.second; a -= v3;b -= v3; a.normalise(); b.normalise(); Ogre::Vector3 c = b.crossProduct(a); Ogre::Real sinv = c.length(); Ogre::Real ang = -asinf(sinv); c.normalise(); mNode->rotate( c,Ogre::Radian(ang),Ogre::Node::TS_WORLD ); mNotify( mName,c,ang ); } mMouseX = _absx; mMouseY = _absy; } mouseFocus( _absx,_absy ); }
void LinearControlet::injectMouseMove(int _absx, int _absy, int _absz){ if( mPick && (_absx!=mMouseX || _absy!=mMouseY) ){ /*鼠标按下点(mMouseX,mMouseY)连接眼睛的位置,在空间形成一条直线(直线A)。 同样(_absx,_absy)与眼睛相连也形成一条直线(直线B)。这两条直线可以构成一个平面(叫V平面吧)。 而LinearControlet的位置和方向在空间也形成一条直线(C)。该直线在V上的投影直线与直线A与B相交 形成一个矢量,把该矢量投影回C,形成一个移动向量。 简化点:这个问题等价与两个直线间的最短距离。A与C B与C */ Game& game = Game::getSingleton(); int sx = game.getScreenWidth(); int sy = game.getScreenHeight(); Ogre::Vector3 eye = game.getCamera()->getPosition(); Ogre::Ray A = game.getCamera()->getCameraToViewportRay( (Ogre::Real)mMouseX/(Ogre::Real)sx, (Ogre::Real)mMouseY/(Ogre::Real)sy ); Ogre::Ray B = game.getCamera()->getCameraToViewportRay( (Ogre::Real)_absx/(Ogre::Real)sx, (Ogre::Real)_absy/(Ogre::Real)sy ); Ogre::Matrix3 m3 = mNode->getLocalAxes(); Ogre::Vector3 v3 = mNode->getPosition(); //m3[0][2],m3[1][2],m3[2][2] 是Z坐标轴在世界坐标中的矢量 Ogre::Ray C(v3,Ogre::Vector3(m3[0][2],m3[1][2],m3[2][2])); Math3d::CalcResult result1 = Math3d::CalcNearPoint( C,A ); Math3d::CalcResult result2 = Math3d::CalcNearPoint( C,B ); if( result1.first && result2.first ){ Ogre::Vector3 a = result1.second; Ogre::Vector3 b = result2.second; /*将移动限制在mLimited之间,mLimited是两个直线参数 */ Ogre::Ray ray(mPosition,-mDirection); Ogre::Real t = Math3d::RayParameter( ray,v3 + b-a ); if( t < mLimited[0] ) t = mLimited[0]; if( t > mLimited[1] ) t = mLimited[1]; Ogre::Vector3 p = Math3d::RayPoint( ray,t ); mNode->setPosition( p ); mNotify( mName,p-v3 ); } mMouseX = _absx; mMouseY = _absy; } mouseFocus( _absx,_absy ); }
status_t AmSuperPlayer::seekTo(int msec) { int current=-1; TRACE(); Mutex::Autolock l(mMutex); TRACE(); if (mPlayer == 0) return UNKNOWN_ERROR; mPlayer->getCurrentPosition(¤t); if(current>=0 && (msec<(current+1500) && msec>(current-1500))) { mNotify(mCookie, MEDIA_SEEK_COMPLETE, 0, 0); return NO_ERROR; } return mPlayer->seekTo(msec); }