Пример #1
0
// returns bytes written, else -1 if error (0 is OK)
int AmAudio::put(unsigned long long system_ts, unsigned char* buffer, 
		 int input_sample_rate, unsigned int size)
{
  if(!size){
    return 0;
  }

  if(max_rec_time > -1 && rec_time >= max_rec_time)
    return -1;

  memcpy((unsigned char*)samples,buffer,size);
  size = resampleInput((unsigned char*)samples, size, 
		       input_sample_rate, getSampleRate());

  int s = encode(size);
  if(s>0){

    incRecordTime(bytes2samples(size));

    unsigned int wr_ts = scaleSystemTS(system_ts);
    //DBG("write(wr_ts = %10.u; s = %u)\n",wr_ts,s);
    return write(wr_ts,(unsigned int)s);
  }
  else{
    return s;
  }
}
Пример #2
0
// returns bytes written, else -1 if error (0 is OK)
int AmAudio::put(unsigned int user_ts, unsigned char* buffer, unsigned int size)
{
    if(!size){
      return 0;
    }

    if(max_rec_time > -1 && rec_time >= max_rec_time)
	return -1;
    
    memcpy((unsigned char*)samples,buffer,size);
    
    unsigned int s = encode(size);
    if(s>0) {
	//DBG("%s\n",typeid(this).name());
	incRecordTime(bytes2samples(size));
	return write(user_ts,(unsigned int)s);
    }
    else{
	return s;
    }
}