示例#1
0
void CVDPAU::BindPixmap()
{
  CSharedLock lock(m_DecoderSection);

  { CSharedLock dLock(m_DisplaySection);
    if (m_DisplayState != VDPAU_OPEN)
      return;
  }

  if (m_glPixmap)
  {
    if(presentSurface != VDP_INVALID_HANDLE)
    {
      VdpPresentationQueueStatus status;
      VdpTime time;
      VdpStatus vdp_st;
      vdp_st = vdp_presentation_queue_query_surface_status(
                    vdp_flip_queue, presentSurface, &status, &time);
      CheckStatus(vdp_st, __LINE__);
      while(status != VDP_PRESENTATION_QUEUE_STATUS_VISIBLE && vdp_st == VDP_STATUS_OK)
      {
        Sleep(1);
        vdp_st = vdp_presentation_queue_query_surface_status(
                      vdp_flip_queue, presentSurface, &status, &time);
        CheckStatus(vdp_st, __LINE__);
      }
    }
    
    glXBindTexImageEXT(m_Display, m_glPixmap, GLX_FRONT_LEFT_EXT, NULL);
  }
  else CLog::Log(LOGERROR,"(VDPAU) BindPixmap called without valid pixmap");
}
示例#2
0
bool CVDPAU::GetPicture(AVCodecContext* avctx, AVFrame* frame, DVDVideoPicture* picture)
{
  CSharedLock lock(m_DecoderSection);

  { CSharedLock dLock(m_DisplaySection);
    if (m_DisplayState != VDPAU_OPEN)
      return false;
  }

  *picture = m_DVDVideoPics.front();
  // if this is the first field of an interlaced frame, we'll need
  // this same picture for the second field later
  if (m_mixerstep != 1)
    m_DVDVideoPics.pop();

  picture->format = DVDVideoPicture::FMT_VDPAU;
  picture->iFlags &= DVP_FLAG_DROPPED;
  picture->iWidth = OutWidth;
  picture->iHeight = OutHeight;
  picture->vdpau = this;

  if(m_mixerstep)
  {
    picture->iRepeatPicture = -0.5;
    if(m_mixerstep > 1)
    {
      picture->dts = DVD_NOPTS_VALUE;
      picture->pts = DVD_NOPTS_VALUE;
    }
  }
  return true;
}
示例#3
0
void SynchCorrection::Reset(bool soft)
{
  Log("SynchCorrection::Reset %u", soft);
  m_dBiasCorrection = 0.0001;
  m_iBiasDir = 0;
  //m_dlastAdjustment = 1.0;
  
  if (!soft)
  {
    CAutoLock lock(&m_csSampleQueueLock);
    m_rtStart = 0;
    m_dEVRAudioDelay = 0.0;
    m_dlastAdjustment = 1.0;
    m_iQualityDir = 0;
    m_bQualityCorrectionOn = false;
    m_rtAHwStartSet = false;
    m_rtAHwStart = 0;

    {
      CAutoLock dLock(&m_csDeltaLock);
      m_dDeltaError = 0.0;
    }

    SetBias(1.0);
    SetAdjustment(1.0);
    Flush();
  }
}
示例#4
0
void CVDPAU::FFDrawSlice(struct AVCodecContext *s,
                                           const AVFrame *src, int offset[4],
                                           int y, int type, int height)
{
  CDVDVideoCodecFFmpeg* ctx = (CDVDVideoCodecFFmpeg*)s->opaque;
  CVDPAU*               vdp = (CVDPAU*)ctx->GetHardware();

  // while we are waiting to recover we can't do anything
  CSharedLock lock(vdp->m_DecoderSection);

  { CSharedLock dLock(vdp->m_DisplaySection);
    if(vdp->m_DisplayState != VDPAU_OPEN)
      return;
  }


  if(src->linesize[0] || src->linesize[1] || src->linesize[2]
  || offset[0] || offset[1] || offset[2])
  {
    CLog::Log(LOGERROR, "CVDPAU::FFDrawSlice - invalid linesizes or offsets provided");
    return;
  }

  VdpStatus vdp_st;
  vdpau_render_state * render;

  render = (vdpau_render_state*)src->data[0];
  if(!render)
  {
    CLog::Log(LOGERROR, "CVDPAU::FFDrawSlice - invalid context handle provided");
    return;
  }

  // ffmpeg vc-1 decoder does not flush, make sure the data buffer is still valid
  if (!vdp->IsSurfaceValid(render))
  {
    CLog::Log(LOGWARNING, "CVDPAU::FFDrawSlice - ignoring invalid buffer");
    return;
  }

  uint32_t max_refs = 0;
  if(s->pix_fmt == PIX_FMT_VDPAU_H264)
    max_refs = render->info.h264.num_ref_frames;

  if(vdp->decoder == VDP_INVALID_HANDLE
  || vdp->vdpauConfigured == false
  || vdp->max_references < max_refs)
  {
    if(!vdp->ConfigVDPAU(s, max_refs))
      return;
  }

  vdp_st = vdp->vdp_decoder_render(vdp->decoder,
                                   render->surface,
                                   (VdpPictureInfo const *)&(render->info),
                                   render->bitstream_buffers_used,
                                   render->bitstream_buffers);
  vdp->CheckStatus(vdp_st, __LINE__);
}
示例#5
0
void DeviceMuxer::clear()
{
	if (_device)
		_device->readAll();
	QMutexLocker rLock(_readLock);
	_buffer.clear();
	rLock.unlock();
	QMutexLocker dLock(_dataLock);
	_data.clear();
}
示例#6
0
void CVDPAU::ReleasePixmap()
{
  CSharedLock lock(m_DecoderSection);

  { CSharedLock dLock(m_DisplaySection);
    if (m_DisplayState != VDPAU_OPEN)
      return;
  }

  if (m_glPixmap)
  {
    glXReleaseTexImageEXT(m_Display, m_glPixmap, GLX_FRONT_LEFT_EXT);
  }
  else CLog::Log(LOGERROR,"(VDPAU) ReleasePixmap called without valid pixmap");
}
示例#7
0
void InStream::routeUpdateHook() {
	AutoMutex dLock(mDev.mLock);
	AutoMutex sLock(mLock);
	int newDevices = -1;
	mParameters.get(AUDIO_PARAMETER_STREAM_ROUTING, newDevices);
	if (mDevices != newDevices && newDevices != -1) {
		ALOGD("Devices changed from 0x%08x to 0x%08x", mDevices, newDevices);
		mDevices = (audio_devices_t) newDevices;
		mDbgStr.clear();
		deviceUpdatePrepare();
		deviceUpdateFinish();
	}
	else
		ALOGE("Bogus device update 0x%08x", newDevices);
}
示例#8
0
void DeviceMuxer::handleReadyRead()
{
    if (!_device)
        return;

    channel_t chan;
    quint16  dataSize;
    int hdrSize = sizeof(chan) + sizeof(dataSize);

    QMutexLocker rLock(_readLock);
    _buffer.append(_device->readAll());
    rLock.unlock();

    while (_buffer.size() >= hdrSize) {
        rLock.relock();
        // read the channel no. and size from the device
        // Extract the channel no.
        memcpy(&chan, _buffer.constData(), sizeof(chan));
        // Extract the size
        memcpy(&dataSize, _buffer.constData() + sizeof(chan), sizeof(dataSize));
        // Now try to read out the data
        while (_buffer.size() < hdrSize + dataSize) {
            QCoreApplication::processEvents();
            _buffer.append(_device->readAll());
        }
        QMutexLocker dLock(_dataLock);
        _data[chan].append(_buffer.constData() + hdrSize, dataSize);
        dLock.unlock();

        _buffer.remove(0, hdrSize + dataSize);
        // Release the read lock
        rLock.unlock();

        // Emit a signal after all locks are released
        _readyReadEmitted[chan] = true;
        emit readyRead(chan);

        rLock.relock();
        _buffer.append(_device->readAll());
        rLock.unlock();
    }
}
示例#9
0
void CVDPAU::Present()
{
  //CLog::Log(LOGNOTICE,"%s",__FUNCTION__);
  VdpStatus vdp_st;

  CSharedLock lock(m_DecoderSection);

  { CSharedLock dLock(m_DisplaySection);
    if (m_DisplayState != VDPAU_OPEN)
      return;
  }

  presentSurface = outputSurface;

  vdp_st = vdp_presentation_queue_display(vdp_flip_queue,
                                          presentSurface,
                                          0,
                                          0,
                                          0);
  CheckStatus(vdp_st, __LINE__);
}
示例#10
0
int CVDPAU::FFGetBuffer(AVCodecContext *avctx, AVFrame *pic)
{
  //CLog::Log(LOGNOTICE,"%s",__FUNCTION__);
  CDVDVideoCodecFFmpeg* ctx        = (CDVDVideoCodecFFmpeg*)avctx->opaque;
  CVDPAU*               vdp        = (CVDPAU*)ctx->GetHardware();
  struct pictureAge*    pA         = &vdp->picAge;

  // while we are waiting to recover we can't do anything
  CSharedLock lock(vdp->m_DecoderSection);

  { CSharedLock dLock(vdp->m_DisplaySection);
    if(vdp->m_DisplayState != VDPAU_OPEN)
    {
      CLog::Log(LOGWARNING, "CVDPAU::FFGetBuffer - returning due to awaiting recovery");
      return -1;
    }
  }

  vdpau_render_state * render = NULL;

  // find unused surface
  for(unsigned int i = 0; i < vdp->m_videoSurfaces.size(); i++)
  {
    if(!(vdp->m_videoSurfaces[i]->state & (FF_VDPAU_STATE_USED_FOR_REFERENCE | FF_VDPAU_STATE_USED_FOR_RENDER)))
    {
      render = vdp->m_videoSurfaces[i];
      render->state = 0;
      break;
    }
  }

  VdpStatus vdp_st = VDP_STATUS_ERROR;
  if (render == NULL)
  {
    // create a new surface
    VdpDecoderProfile profile;
    ReadFormatOf(avctx->pix_fmt, profile, vdp->vdp_chroma_type);
    render = (vdpau_render_state*)calloc(sizeof(vdpau_render_state), 1);
    if (render == NULL)
    {
      CLog::Log(LOGWARNING, "CVDPAU::FFGetBuffer - calloc failed");
      return -1;
    }
    vdp_st = vdp->vdp_video_surface_create(vdp->vdp_device,
                                           vdp->vdp_chroma_type,
                                           avctx->coded_width,
                                           avctx->coded_height,
                                           &render->surface);
    vdp->CheckStatus(vdp_st, __LINE__);
    if (vdp_st != VDP_STATUS_OK)
    {
      free(render);
      CLog::Log(LOGERROR, "CVDPAU::FFGetBuffer - No Video surface available could be created");
      return -1;
    }
    vdp->m_videoSurfaces.push_back(render);
  }

  if (render == NULL)
    return -1;

  pic->data[1] =  pic->data[2] = NULL;
  pic->data[0]= (uint8_t*)render;

  pic->linesize[0] = pic->linesize[1] =  pic->linesize[2] = 0;

  if(pic->reference)
  {
    pic->age = pA->ip_age[0];
    pA->ip_age[0]= pA->ip_age[1]+1;
    pA->ip_age[1]= 1;
    pA->b_age++;
  }
  else
  {
    pic->age = pA->b_age;
    pA->ip_age[0]++;
    pA->ip_age[1]++;
    pA->b_age = 1;
  }
  pic->type= FF_BUFFER_TYPE_USER;

  render->state |= FF_VDPAU_STATE_USED_FOR_REFERENCE;
  pic->reordered_opaque= avctx->reordered_opaque;
  return 0;
}
int DroidStimpackModuleDataComponent::handleObjectMenuSelect(CreatureObject* player, byte selectedID, PetControlDevice* controller) {

    ManagedReference<DroidObject*> droid = getDroidObject();
    DroidComponent* droidComponent = cast<DroidComponent*>(getParent());
    if( droid == NULL || droidComponent == NULL) {
        player->sendSystemMessage("@pet/droid_modules:stimpack_error");
        return 0;
    }
    if( selectedID == LOAD_STIMPACK ) {
        Locker dLock(droid);
        Locker crossLoker(player,droid);
        ManagedReference<SceneObject*> inventory = player->getSlottedObject("inventory");
        if (inventory == NULL) {
            player->sendSystemMessage("@pet/droid_modules:no_stimpacks");
            return 0;
        }
        int foundStims = 0;
        for (int i = 0; i < inventory->getContainerObjectsSize(); ++i) {
            SceneObject* item = inventory->getContainerObject(i);

            if (!item->isTangibleObject())
                continue;

            TangibleObject* tano = cast<TangibleObject*>( item);
            // check it they have atleast 1 stim pack
            if (tano->isPharmaceuticalObject()) {
                PharmaceuticalObject* pharma = cast<PharmaceuticalObject*>( tano);
                if (pharma->isStimPack()) {
                    StimPack* stim = cast<StimPack*>(pharma);
                    if (stim->isClassA()) {
                        foundStims += 1;
                    }
                }
            }
        }
        if (foundStims == 0) {
            player->sendSystemMessage("@pet/droid_modules:no_stimpacks");
            return 0;
        } else {
            sendLoadUI(player);
            return 0;
        }
    }
    if( selectedID == REQUEST_STIMPACK ) {
        // we need to check cooldown on droid
        if( droid->isDead() || droid->isIncapacitated() || player->isDead()) {
            return 0;
        }

        // Droid must have power
        if( !droid->hasPower() ) {
            droid->showFlyText("npc_reaction/flytext","low_power", 204, 0, 0);  // "*Low Power*"
            return 0;
        }
        if(droid->getPendingTask("droid_request_stimpack") != NULL) {
            player->sendSystemMessage("@pet/droid_modules:stimpack_not_ready");
            return 0;
        }
        // Submit repair task
        Reference<Task*> task = new DroidStimpackTask( droid,player,controller->getCustomObjectName().toString() );
        droid->addPendingTask("droid_request_stimpack", task, 1); // rte determines when it will fire it
    }
    return 0;
}