Exemplo n.º 1
0
JNIEXPORT void JNICALL Java_com_ssb_droidsound_plugins_GSFPlugin_N_1unload(JNIEnv *, jobject, jlong)
{
    GSFClose();
    if(fifo != NULL)
        delete fifo;
    fifo = NULL;
}
Exemplo n.º 2
0
void writeSound(void)
{
	int ret = soundBufferLen;
	//int i;
	
	while (mod.outMod->CanWrite() < ((ret*sndNumChannels*(sndBitsPerSample/8))<<(mod.dsp_isactive()?1:0)))
		Sleep(50);


	mod.SAAddPCMData((char *)soundFinalWave,sndNumChannels,sndBitsPerSample,decode_pos_ms);
	mod.VSAAddPCMData((char *)soundFinalWave,sndNumChannels,sndBitsPerSample,decode_pos_ms);
	decode_pos_ms += (ret/(2*sndNumChannels) * 1000) / (float)sndSamplesPerSec;

	if (mod.dsp_isactive())
		ret=mod.dsp_dosamples((short *)soundFinalWave,ret/sndNumChannels/(sndBitsPerSample/8),sndBitsPerSample,sndNumChannels,sndSamplesPerSec)*(sndNumChannels*(sndBitsPerSample/8));
	


	//if(soundFinalWave[0]==0&&soundFinalWave[1]==0&&soundFinalWave[2]==0&&soundFinalWave[3]==0)
	//  DisplayError("%.2X%.2X%.2X%.2X - %d", soundFinalWave[0],soundFinalWave[1],soundFinalWave[2],soundFinalWave[3],ret);
	mod.outMod->Write((char *)&soundFinalWave,ret);
	

	if (seek_needed != -1)		//if a seek is initiated
	{
		mod.outMod->Flush((long)decode_pos_ms);
		
		if (seek_needed < decode_pos_ms)	//if we are asked to seek backwards.  we have to start from the beginning
		{
			GSFClose();
			GSFRun(lastfn);
			decode_pos_ms = 0;
		}
	}
}
void writeSound(void)
{
  int ret = soundBufferLen;
  static int countdown = 20;

  decode_pos_ms += (ret/(2*sndNumChannels) * 1000) / (float)sndSamplesPerSec;

  _playback->output->write_audio (soundFinalWave, soundBufferLen);

  if (--countdown == 0)
    {
      countdown = 20;
    }

  /* is seek request complete? (-2) */
  if (seek_needed == -2)
    {
      _playback->output->flush(decode_pos_ms); // Scroll to new position in track
      seek_needed = -1;
    }

  if (lastfn != NULL && (seek_needed != -1))	//if a seek is initiated
    {
      if (seek_needed < decode_pos_ms)	//if we are asked to seek backwards.  we have to start from the beginning
        {
          GSFClose();
          GSFRun(lastfn);
          decode_pos_ms = 0;
        }
    }
}
Exemplo n.º 4
0
void stop() { 
	if (thread_handle != INVALID_HANDLE_VALUE)
	{
		if (paused)
			unpause();
		killDecodeThread=1;
		if (WaitForSingleObject(thread_handle,5000) == WAIT_TIMEOUT)
		{
			MessageBox(mod.hMainWindow,"error asking thread to die!\n","error killing decode thread",0);
			TerminateThread(thread_handle,0);
		}
		CloseHandle(thread_handle);
		thread_handle = INVALID_HANDLE_VALUE;
	}
	if (input_file != INVALID_HANDLE_VALUE)
	{
		CloseHandle(input_file);
		input_file=INVALID_HANDLE_VALUE;
	}
	GSFClose();

	mod.outMod->Close();

	mod.SAVSADeInit();
}
gboolean gsf_play_loop(const gchar * filename)
{
  int r;
  const gchar *fn;

  fn = g_filename_from_uri(filename, NULL, NULL);

  r = GSFRun(fn);
  if (!r)
    return -1;

  lastfn = g_strdup(fn);

  _playback->output->open_audio(FMT_S16_LE, sndSamplesPerSec, sndNumChannels);

  //gint length = tuple_get_int(ti, FIELD_LENGTH, NULL);

  _playback->set_params(_playback, sndSamplesPerSec*2*2*8, sndSamplesPerSec, sndNumChannels);

  decode_pos_ms = 0;
  seek_needed = -1;
  TrailingSilence=1000;

  stop_flag = FALSE;
  _playback->set_pb_ready(_playback);

  while(! stop_flag)
    EmulationLoop();

  GSFClose();

  stop_flag = TRUE;
  _playback->output->abort_write();
#if _AUD_PLUGIN_VERSION_MIN < 40
  _playback->output->close_audio(); //Fixes issue when switching tracks manually.
#endif
  g_free(lastfn);
  lastfn = NULL;

  return 0;
}