コード例 #1
0
void RDHPIRecordStream::tickClock()
{
  HPI_InStreamGetInfoEx(hpi_subsys,hpi_stream,
			&state,&buffer_size,&data_recorded,
			&samples_recorded,&reserved);
  if((!record_started)&&(is_recording)) {
    if(samples_recorded>0) {
      if(record_length>0) {
        length_timer->start(record_length,true);
      }
      emit recordStart();
      emit stateChanged(card_number,stream_number,4);  // RecordStarted
      if(debug) {
	printf("RDHPIRecordStream: emitted recordStart()\n");
	printf("RDHPIRecordStream: emitted stateChanged(%d,%d,RDHPIRecordStream::RecordStarted)\n",card_number,stream_number);
      }
      record_started=true;
    }
  }
  while(data_recorded>fragment_size) {
#if HPI_VER > 0x00030500
    HPI_InStreamReadBuf(hpi_subsys,hpi_stream,pdata,fragment_size);
#else
    HPI_InStreamRead(hpi_subsys,hpi_stream,&hpi_data);
#endif
    if(is_recording) {
      writeWave(pdata,fragment_size);
    }
    HPI_InStreamGetInfoEx(hpi_subsys,hpi_stream,
			  &state,&buffer_size,&data_recorded,
			  &samples_recorded,&reserved);
  }
  if(state==HPI_STATE_STOPPED) {
#if HPI_VER > 0x00030500
    HPI_InStreamReadBuf(hpi_subsys,hpi_stream,pdata,data_recorded);
#else
    HPI_DataCreate(&hpi_data,&format,pdata,data_recorded);
    HPI_InStreamRead(hpi_subsys,hpi_stream,&hpi_data);
#endif
    if(is_recording) {
      writeWave(pdata,data_recorded);
    }
  }
  emit position(samples_recorded);
  if(debug) {
    printf("RDHPIRecordStream: emitted position(%u)\n",
	   (unsigned)samples_recorded);
  }
}
コード例 #2
0
void AsiHpiDevice::readData()
{
#ifdef ASIHPI
    uint16_t state=0;
    uint32_t buffer_size=0;
    uint32_t data_recorded=0;
    uint32_t samples_recorded=0;
    uint32_t aux_data_recorded=0;

    HpiLog(HPI_InStreamGetInfoEx(NULL,asihpi_input_stream,&state,&buffer_size,
                                 &data_recorded,&samples_recorded,
                                 &aux_data_recorded));
    if(state==HPI_STATE_RECORDING) {
        if(HpiLog(HPI_InStreamReadBuf(NULL,asihpi_input_stream,asihpi_pcm_buffer,
                                      data_recorded))==0) {
            for(unsigned i=0; i<ringBufferQuantity(); i++) {
                ringBuffer(i)->write((float *)asihpi_pcm_buffer,
                                     data_recorded/(sizeof(float)*channels()));
            }
        }
    }
    else {
        Log(LOG_WARNING,"not in recording state"+
            QString().sprintf(" [state: %u]",state));
    }


#endif  // ASIHPI
}