Beispiel #1
0
int
VHTI_set_DTD_location (const char *path)
{
   int status = 0;

   std::ostringstream dtd_stringstream;
   std::auto_ptr<std::ifstream> dtd (new std::ifstream(path));

   if (dtd->fail ())
   {
      std::cerr << "Couldn't open "
                << path
                << ": "
                << strerror (errno)
                << std::endl;
      status = errno;
   }
   else
   {
      std::string tmp;
      while (std::getline (*dtd, tmp))
      {
         dtd_stringstream << tmp << std::endl;
      }
   }

   g_dtd = dtd_stringstream.str ();

   return status;
}
Beispiel #2
0
void info_xml_creator::output(FILE *out)
{
	m_output = out;

	// output the DTD
	fprintf(m_output, "<?xml version=\"1.0\"?>\n");
	astring dtd(s_dtd_string);
	dtd.replace(0,"__XML_ROOT__", emulator_info::get_xml_root());
	dtd.replace(0,"__XML_TOP__", emulator_info::get_xml_top());

	fprintf(m_output, "%s\n\n", dtd.cstr());

	// top-level tag
	fprintf(m_output, "<%s build=\"%s\" debug=\""
#ifdef MAME_DEBUG
		"yes"
#else
		"no"
#endif
		"\" mameconfig=\"%d\">\n",
		emulator_info::get_xml_root(),
		xml_normalize_string(build_version),
		CONFIG_VERSION
	);

	// iterate through the drivers, outputting one at a time
	while (m_drivlist.next())
		output_one();

	// output devices (both devices with roms and slot devices)
	output_devices();

	// close the top level tag
	fprintf(m_output, "</%s>\n",emulator_info::get_xml_root());
}
Beispiel #3
0
int AEC::doAEC(int d, int x)
{
  // Mic Highpass Filter - to remove DC
  d = acMic.highpass(d);

  // Mic Highpass Filter - cut-off below 300Hz
  d = cutoff.highpass(d);
  
  // Amplify, for e.g. Soundcards with -6dB max. volume
  d = (gain * d) / 65536;

  // ambient mic level estimation
  micAvg += (labs(65536 * d) - micAvg) / 10000;

  // Spk Highpass Filter - to remove DC
  x = acSpk.highpass(x);

  // Double Talk Detector
  int update = !dtd(d, x);

  // Acoustic Echo Cancellation
  d = nlms_pw(d, x, update);

  // Acoustic Echo Suppression
  if (update) {
    // Non Linear Processor (NLP): attenuate low volumes
    // NLPAttenuation -6dB = d * 0.5 or d / 2
    d /= 2;
  }
  
  return d;
}
Beispiel #4
0
/* This function is expected to update the samples in sb to remove echo - once
 * it completes, they are ready to go out the tx side of the hybrid */
void echo_update_tx(echo *e, SAMPLE_BLOCK *sb)
{
    size_t i;
    int any_doubletalk = 0;
    for (i=0; i<sb->count; i++)
    {
        SAMPLE rx_s, tx_s;
        float tx, rx;

        rx_s = cbuffer_pop(e->rx_buf);
        tx_s = sb->s[i];

        tx = (float)tx_s;
        rx = (float)rx_s;

        /* High-pass filter - filter out sub-300Hz signals */
        tx = update_fir(e->hp, tx);

        /* Geigel double-talk detector */
        int update = !dtd(e, tx);

        /* nlms-pw */
        tx = nlms_pw(e, tx, rx, update);

        /* If we're not talking, let's attenuate our signal */
        if (update)
        {
            tx *= M12dB;
        }
        else
        {
            any_doubletalk = 1;
        }

        /* clipping */
        tx = clip(tx);

        sb->s[i] = (int)tx;
    }
    VERBOSE_LOG("%s\n", any_doubletalk ? "doubletalk" : " ");
}
Beispiel #5
0
int AEC::doAEC(int d, int x) 
{
  REAL s0 = (REAL)d;
  REAL s1 = (REAL)x;
  
  // Mic Highpass Filter - to remove DC
  s0 = hp00.highpass(s0);
  
  // Mic Highpass Filter - telephone users are used to 300Hz cut-off
  s0 = hp0.highpass(s0);

  // ambient mic level estimation
  s0avg += 1e-4f*(fabsf(s0) - s0avg);
  
  // Spk Highpass Filter - to remove DC
  s1 = hp1.highpass(s1);

  // Double Talk Detector
  int update = !dtd(s0, s1);

  // Acoustic Echo Cancellation
  s0 = nlms_pw(s0, s1, update);

  // Acoustic Echo Suppression
  if (update) {
    // Non Linear Processor (NLP): attenuate low volumes
    s0 *= NLPAttenuation;
  }
  
  // Saturation
  if (s0 > MAXPCM) {
    return (int)MAXPCM;
  } else if (s0 < -MAXPCM) {
    return (int)-MAXPCM;
  } else {
    return (int)(s0);
  }
}
void Clog_cellidImpl::CheckedRunL()
{
	CALLSTACKITEM_N(_CL("Clog_cellidImpl"), _CL("CheckedRunL"));

#ifdef __WINS__
	TTimeIntervalMicroSeconds32 wait_time;
#endif
	if (iStatus!=KErrNone) {
		TBuf<40> msg;
		msg.Format(_L("NotifyChangeOfCurrentNetwork %d"), iStatus.Int());
		post_error(msg, iStatus.Int(), GetTime());
		if (iErrorCount++ >= 10) {
			User::Leave(-1005);
		}
	} else {
		iErrorCount=0;
#ifndef __WINS__
#  ifdef BASICGSM
		if (async_info.iNetworkInfo.iShortName.CompareF(_L("elisa"))==0) {
			async_info.iNetworkInfo.iShortName=_L("RADIOLINJA");
		}
		iCell.iMCC()=async_info.iNetworkInfo.iId.iMCC;
		iCell.iMNC()=async_info.iNetworkInfo.iId.iMNC;
		iCell.iShortName=async_info.iNetworkInfo.iShortName;
		iCell.iLocationAreaCode()=async_info.iLocationAreaCode;
		iCell.iCellId()=async_info.iCellId;
		iCell.iMappedId()=iCellMap->GetId(iCell);
#  endif
#  ifdef ETEL3RDPARTY
		iCell.iMCC.FromStringL(async_info.iCountryCode);
		iCell.iMNC.FromStringL(async_info.iNetworkId);
		iCell.iShortName=async_info.iShortName;
		iCell.iLocationAreaCode()=async_info.iLocationAreaCode;
		iCell.iCellId()=async_info.iCellId;
		iCell.iMappedId()=iCellMap->GetId(iCell);
#  endif
#  ifdef MOBINFO
		//TBuf<100> msg=_L("cell mcc ");

		if (iInfoState==GETTING_FIRST_MCC || iInfoState==GETTING_NEW_MCC) {
			iCell.iMCC.FromStringL(iNetworkInfo.iNetworkCountryCode);
		}
		if (iInfoState==GETTING_FIRST_MCC) {
			//post_error(msg, KErrGeneral);
			iInfoState=GETTING_FIRST_CELL;
			iMobInfo->GetCellId(async_infop, iStatus);
			SetActive();
			return;
		}
		/*
		msg.Append(iNetworkInfo.iNetworkCountryCode);
		if (iInfoState==GETTING_CELL) {
			msg.Append(async_infop().iCountryCode);
			msg.Append(_L(" mnc "));
			msg.Append(async_infop().iNetworkIdentity);
			msg.Append(_L(" lac "));
			msg.AppendNum(async_infop().iLocationAreaCode);
			msg.Append(_L(" cellid "));
			msg.AppendNum(async_infop().iCellId);
		}
		post_error(msg, KErrGeneral);
		return;
		*/
		
		iCell.iMNC.FromStringL(async_infop().iNetworkIdentity);
		iCell.iShortName()=iNetworkInfo.iNetworkShortName;
		iCell.iLocationAreaCode()=async_infop().iLocationAreaCode;
		iCell.iCellId()=async_infop().iCellId;
		iCell.iMappedId()=iCellMap->GetId(iCell);

		if (	(iInfoState==GETTING_CELL) && 
				(iCell.iMNC() != prev_info.iLocationAreaCode)) {
			iInfoState=GETTING_NEW_MCC;
			iMobInfo->GetCellId(async_infop, iStatus);
			SetActive();
			return;
		}
		async_infop().iCountryCode=iNetworkInfo.iNetworkCountryCode;
		iInfoState=GETTING_CELL;
#  endif

		if ( iCell.iLocationAreaCode()==0 && iCell.iCellId()==0) {
			if (!iPostedMissing ) {
				iTimeOut->WaitMax(MISSING_TIMEOUT);
			}
		} else {
			ResetMissing();
			post_new_value(&iCell);
		}

#  ifndef MOBINFO
		prev_info=async_info;
#  else
		prev_info=async_infop();
#  endif
	}
#ifdef BASICGSM
#  ifndef __S60V2__
	Phone().NotifyChangeOfCurrentNetwork(iStatus, async_info);
#  else
	Phone().NotifyChangeOfCurrentNetworkNS(iStatus, async_info);
#  endif
#endif //BASICGSM

#ifdef ETEL3RDPARTY
	Telephony().NotifyChange(iStatus, CTelephony::ECurrentNetworkInfoChange, async_infop);
	i3rdpartyState=NOTIFYONCHANGE;
#endif

#ifdef MOBINFO
	post_error(_L("NotifyCellIdChange"), KErrGeneral);
	iMobInfo->NotifyCellIdChange(async_infop, iStatus);
#endif
	SetActive();
#else //WINS
		TTime this_time;
		TBuf<40> val=bases::test_data[test_data_i][1];
		while (! val.Compare(_L("SWITCH"))) {
			val=bases::test_data[++test_data_i][1];
		}
		TPtrC dtd(bases::test_data[test_data_i][0]);
		_LIT(KTime, "t");
		TBBTime t(KTime);
		t.FromStringL(dtd);
		CCellMap::Parse(val, iCell.iCellId(), iCell.iLocationAreaCode(), iCell.iShortName());
		iOpMap->NameToMccMnc(iCell.iShortName(), iCell.iMCC(), iCell.iMNC());
		++test_data_i;
		if (test_data_i == 322) {
			TInt x=0;
		}
		iCell.iMappedId()=iCellMap->GetId(iCell);
		post_new_value(&iCell, t());
		this_time=t();
		TTime next_time;
		{
			val=bases::test_data[test_data_i][1];
			while (! val.Compare(_L("SWITCH"))) {
				val=bases::test_data[++test_data_i][1];
			}
			TPtrC dtd(bases::test_data[test_data_i][0]);
			t.FromStringL(dtd);
			next_time=t();
		}
		TTimeIntervalMicroSeconds w=next_time.MicroSecondsFrom(this_time);
		TInt64 ms=w.Int64();
		//ms/=(60*5);
		wait_time=I64LOW(ms);
	}
Beispiel #7
0
int main(int argc, char *argv[]) {
  if (argc != 2) {
    std::cerr << "Usage: dtdbin PATH_TO_DTD_FILES" << std::endl;
    return EXIT_FAILURE;
  }

  std::ofstream cpp("musicxml-dtd.cpp"), hpp("musicxml-dtd.hpp");

  hpp << "#ifndef MUSICXML_DTD_HPP" << std::endl
      << "#define MUSICXML_DTD_HPP" << std::endl
      << "#include <map>" << std::endl
      << "#include <string>" << std::endl
      << "#include <xercesc/util/XercesDefs.hpp>" << std::endl
      << std::endl
      << "namespace musicxml {" << std::endl
      << std::endl
      << "extern "
         "std::map<std::string, std::pair<XMLByte const *, XMLSize_t>> const "
         "dtd;" << std::endl
      << std::endl
      << "}" << std::endl
      << std::endl
      << "#endif" << std::endl;

  cpp << "#include \"musicxml-dtd.hpp\"" << std::endl;
  cpp << std::endl;
  for (auto &&pair: dtds) {
    std::string path(argv[1]);
    path += pair.second;
    std::ifstream dtd(path);
    if (!dtd.good()) {
      std::cerr << "DTD file " << path << " not found." << std::endl;
      return EXIT_FAILURE;
    }
    std::istreambuf_iterator<char> dtd_begin(dtd.rdbuf()), dtd_end;
    std::string dtd_string(dtd_begin, dtd_end);
    cpp << "static XMLByte const " << cpp_identifier(pair.second)
        << "[" << std::dec << dtd_string.length() << "UL] = {";
    for (unsigned i = 0; i < dtd_string.length(); ++i) {
      if ((i % 13) == 0) cpp << std::endl << "  ";
      cpp << "0X";
      cpp.width(2); cpp.fill('0');
      cpp << std::hex << int(static_cast<unsigned char>(dtd_string[i]));
      if (i < dtd_string.length() - 1) cpp << ", ";
    }
    cpp << std::endl << "};" << std::endl << std::endl;
  }

  cpp << "std::map<std::string, std::pair<XMLByte const *, XMLSize_t>> const "
         "musicxml::dtd = {" << std::endl;
  for (auto &&pair: dtds) {
    std::string path(argv[1]);
    path += pair.second;
    cpp << "  { \"" << pair.first << "\"," << std::endl
        << "    std::make_pair(&" << cpp_identifier(pair.second) << "[0], sizeof("
        << cpp_identifier(pair.second) << "))" << std::endl << "  },"
        << std::endl;
  }
  cpp << "};" << std::endl;

  return EXIT_SUCCESS;
}
Beispiel #8
0
int
ParserWrapper::_parse( const char *htmlBytes, uint32_t htmlNumBytes )
{
	nsresult result;

	// We may have to try parsing twice, if decoder is null AND the document contains a <meta> tag
	while( true )
	{
		if( charset.IsEmpty() )
		{
			decoder = defaultDecoder;
			charset.Assign( defaultCharset );
			charsetSource = defaultCharsetSource;
		}
		else
		{
			result = ccm->GetUnicodeDecoder( charset.get(), &decoder );
			if( NS_FAILED(result) )
			{
				return _setErrorMessage( "Failed to get unicode decoder for charset %s: %x", charset.get(), result );
			}
		}

		nsString streamUTF16;
		if( NS_FAILED( result = decode( decoder, htmlBytes, htmlNumBytes, streamUTF16 ) ) )
		{
			return _setErrorMessage( "Failed to decode HTML: 0x%08x", result );
		}

		nsCOMPtr<nsIParser> parser(do_CreateInstance(kParserCID, &result));
		if( NS_FAILED(result) )
		{
			return _setErrorMessage( "Unable to create a parser: 0x%08x", result );
		}

		// Create a JavaContentSink object and set the file descriptor where
		// we want responses sent
		//contentSink->setParserVersion(parserVersion);

		// Create a CNavDTD dtd object and register the DTD to the parser :
		nsCOMPtr<nsIDTD> dtd(do_CreateInstance(kNavDTDCID, &result));
		if(NS_FAILED(result))
		{
			return _setErrorMessage( "Unable to create a dtd: %x", result );
		}

		parser->RegisterDTD(dtd);
		parser->SetDocumentCharset( charset, charsetSource );
		parser->SetContentSink( contentSink );

		// Parse
		result = parser->Parse(streamUTF16, 0, NS_LITERAL_CSTRING("text/html"), PR_FALSE, PR_TRUE);

		// See if we got interrupted; if so, try again with the new character set
		if( contentSink->getWebShell()->wasStopped() &&
			contentSink->getWebShell()->getNewCharset() != NULL &&
			contentSink->getWebShell()->getNewCharsetSource() > charsetSource )
		{
			charset.Assign( contentSink->getWebShell()->getNewCharset() );
			charsetSource = contentSink->getWebShell()->getNewCharsetSource();
			contentSink->getWebShell()->reset();
			contentSink->reset();
		}
		else
		{
			break;
		}
	}

	return 0;
}