Exemplo n.º 1
0
static void
cbjack_interleave_capture(cubeb_stream * stream, float **in, jack_nframes_t nframes, bool format_mismatch)
{
  float *in_buffer = stream->context->in_float_interleaved_buffer;

  for (unsigned int c = 0; c < stream->in_params.channels; c++) {
    for (long f = 0; f < nframes; f++) {
      in_buffer[(f * stream->in_params.channels) + c] = in[c][f] * stream->volume;
    }
  }
  if (format_mismatch) {
    float_to_s16ne(stream->context->in_resampled_interleaved_buffer_s16ne, in_buffer, nframes * stream->in_params.channels);
  } else {
    memset(stream->context->in_resampled_interleaved_buffer_float, 0, (FIFO_SIZE * MAX_CHANNELS * 3) * sizeof(float));
    memcpy(stream->context->in_resampled_interleaved_buffer_float, in_buffer, (FIFO_SIZE * MAX_CHANNELS * 2) * sizeof(float));
  }
}
Exemplo n.º 2
0
static ULONG APIENTRY
kai_callback(PVOID cbdata, PVOID buffer, ULONG len)
{
  cubeb_stream * stm = cbdata;
  void *p;
  long wanted_frames;
  long frames;
  float soft_volume;
  int elements = len / sizeof(int16_t);

  p = stm->params.format == CUBEB_SAMPLE_FLOAT32NE
      ? stm->float_buffer : buffer;

  wanted_frames = bytes_to_frames(len, stm->params);
  frames = stm->data_callback(stm, stm->user_ptr, NULL, p, wanted_frames);

  _fmutex_request(&stm->mutex, 0);
  stm->total_frames += frames;
  soft_volume = stm->soft_volume;
  _fmutex_release(&stm->mutex);

  if (frames < wanted_frames)
    stm->state_callback(stm, stm->user_ptr, CUBEB_STATE_DRAINED);

  if (stm->params.format == CUBEB_SAMPLE_FLOAT32NE)
    float_to_s16ne(buffer, p, elements);

  if (soft_volume != -1.0f) {
    int16_t *b = buffer;
    int i;

    for (i = 0; i < elements; i++)
      *b++ *= soft_volume;
  }

  return frames_to_bytes(frames, stm->params);
}