Exemplo n.º 1
0
static cell_audio_handle_t audioport_init(const struct cell_audio_params *params)
{
   init_audioport();

   audioport_t *handle = calloc(1, sizeof(*handle));

   CellAudioPortParam port_params = {
      .nChannel = params->channels,
      .nBlock = 8,
      .attr = 0
   };

   handle->channels = params->channels;

   handle->sample_cb = params->sample_cb;
   handle->userdata = params->userdata;
   handle->buffer = fifo_new(params->buffer_size ? params->buffer_size : 4096);

   if (params->samplerate != 48000)
   {
      handle->re = resampler_new(resampler_cb, 48000.0 / params->samplerate, params->channels, handle);
   }

   sys_lwmutex_attribute_t attr;
   sys_lwmutex_attribute_t attr2;
   sys_lwmutex_attribute_t cond_attr;

   sys_lwmutex_attribute_initialize(attr);
   sys_lwmutex_create(&handle->lock, &attr);

   sys_lwmutex_attribute_initialize(attr2);
   sys_lwmutex_create(&handle->cond_lock, &attr2);

   sys_lwcond_attribute_initialize(cond_attr);
   sys_lwcond_create(&handle->cond, &handle->cond_lock, &cond_attr);

   cellAudioPortOpen(&port_params, &handle->audio_port);
   cellAudioPortStart(handle->audio_port);

   pthread_create(&handle->thread, NULL, event_loop, handle);
   return handle;
}

static void audioport_pause(cell_audio_handle_t handle)
{
   audioport_t *port = handle;
   port->is_paused = 1;
   cellAudioPortStop(port->audio_port);
}
Exemplo n.º 2
0
void					ESAudio::Initialize				()
{
	cellAudioInit();

	CellAudioPortParam portparam = {2, BlockCount, CELL_AUDIO_PORTATTR_BGM, 1};
	cellAudioPortOpen(&portparam, &Port);

	cellAudioGetPortConfig(Port, &Config);

	cellAudioCreateNotifyEventQueue(&QueueID, &QueueKey);
	cellAudioSetNotifyEventQueue(QueueKey);
	sys_event_queue_drain(QueueID);

	cellAudioPortStart(Port);
	
	Thread = es_threads->MakeThread(ProcessAudioThread, 0);
	Semaphore = es_threads->MakeSemaphore(1);
}
Exemplo n.º 3
0
static void *ps3_audio_init(const char *device,
      unsigned rate, unsigned latency)
{
   CellAudioPortParam params;
   ps3_audio_t *data = NULL;

   (void)latency;
   (void)device;
   (void)rate;

   data = calloc(1, sizeof(*data));
   if (!data)
      return NULL;

   cellAudioInit();

   params.numChannels = AUDIO_CHANNELS;
   params.numBlocks = AUDIO_BLOCKS;
#if 0
#ifdef HAVE_HEADSET
   if(global->console.sound.mode == SOUND_MODE_HEADSET)
      params.param_attrib = CELL_AUDIO_PORTATTR_OUT_SECONDARY;
   else
#endif
#endif
      params.param_attrib = 0;

   if (cellAudioPortOpen(&params, &data->audio_port) != CELL_OK)
   {
      cellAudioQuit();
      free(data);
      return NULL;
   }

   data->buffer = fifo_new(CELL_AUDIO_BLOCK_SAMPLES * 
         AUDIO_CHANNELS * AUDIO_BLOCKS * sizeof(float));

#ifdef __PSL1GHT__
   sys_lwmutex_attr_t lock_attr = 
   {SYS_LWMUTEX_ATTR_PROTOCOL, SYS_LWMUTEX_ATTR_RECURSIVE, "\0"};
   sys_lwmutex_attr_t cond_lock_attr =
   {SYS_LWMUTEX_ATTR_PROTOCOL, SYS_LWMUTEX_ATTR_RECURSIVE, "\0"};
   sys_lwcond_attribute_t cond_attr = {"\0"};
#else
   sys_lwmutex_attribute_t lock_attr;
   sys_lwmutex_attribute_t cond_lock_attr;
   sys_lwcond_attribute_t cond_attr;

   sys_lwmutex_attribute_initialize(lock_attr);
   sys_lwmutex_attribute_initialize(cond_lock_attr);
   sys_lwcond_attribute_initialize(cond_attr);
#endif

   sys_lwmutex_create(&data->lock, &lock_attr);
   sys_lwmutex_create(&data->cond_lock, &cond_lock_attr);
   sys_lwcond_create(&data->cond, &data->cond_lock, &cond_attr);

   cellAudioPortStart(data->audio_port);
   data->started = true;
   sys_ppu_thread_create(&data->thread, event_loop,
#ifdef __PSL1GHT__
   data,
#else
   (uint64_t)data,
#endif
   1500, 0x1000, SYS_PPU_THREAD_CREATE_JOINABLE, (char*)"sound");

   return data;
}