コード例 #1
0
ファイル: CellAudio.c プロジェクト: cdenix/psmame
void					ESAudio::Shutdown				()
{
	cellAudioPortStop(Port);

	ThreadDie = true;
	delete Thread;
	delete Semaphore;

	cellAudioPortClose(Port);
	cellAudioRemoveNotifyEventQueue(QueueKey);
	sys_event_queue_destroy(QueueID, SYS_EVENT_QUEUE_DESTROY_FORCE);
	cellAudioQuit();
}
コード例 #2
0
int
sampleSpursUtilSpuPrintfServiceFinalize(SampleUtilSpursPrintfService *service)
{
	int ret;
	uint64_t	exit_code;

	/*
	 *
	 */
	ret = cellSpursDetachLv2EventQueue (service->spurs, SPU_PORT_PRINTF);
	if (ret) {
		printf ("cellSpursDetachLv2EventQueue failed %d\n", ret);
		return ret;
	}

	/*
	 * send event for temination.
	 */
	ret = sys_event_port_send (service->terminating_port, 0, 0, 0);
	if (ret) {
		printf ("sys_event_port_send failed %d\n", ret);
		return ret;
	}
	/*	wait for termination of the handler thread */
	ret = sys_ppu_thread_join (service->spu_printf_handler, &exit_code);
	if (ret) {
		printf("sys_ppu_thread_join failed %d\n", ret);
		return ret;
	}

	/* Disconnect and destroy the terminating port */
	ret = sys_event_port_disconnect(service->terminating_port);
	if (ret) {
		printf("sys_event_disconnect failed %d\n", ret);
		return ret;
	}
	ret = sys_event_port_destroy(service->terminating_port);
	if (ret) {
		printf("sys_event_port_destroy failed %d\n", ret);
		return ret;
	}	

	/*	clean event_queue for spu_printf */
	ret = sys_event_queue_destroy (service->equeue, 0);
	if (ret) {
		printf("sys_event_queue_destroy failed %d\n", ret);
		return ret;
	}

	return CELL_OK;
}
コード例 #3
0
ファイル: ps3_audio.c プロジェクト: bielorkut/showtime
static int
ps3_audio_start(audio_mode_t *am, audio_fifo_t *af)
{
  prop_sub_t *s_vol;
  audio_buf_t *ab;

  u32 port_num;

  AudioPortConfig config;

  int ret;
  int cur_channels = 0;
  int running = 0;

  sys_event_queue_t snd_queue;
  u64 snd_queue_key;
  int achannels = 0;

  if(audioInit())
    return -1;

  s_vol = prop_subscribe(PROP_SUB_DIRECT_UPDATE,
			 PROP_TAG_CALLBACK_FLOAT, set_mastervol, NULL,
			 PROP_TAG_ROOT, prop_mastervol,
			 NULL);

  TRACE(TRACE_DEBUG, "AUDIO", "PS3 audio system initialized");

  while(1) {
    ab = af_deq2(af, !running, am);
    if(ab == AF_EXIT) {
      ab = NULL;
      break;
    }

    if(ab != NULL) {

      if(ab->ab_channels != cur_channels) {
      
	if(running) {
	  audioPortStop(port_num);
	  audioRemoveNotifyEventQueue(snd_queue_key);
	  audioPortClose(port_num);
	  sys_event_queue_destroy(snd_queue, 0);
	  running = 0;
	}

	cur_channels = ab->ab_channels;

	AudioOutConfiguration conf;
	memset(&conf, 0, sizeof(conf));

	switch(cur_channels) {
	case 2:
	  achannels = 2;
	  conf.channel = 2;
	  conf.encoder = AUDIO_OUT_CODING_TYPE_LPCM;
	  break;

	case 6:
	  achannels = 8;
	  if(max_pcm >= 6) {
	    conf.channel = 6;
	    conf.encoder = AUDIO_OUT_CODING_TYPE_LPCM;
	  } else if(max_dts == 6) {
	    conf.channel = 6;
	    conf.encoder = AUDIO_OUT_CODING_TYPE_DTS;
	  } else if(max_ac3 == 6) {
	    conf.channel = 6;
	    conf.encoder = AUDIO_OUT_CODING_TYPE_AC3;
	  } else {
	    conf.channel = 2;
	    conf.encoder = AUDIO_OUT_CODING_TYPE_LPCM;
	    conf.down_mixer = AUDIO_OUT_DOWNMIXER_TYPE_A;
	  }
	  break;

	case 7:
	case 8:
	  achannels = 8;
	  if(max_pcm == 8) {
	    conf.channel = 8;
	    conf.encoder = AUDIO_OUT_CODING_TYPE_LPCM;
	  } else if(max_dts == 6) {
	    conf.channel = 6;
	    conf.encoder = AUDIO_OUT_CODING_TYPE_DTS;
	    conf.down_mixer = AUDIO_OUT_DOWNMIXER_TYPE_B;
	  } else if(max_ac3 == 6) {
	    conf.channel = 6;
	    conf.encoder = AUDIO_OUT_CODING_TYPE_AC3;
	    conf.down_mixer = AUDIO_OUT_DOWNMIXER_TYPE_B;
	  } else {
	    conf.channel = 2;
	    conf.encoder = AUDIO_OUT_CODING_TYPE_LPCM;
	    conf.down_mixer = AUDIO_OUT_DOWNMIXER_TYPE_A;
	  }
	  break;
	}



	int r;
	r = audioOutConfigure(AUDIO_OUT_PRIMARY, &conf, NULL, 1);
	if(r == 0) {
	  int i;
	  for(i = 0; i < 100;i++) {
	    AudioOutState state;
	    r = audioOutGetState(AUDIO_OUT_PRIMARY, 0, &state );
	    if(r != 0)
	      break;
	    TRACE(TRACE_DEBUG, "AUDIO", "The state is %d", state.state);
	    if(state.state == 2)
	      continue;
	    usleep(100);
	    break;
	  }
	}

	AudioPortParam params;

	params.numChannels = achannels;
	params.numBlocks = AUDIO_BLOCK_8;
	params.attr = 0;
	params.level = 1;
	
	ret = audioPortOpen(&params, &port_num);

	TRACE(TRACE_DEBUG, "AUDIO", "PS3 audio port %d opened", port_num);
	
	audioGetPortConfig(port_num, &config);
	audioCreateNotifyEventQueue(&snd_queue, &snd_queue_key);
	audioSetNotifyEventQueue(snd_queue_key);
	sys_event_queue_drain(snd_queue);
	audioPortStart(port_num);
	
	running = 1;
      }
    }
    
    playOneBlock((u64*)(u64)config.readIndex,
		 (float*)(u64)config.audioDataStart,
		 am, ab, snd_queue, achannels);

    
    if(ab != NULL)
      ab_free(ab);
  }
  TRACE(TRACE_DEBUG, "AUDIO", "leaving the loop");

  if(running) {
    audioPortStop(port_num);
    audioRemoveNotifyEventQueue(snd_queue_key);
    audioPortClose(port_num);
    sys_event_queue_destroy(snd_queue, 0);
  }

  audioQuit();
  prop_unsubscribe(s_vol);
  return 0;
}