Ejemplo n.º 1
0
static uint32_t resampler_cb(void *userdata, float **data)
{
   audioport_t *port = userdata;
   uint32_t has_read = 0;

   if (port->sample_cb)
      has_read = port->sample_cb(port->re_pull_buffer, CELL_AUDIO_BLOCK_SAMPLES * port->channels * sizeof(int16_t), port->userdata);
   else
   {
      has_read = CELL_AUDIO_BLOCK_SAMPLES * port->channels;
      sys_lwmutex_lock(&port->lock, SYS_NO_TIMEOUT);
      uint32_t avail = fifo_read_avail(port->buffer);
      if (avail < CELL_AUDIO_BLOCK_SAMPLES * port->channels * sizeof(int16_t))
         has_read = avail / sizeof(int16_t);

      fifo_read(port->buffer, port->re_pull_buffer, has_read * sizeof(int16_t));
      sys_lwmutex_unlock(&port->lock);
      sys_lwcond_signal(&port->cond);
   }

   if (has_read < CELL_AUDIO_BLOCK_SAMPLES * port->channels * 2)
      memset(port->re_pull_buffer + has_read, 0, (CELL_AUDIO_BLOCK_SAMPLES * port->channels - has_read) * sizeof(int16_t));

   audio_convert_s16_to_float_altivec(port->re_buffer, port->re_pull_buffer, CELL_AUDIO_BLOCK_SAMPLES * port->channels);

   *data = port->re_buffer;
   return CELL_AUDIO_BLOCK_SAMPLES;
}
Ejemplo n.º 2
0
static void event_loop(uint64_t data)
#endif
{
   float out_tmp[CELL_AUDIO_BLOCK_SAMPLES * AUDIO_CHANNELS]
      __attribute__((aligned(16)));
   sys_event_queue_t id;
   sys_ipc_key_t key;
   sys_event_t event;
   ps3_audio_t *aud = data;

   cellAudioCreateNotifyEventQueue(&id, &key);
   cellAudioSetNotifyEventQueue(key);

   while (!aud->quit_thread)
   {
      sys_event_queue_receive(id, &event, SYS_NO_TIMEOUT);

      sys_lwmutex_lock(&aud->lock, SYS_NO_TIMEOUT);
      if (fifo_read_avail(aud->buffer) >= sizeof(out_tmp))
         fifo_read(aud->buffer, out_tmp, sizeof(out_tmp));
      else
         memset(out_tmp, 0, sizeof(out_tmp));
      sys_lwmutex_unlock(&aud->lock);
      sys_lwcond_signal(&aud->cond);

      cellAudioAddData(aud->audio_port, out_tmp,
            CELL_AUDIO_BLOCK_SAMPLES, 1.0);
   }

   cellAudioRemoveNotifyEventQueue(key);
   sys_ppu_thread_exit(0);
}