bool AudioEncoderFAAC::setup(AudioSettings s) {

  if(!validateSettings(s)) {
    return false;
  }

  settings = s;
  
  return true;
}
int BabelConnectionSettings::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QDialog::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: validateSettings(); break;
        default: ;
        }
        _id -= 1;
    }
    return _id;
}
Пример #3
0
void AmigaUAE::runExecutable(const QString& filename)
{
    if (!validateSettings()) {
        return;
    }

    if (!m_skipUAELaunch) {
        launchUAE();
    }

    QFileInfo info(filename);

    m_amigaExePath = info.path();
    writeSettings();
}
Пример #4
0
SettingsMigrator() :
  mSettings("QSyncthingTray", "qst")
{
  validateSettings();
}
bool AudioEncoderFAAC::initialize() {

  if(encoder) {
    STREAMER_ERROR("It seems that you already initialized the AudioEncoderFAAC. I'm not initializing again. First shutdown().");
    return false;
  }

  if(!validateSettings(settings)) {
    return false;
  }

  encoder = faacEncOpen(settings.samplerate, 
                        getNumChannels(), 
                        &nsamples_needed, 
                        &nbytes_out);

  if(!encoder) {
    STREAMER_ERROR("Error while trying to open the FAAC encoder.\n");
    return false;
  }

  faac_buffer = new unsigned char[nbytes_out];
  if(!faac_buffer) {
    STREAMER_ERROR("Erorr while allocating the buffer for the encoded faac data.\n");
    shutdown();
    return false;
  }

  STREAMER_STATUS("FAAC, nsamples_needed: %ld, nbytes_out: %ld\n", nsamples_needed, nbytes_out);

  // configure faac
  faacEncConfigurationPtr config = faacEncGetCurrentConfiguration(encoder);
  config->mpegVersion = MPEG4;
  config->aacObjectType = LOW;
  config->useLfe = 0;
  config->quantqual = 100; 
  config->bitRate = settings.bitrate * 1000 / getNumChannels();
  config->outputFormat = 0; // 0 = Raw, 1 = ADTS

  if(settings.in_bitsize == AV_AUDIO_BITSIZE_S16) {
    config->inputFormat = FAAC_INPUT_16BIT; 
  }
  else if(settings.in_bitsize == AV_AUDIO_BITSIZE_F32) {
    config->inputFormat = FAAC_INPUT_FLOAT;
  }
  else {
    STREAMER_ERROR("Cannot initialize the AudioEncoderFAAC because the in_bitsize is invalid. we only support S16 of F32.\n");
    ::exit(EXIT_FAILURE);
  }

  int r = faacEncSetConfiguration(encoder, config);
  if(!r) {
    STREAMER_ERROR("Error while setting the configuration for faac.\n");
    shutdown();
    return false;
  }


  // get the decoder specific config
  unsigned char* header;
  unsigned long header_size = 0;
  r = faacEncGetDecoderSpecificInfo(encoder, &header, &header_size);
  if(r < 0) {
    STREAMER_ERROR("Error while trying to get the decoder specific info from libfaac.\n");
    shutdown();
    return false;
  }
  std::copy(header, header + header_size, std::back_inserter(audio_specific_config));

  free(header);
  header = NULL;

  // write data to file if output file has been specified
  if(output_file.size()) {
    ofs.open(output_file.c_str(), std::ios::out | std::ios::binary);
    if(!ofs.is_open()) {
      STREAMER_ERROR("Cannot open the output file for the AudioEncoderFAAC: %s\n", output_file.c_str());
      ::exit(EXIT_FAILURE);
    }
    ofs.write((char*)header, header_size);
  }
  
  STREAMER_STATUS("Bitrate in bits per channel: %d, decoder size: %ld\n", config->bitRate, header_size);

  return true;
}
Пример #6
0
void MaraSettingsDialog::validateAndAccept()
{
	if(validateSettings()) accept();
}