Example #1
0
File: segment.cpp Project: KDE/kget
void Segment::slotData(KIO::Job *, const QByteArray& _data)
{
    // Check if the transfer allows resuming...
    if (m_offset && !m_canResume)
    {
        kDebug(5001) << m_url << "does not allow resuming.";
        stopTransfer();
        setStatus(Killed, false );
        const QString errorText = KIO::buildErrorString(KIO::ERR_CANNOT_RESUME, m_url.prettyUrl());
        emit error(this, errorText, Transfer::Log_Warning);
        return;
    }

    m_buffer.append(_data);
    if (!m_findFilesize && m_totalBytesLeft && static_cast<uint>(m_buffer.size()) >= m_totalBytesLeft)
    {
        kDebug(5001) << "Segment::slotData() buffer full. stoping transfer...";//TODO really stop it? is this even needed?
        if (m_getJob) {
            m_getJob->kill(KJob::Quietly);
            m_getJob = 0;
        }
        m_buffer.truncate(m_totalBytesLeft);
        slotWriteRest();
    }
    else
    { 
    /* 
     write to the local file only if the buffer has more than 100kbytes
     this hack try to avoid too much cpu usage. it seems to be due KIO::Filejob
     so remove it when it works property
    */
    if (m_buffer.size() > MultiSegKioSettings::saveSegSize() * 1024)
        writeBuffer();
    }
}
Example #2
0
// PS3 Disconnect
int serverDisconnect() {

  if (!s_connected) {
    return MOVE_CLIENT_OK;

  }

  // Update internal state
  s_connected = FALSE;

  // Stop UpdateMoveState thread
  if (s_transferring) {
    stopTransfer();

  }

  // Clear file descriptor
  FD_CLR(s_transfer_sockfd, &s_fd_read);
  FD_CLR(s_transfer_sockfd, &s_fd_except);

  // Best effort attempt to cleanly close tranfer socket
  close(s_transfer_sockfd);

  // Best effort attempt to cleanly close control socket
  shutdown(s_control_sockdf, 2);
  close(s_control_sockdf);

  return errno;

}
Example #3
0
  bool SdioDmaSdCard::writeBlocks(const void *src,uint32_t blockIndex,uint32_t numBlocks) {

    _dmaFinished=_sdioFinished=false;

    // enable the relevant interrupts

    SdioInterruptFeature::enableInterrupts(SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT | SDIO_IT_DATAEND | SDIO_IT_RXOVERR | SDIO_IT_STBITERR);
    SdioDmaChannelInterruptFeature::enableInterrupts(SdioDmaChannelInterruptFeature::COMPLETE | SdioDmaChannelInterruptFeature::TRANSFER_ERROR);

    // issue the command

    if(!writeBlocksCommand(blockIndex,BLOCK_SIZE,numBlocks))
      return false;

    // use DMA to transfer the data

    beginWrite(src,numBlocks*BLOCK_SIZE);

    // wait for completion or error and issue the stop transfer command

    if(!waitForTransfer() || !stopTransfer())
      return false;

    // wait for the peripheral to go quiet

    SdCardSdioFeature::waitForTransmitComplete();
    return true;
  }
Example #4
0
static void pdp_ieee1394_free(t_pdp_ieee1394 *x)
{
  //pdp_ieee1394_close(x);
  if(x->x_haveVideo)stopTransfer(x);
  //if(x->decodedbuf)delete[]decodedbuf;
  if(x->x_decoder!=NULL)dv_decoder_free(x->x_decoder);
}
Example #5
0
void pix_videoDarwin :: setupCapture()
{
    stopTransfer();
    SGSetChannelUsage(m_vc, 0);

    if (m_record) {
        SGSetDataOutput(m_sg,&theFSSpec,seqGrabToDisk);
        switch(m_record){

        case 1:
            SGSetChannelPlayFlags(m_vc, channelPlayAllData);
            SGSetChannelUsage(m_vc, seqGrabRecord | seqGrabPlayDuringRecord);
            post("record full preview");
            break;
        case 2:
            SGSetChannelUsage(m_vc, seqGrabRecord | seqGrabPlayDuringRecord);
            post("record some preview");
            break;
        case 3:
            SGSetChannelUsage(m_vc, seqGrabRecord);
            post("record no preview");
            break;
        default:
            SGSetChannelUsage(m_vc, seqGrabRecord);
        }
    }
    else {
        SGSetChannelUsage(m_vc, seqGrabPreview);
    }
    SGUpdate(m_sg,0);

    startTransfer();
}
Example #6
0
// Public functions
int startTransfer(void) {
  int res;

  if (s_transferring) {
    return MOVE_CLIENT_OK;

  }

  // Update state
  s_transferring = TRUE;

  // Run update loop in a separate thread
  if ((res = pthread_create(&s_update_move_state_thread, NULL, (void *)&updateMoveState, s_move_state_deferred))) {
    stopTransfer();
    return MOVE_CLIENT_ERROR;

  }

  return MOVE_CLIENT_OK;

}
Example #7
0
/////////////////////////////////////////////////////////
// colorspaceMess
//
/////////////////////////////////////////////////////////
void pix_videoDarwin :: csMess(int format)
{
    m_colorspace = format;
    if (format == GL_RGBA) {
     post("colorspace is GL_RGBA %d",m_colorspace);
    } else if (format == GL_BGRA_EXT) {
      post("colorspace is GL_RGBA %d",m_colorspace);
    } else if (format == GL_YCBCR_422_GEM) {
      post("colorspace is YUV %d",m_colorspace);
    } else if (format == GL_LUMINANCE) {
        post("'Gray' not yet supported...using YUV");
        format=GL_YCBCR_422_GEM;
    } else {
      error("colorspace is unknown %d", m_colorspace);
      return;
    }

    stopTransfer();
    resetSeqGrabber();
    startTransfer();
}
Example #8
0
/////////////////////////////////////////////////////////
// dimenMess
//
/////////////////////////////////////////////////////////
void pix_videoDarwin :: dimenMess(int x, int y, int leftmargin, int rightmargin,
    int topmargin, int bottommargin)
{
    if (x > 0 ){
        m_vidXSize = (int)x;
    }else{
        m_vidXSize = 320;
    }
    if (y > 0){
        m_vidYSize = (int)y;
    }else{
        m_vidYSize = 240;
    }
    stopTransfer();
    resetSeqGrabber();
    startTransfer();
    post("height %d width %d",m_vidYSize,m_vidXSize);
//  m_pixBlock.image.xsize = m_vidXSize;
//  m_pixBlock.image.ysize = m_vidYSize;

}
Example #9
0
static int pdp_ieee1394_open(t_pdp_ieee1394 *x, t_symbol *name)
{
  x->x_devicename = name->s_name;

  if(x->x_haveVideo){
    verbose(1, "Stream already going on. Doing some clean-up...");
    stopTransfer(x);
  }

  /*
  All of the errors in this method return -1 anyhow, so fd should be 0 to allow
  successful open if everything goes ok.

  Ico Bukvic [email protected] 2-18-07
  */
  int fd = 0; 
  struct dv1394_init init = {
    DV1394_API_VERSION, // api version 
    0x63,              // isochronous transmission channel
    N_BUF,             // number of frames in ringbuffer
    (x->x_norm==NTSC)?DV1394_NTSC:DV1394_PAL,         // PAL or NTSC
    //DV1394_PAL,         // PAL or NTSC
    0, 0 , 0                // default packet rate
  };

  x->x_framesize=(x->x_norm==NTSC)?DV1394_NTSC_FRAME_SIZE:DV1394_PAL_FRAME_SIZE;
  //x->x_framesize=DV1394_PAL_FRAME_SIZE;

  if(x->x_devicename){
    if ((fd = open(x->x_devicename, O_RDWR)) < 0) {
        perror(x->x_devicename);
        return -1;
    }
  } else {
    signed char devnum=(x->x_devicenum<0)?0:(signed char)x->x_devicenum;
    char buf[256];
    buf[255]=0;buf[32]=0;buf[33]=0;
    if (devnum<0)devnum=0;
    snprintf(buf, 32, "/dev/ieee1394/dv/host%d/%s/in", devnum, (x->x_norm==NTSC)?"NTSC":"PAL");
    //snprintf(buf, 32, "/dev/ieee1394/dv/host%d/%s/in", devnum, "PAL");
    if ((fd = open(buf, O_RDWR)) < 0)    {
      snprintf(buf, 32, "/dev/dv1394/%d", devnum);
      if ((fd = open(buf, O_RDWR)) < 0) {
	if ((fd=open("/dev/dv1394", O_RDWR)) < 0)    {
	  perror(buf);
	  return -1;
	}
      }
    }
  }
  if (ioctl(fd, DV1394_INIT, &init) < 0)    {
    perror("initializing");
    close(fd);
    return -1;
  }
  
  x->x_mmapbuf = (unsigned char *) mmap( NULL, N_BUF*x->x_framesize,
				       PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
  if(x->x_mmapbuf == MAP_FAILED) {
    perror("mmap frame buffers");
    close(fd);
    return -1;
  }
  
  if(ioctl(fd, DV1394_START_RECEIVE, NULL)) {
    perror("dv1394 START_RECEIVE ioctl");
    close(fd);
    return -1;
  }
  /*Extra verbosity never hurt anyone...

  Ico Bukvic [email protected] 2-18-07
  */
  post("DV4L: Successfully opened...");
  startTransfer(x);
  x->dvfd=fd;

  return 1;
	
}