Пример #1
0
void BKE_sound_init(Main *bmain)
{
  /* Make sure no instance of the sound system is running, otherwise we get leaks. */
  BKE_sound_exit();

  AUD_DeviceSpecs specs;
  int device, buffersize;
  const char *device_name;

  device = U.audiodevice;
  buffersize = U.mixbufsize;
  specs.channels = U.audiochannels;
  specs.format = U.audioformat;
  specs.rate = U.audiorate;

  if (force_device == NULL) {
    int i;
    char **names = BKE_sound_get_device_names();
    device_name = names[0];

    /* make sure device is within the bounds of the array */
    for (i = 0; names[i]; i++) {
      if (i == device) {
        device_name = names[i];
      }
    }
  }
  else {
    device_name = force_device;
  }

  if (buffersize < 128) {
    buffersize = 1024;
  }

  if (specs.rate < AUD_RATE_8000) {
    specs.rate = AUD_RATE_48000;
  }

  if (specs.format <= AUD_FORMAT_INVALID) {
    specs.format = AUD_FORMAT_S16;
  }

  if (specs.channels <= AUD_CHANNELS_INVALID) {
    specs.channels = AUD_CHANNELS_STEREO;
  }

  if (!(sound_device = AUD_init(device_name, specs, buffersize, "Blender"))) {
    sound_device = AUD_init("Null", specs, buffersize, "Blender");
  }

  BKE_sound_init_main(bmain);
}
Пример #2
0
void BKE_sound_init(struct Main *bmain)
{
	AUD_DeviceSpecs specs;
	int device, buffersize;
	const char *device_name;

	device = U.audiodevice;
	buffersize = U.mixbufsize;
	specs.channels = U.audiochannels;
	specs.format = U.audioformat;
	specs.rate = U.audiorate;

	if (force_device == NULL) {
		int i;
		char **names = BKE_sound_get_device_names();
		device_name = names[0];

		/* make sure device is within the bounds of the array */
		for (i = 0; names[i]; i++) {
			if (i == device) {
				device_name = names[i];
			}
		}
	}
	else
		device_name = force_device;

	if (buffersize < 128)
		buffersize = 1024;

	if (specs.rate < AUD_RATE_8000)
		specs.rate = AUD_RATE_44100;

	if (specs.format <= AUD_FORMAT_INVALID)
		specs.format = AUD_FORMAT_S16;

	if (specs.channels <= AUD_CHANNELS_INVALID)
		specs.channels = AUD_CHANNELS_STEREO;

	if (!(sound_device = AUD_init(device_name, specs, buffersize, "Blender")))
		sound_device = AUD_init("Null", specs, buffersize, "Blender");

	BKE_sound_init_main(bmain);
}