예제 #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
bool AmAudioFormat::operator == (const AmAudioFormat& r) const
{
  return ( codec && r.codec
	   && (r.codec->id == codec->id) 
	   && (r.bytes2samples(1024) == bytes2samples(1024))
	   && (r.channels == channels)
	   && (r.rate == rate));
}
예제 #3
0
bool AmAudioFormat::operator == (const AmAudioFormat& r) const
{
  return ( codec && r.codec
	   && (strlen(r.codec->name) == strlen(codec->name))
	   && (!memcmp(r.codec->name,codec->name,strlen(codec->name)))
	   && (r.bytes2samples(1024) == bytes2samples(1024))
	   && (r.channels == channels)
	   && (r.rate == rate));
}
예제 #4
0
/* Writes 'todo' mixed SBYTES (!!) to 'buf'. It returns the number of SBYTES
   actually written to 'buf' (which is rounded to number of samples that fit
   into 'todo' bytes). */
ULONG VC1_WriteBytes(SBYTE* buf,ULONG todo)
{
	if(!vc_softchn)
		return VC1_SilenceBytes(buf,todo);

	todo = bytes2samples(todo);
	VC1_WriteSamples(buf,todo);

	return samples2bytes(todo);
}
예제 #5
0
UWORD VC_WriteBytes(char *buf,UWORD todo)
/*
	Writes 'todo' mixed SBYTES (!!) to 'buf'. It returns the number of
	SBYTES actually written to 'buf' (which is rounded to number of samples
	that fit into 'todo' bytes).
*/
{
	todo=bytes2samples(todo);
	VC_WriteSamples(buf,todo);
	return samples2bytes(todo);
}
예제 #6
0
/* Fill the buffer with 'todo' bytes of silence (it depends on the mixing mode
   how the buffer is filled) */
ULONG VC1_SilenceBytes(SBYTE* buf,ULONG todo)
{
	todo=samples2bytes(bytes2samples(todo));

	/* clear the buffer to zero (16 bits signed) or 0x80 (8 bits unsigned) */
	if(vc_mode & DMODE_16BITS)
		memset(buf,0,todo);
	else
		memset(buf,0x80,todo);

	return todo;
}
예제 #7
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;
    }
}