Ejemplo n.º 1
0
int audio_reset_parameters(struct audio_info_struct *ai)
{
	audio_set_format(ai);
	audio_set_channels(ai);
	audio_set_rate(ai);

	return 0;
}
Ejemplo n.º 2
0
/* !!! pamiêtaæ o zainicjowaniu parametrów !!! */
int outputInit()
{
	int ret;
	filedevice = open( SOUNDDEVICE, O_WRONLY );
	if ( filedevice == -1 )
		return -1;
	ret = ioctl( filedevice, SNDCTL_DSP_RESET, NULL );
	if(ret < 0)
	{
		fprintf(stderr,"Can't reset audio!\n");
		return -1;
	}
	if ( audio_set_format() < 0 )
		return -1;
	if ( audio_set_rate() < 0 )
		return -1;
	if ( audio_set_channels() < 0 )
		return -1;
	return 0;
}
Ejemplo n.º 3
0
int audio_init(int samplerate, double framerate)
{
  /* Shutdown first */
  audio_shutdown();

  /* Clear the sound data context */
  memset(&snd, 0, sizeof (snd));

  /* Initialize Blip Buffers */
  snd.blips[0] = blip_new(samplerate / 10);
  if (!snd.blips[0])
  {
    return -1;
  }

  /* Mega CD sound hardware */
  if (system_hw == SYSTEM_MCD)
  {
    /* allocate blip buffers */
    snd.blips[1] = blip_new(samplerate / 10);
    snd.blips[2] = blip_new(samplerate / 10);
    if (!snd.blips[1] || !snd.blips[2])
    {
      audio_shutdown();
      return -1;
    }
  }

  /* Initialize resampler internal rates */
  audio_set_rate(samplerate, framerate);

  /* Set audio enable flag */
  snd.enabled = 1;

  /* Reset audio */
  audio_reset();

  return (0);
}
Ejemplo n.º 4
0
void init_sound (void)
{
  int channels;
  int dspbits;
  unsigned int rate;
  
  if (currprefs.sound_maxbsiz < 128 || currprefs.sound_maxbsiz > 16384) {
    fprintf (stderr, "Sound buffer size %d out of range.\n", currprefs.sound_maxbsiz);
    currprefs.sound_maxbsiz = 8192;
  }
  sndbufsize = 8192;
  
  dspbits = currprefs.sound_bits;
  rate    = currprefs.sound_freq;
  channels = currprefs.stereo ? 2 : 1;

  if (dspbits != 16) {
    fprintf(stderr, "Only 16 bit sounds supported.\n");
    exit(1);
  }
  if (rate < 1 || rate > SOUNDTICKS_NTSC) {
    fprintf(stderr, "Too small or high a rate: %u\n", rate);
    exit(1);
  }
  if (channels != 2) {
    fprintf(stderr, "Only stereo supported.\n");
    exit(1);
  }

  sound_bytes_per_second = (dspbits / 8) *  channels * rate;

  audio_set_rate(rate);

  sound_available = 1;
  
  sndbufpt = sndbuffer;
}
Ejemplo n.º 5
0
int audio_open(struct audio_info_struct *ai)
{
  int dev = AL_DEFAULT_OUTPUT;
  ALconfig config = alNewConfig();
  ALport port = NULL;
  
  /* Test for correct completion */
  if (config == 0) {
    fprintf(stderr,"audio_open : %s\n",alGetErrorString(oserror()));
    return -1;
  }
  
  /* Set port parameters */
  if(ai->channels == 2)
    alSetChannels(config, AL_STEREO);
  else
    alSetChannels(config, AL_MONO);

  alSetWidth(config, AL_SAMPLE_16);
  alSetSampFmt(config,AL_SAMPFMT_TWOSCOMP);
  alSetQueueSize(config, 131069);

  /* Setup output device to specified module. If there is no module
     specified in ai structure, use the default four output */
  if ((ai->device) != NULL) {
    
    char *dev_name;
    
    dev_name=malloc((strlen(ai->device) + strlen(analog_output_res_name) + 1) *
                  sizeof(char));
    
    strcpy(dev_name,ai->device);
    strcat(dev_name,analog_output_res_name);
    
    /* Find the asked device resource */
    dev=alGetResourceByName(AL_SYSTEM,dev_name,AL_DEVICE_TYPE);

    /* Free allocated space */
    free(dev_name);

    if (!dev) {
      fprintf(stderr,"Invalid audio resource: %s (%s)\n",dev_name,
            alGetErrorString(oserror()));
      return -1;
    }
  }
  
  /* Set the device */
  if (alSetDevice(config,dev) < 0)
    {
      fprintf(stderr,"audio_open : %s\n",alGetErrorString(oserror()));
      return -1;
    }
  
  /* Open the audio port */
  port = alOpenPort("mpg123-VSC", "w", config);
  if(port == NULL) {
    fprintf(stderr, "Unable to open audio channel: %s\n",
          alGetErrorString(oserror()));
    return -1;
  }
  
  ai->handle = (void*)port;
  
  
  audio_set_format(ai, config);
  audio_set_channels(ai, config);
  audio_set_rate(ai, config);
    

  alFreeConfig(config);
 
  return 1;
}
Ejemplo n.º 6
0
static javacall_result video_set_rate(javacall_handle handle, long rate){
    return audio_set_rate(handle, rate);
}