Beispiel #1
0
/* Feed Sound Data */
void SoundFeedStreamData(unsigned char* pSound,long lBytes)
{
    //LOG_ENTER();
#ifndef NOSOUND

    //LOGD("ENTER SoundFeedStreamData(%p, %d), enable_audio=%d", pSound, lBytes, enable_audio);

  //u32 render_ticks;
	if( enable_audio == 0 ) return;
  
  if(pSound == NULL || lBytes <= 0 || lBytes > 32768) // || sound_new_buffer != 0) 
  {
    //LOG_LEAVE();
    return;
  }

  //memcpy(sound_buffer, pSound, lBytes);
  //sound_buffer_bytes = lBytes;
  //pthread_cond_signal(&sound_cond);

#ifdef TIGER_KING
   extern int stop;
   if(!stop) {
	   render_audio((s16*)pSound, lBytes);
   }
#else
  render_audio((s16*)pSound, lBytes);
#endif
  
#if 0
	if(last_render_ticks == 0)
	{
	  last_render_ticks = timeGetTime_spu();
	}
	
  render_ticks = timeGetTime_spu();
	if(render_ticks < last_render_ticks + 5)
	{
    u32 render_delta = (last_render_ticks + 5) - render_ticks;
    if(render_delta < 5)
    {
      usleep(render_delta * 1000);
    }
	}
	last_render_ticks = timeGetTime_spu();
#endif
#endif

    //LOG_LEAVE();
}
Beispiel #2
0
void device_io()
{
   if ( render_audio() && --scanDC == 0 )
   {
      scanDC = bufsPerScan;               // reload downcounter to next scan

      /* scan keys */

      if ( curKey >= 0 )
      {
         if ( ! readKey( curKey ) )
         {
            console.postKeyUp( curKey, 0 );
            scanKeys();
         }
      }
      else
          scanKeys();

      /* scan buttons */

      for ( byte i = 0; i < NumButs; i++ )
         scanBut(i);

      /* read next pot */

      readPot( nextPot );
      if ( ++nextPot >= NumPots )
         nextPot = 0;
   }
}
Beispiel #3
0
void CheckPauseSound()
{
   extern int stop;

   while(is_paused() && (bEndThread == 0) && (!stop) )
  {
#ifndef TIGER_KING  
    usleep(20000);
    if(!render_audio) {
	    render_audio((s16*)sound_buffer_silence, 882 * 2);
    	}
#else
    LOGD("game is paused, audio thread waiting ..");
    sleep(1);
#endif
  }
   
   if(stop) {
   	LOGD("QUIT audio thread since game is quiting");
       bEndThread =1;
	return;
   }

}
Beispiel #4
0
static void *sound_thread_play(void *none)
{
#ifndef NOSOUND
#if 0
	if( enable_audio == 0 ) return NULL;
	pthread_mutex_init(&sound_mutex, NULL);
	pthread_cond_init(&sound_cond, NULL);
  start_audio();
  while(!sound_thread_exit && !bEndThread)
  {
  	pthread_mutex_lock(&sound_mutex);
  	pthread_cond_wait(&sound_cond, &sound_mutex);
  	pthread_mutex_unlock(&sound_mutex);
  	if(pSpuBuffer)
      render_audio((s16*)pSpuBuffer, sound_buffer_bytes);
  }
  sound_thread_exit = 0;
  pthread_cond_destroy(&sound_cond);
  pthread_mutex_destroy(&sound_mutex);
  end_audio();
#endif
  return NULL;
#endif
}
void retro_run()
{
   static uint64_t samples_count = 0;
   static uint64_t frames_count = 0;

   input_poll_cb();

   uint64_t expected_frames = samples_count / 35112;
   if (frames_count < expected_frames) // Detect frame dupes.
   {
#ifdef VIDEO_RGB565
      video_cb(0, 160, 144, 512);
#else
      video_cb(0, 160, 144, 1024);
#endif
      frames_count++;
      return;
   }

   union
   {
      gambatte::uint_least32_t u32[2064 + 2064];
      int16_t i16[2 * (2064 + 2064)];
   } static sound_buf;
   unsigned samples = 2064;

   static gambatte::video_pixel_t video_buf[256 * 144];
   gambatte::uint_least32_t video_pitch = 256;
   while (gb.runFor(video_buf, video_pitch, sound_buf.u32, samples) == -1)
   {
#ifdef CC_RESAMPLER
      CC_renderaudio((audio_frame_t*)sound_buf.u32, samples);
#else
      render_audio(sound_buf.i16, samples);

      unsigned read_avail = blipper_read_avail(resampler_l);
      if (read_avail >= 512)
      {
         blipper_read(resampler_l, sound_buf.i16 + 0, read_avail, 2);
         blipper_read(resampler_r, sound_buf.i16 + 1, read_avail, 2);
         audio_batch_cb(sound_buf.i16, read_avail);
      }

#endif
      samples_count += samples;
      samples = 2064;
   }

   samples_count += samples;

#ifdef CC_RESAMPLER
   CC_renderaudio((audio_frame_t*)sound_buf.u32, samples);
#else
   render_audio(sound_buf.i16, samples);
#endif

#ifdef VIDEO_RGB565
   video_cb(video_buf, 160, 144, 512);
#else
   video_cb(video_buf, 160, 144, 1024);
#endif


#ifndef CC_RESAMPLER
   unsigned read_avail = blipper_read_avail(resampler_l);
   blipper_read(resampler_l, sound_buf.i16 + 0, read_avail, 2);
   blipper_read(resampler_r, sound_buf.i16 + 1, read_avail, 2);
   audio_batch_cb(sound_buf.i16, read_avail);
#endif

   frames_count++;

   bool updated = false;
   if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated)
      check_variables();
}
Beispiel #6
0
void retro_run(void)
{
   bool updated = false;

   input_poll_cb();

   uint64_t start_tick, end_tick;
   sceRtcGetCurrentTick(&start_tick);


   switch_to_cpu_thread();

   update_input();


   sceRtcGetCurrentTick(&end_tick);
//   printf("frame time : %u\n", (uint32_t)(end_tick - start_tick));
   static int frames = 0;
   static float total = 0.0;

   if ( frames >= 200)
      total += (end_tick - start_tick);

   if (frames++ == 400)
      printf("total : %f\n", total / 200.0);

   render_audio();


   static unsigned int __attribute__((aligned(64))) d_list[32];
   void* const texture_vram_p = GBA_FRAME_TEXTURE;

   sceGuStart(GU_DIRECT, d_list);

#ifdef HW_RENDER_TEST
   if(ge_render_enable)
      sceGuTexImage(0, GBA_LINE_SIZE, 256, GBA_LINE_SIZE, texture_vram_p);
   else
#endif
      sceGuTexImage(0, 256, 256, 256, texture_vram_p);

#ifdef HW_RENDER_TEST
   if(ge_render_enable)
   {
//      sceGuTexMode(GU_PSM_5551, 0, 0, GU_FALSE);
      sceGuTexMode(GU_PSM_8888, 0, 0, GU_FALSE);
      sceGuEnable(GU_TEXTURE_2D);
      sceGuTexFunc(GU_TFX_REPLACE,GU_TCC_RGB);
      sceGuDisable(GU_BLEND);


//      sceGuTexMode(GU_PSM_T16, 0, 0, GU_FALSE);
//      sceGuEnable(GU_TEXTURE_2D);
//      sceGuTexFunc(GU_TFX_REPLACE,GU_TCC_RGBA);
//      sceGuClutMode(GU_PSM_5551,0,0xFF,0);
//      sceGuClutLoad(32, palette_ram+256);
   }
   else
#endif
   {
      sceGuTexMode(GU_PSM_5551, 0, 0, GU_FALSE);
      sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGB);
      sceGuDisable(GU_BLEND);
   }

   sceGuFinish();

//   sceDisplaySetFrameBuf(GBA_FRAME_TEXTURE,256,PSP_DISPLAY_PIXEL_FORMAT_565,PSP_DISPLAY_SETBUF_NEXTFRAME);
#ifdef HW_RENDER_TEST
   if(ge_render_enable)
      video_cb(RETRO_HW_FRAME_BUFFER_VALID, GBA_SCREEN_WIDTH, GBA_SCREEN_HEIGHT, GBA_LINE_SIZE * 2);
   else
#endif
      video_cb(RETRO_HW_FRAME_BUFFER_VALID, GBA_SCREEN_WIDTH, GBA_SCREEN_HEIGHT, 512);

   if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated)
       check_variables();

}