コード例 #1
0
    PixelFormat GLES2RTTManager::getSupportedAlternative(PixelFormat format)
    {
        if (checkFormat(format))
        {
            return format;
        }

        /// Find first alternative
        PixelComponentType pct = PixelUtil::getComponentType(format);

        switch (pct)
        {
            case PCT_BYTE:
                format = PF_A8R8G8B8;
                break;
            case PCT_SHORT:
                format = PF_SHORT_RGBA;
                break;
            case PCT_FLOAT16:
                format = PF_FLOAT16_RGBA;
                break;
            case PCT_FLOAT32:
                format = PF_FLOAT32_RGBA;
                break;
            case PCT_COUNT:
            default:
                break;
        }

        if (checkFormat(format))
            return format;

        /// If none at all, return to default
        return PF_A8R8G8B8;
    }
コード例 #2
0
void StringTestCase::testFormat()
{
    checkFormat("10", "%d", 10);
    checkFormat("foobar", "%s", (const char*)"foobar");
    checkFormat("foo:15:a", "%s:%d:%c", "foo", 15, 'a');
    {
    	static int size = 2048;
    	char buf[size];
    	memset(buf, 'f', sizeof(buf));
    	buf[size-1]=0;
    	checkFormat(buf, "%s", (const char*)buf);
    }
}
コード例 #3
0
ファイル: textbox.cpp プロジェクト: SteveShaw/nanogui-sdl
bool TextBox::focusEvent(bool focused) {
    Widget::focusEvent(focused);

    std::string backup = mValue;

    if (mEditable) {
        if (focused) {
            mValueTemp = mValue;
            mCommitted = false;
            mCursorPos = 0;
        } else {
            if (mValidFormat) {
                if (mValueTemp == "")
                    mValue = mDefaultValue;
                else
                    mValue = mValueTemp;
            }

            if (mCallback && !mCallback(mValue))
                mValue = backup;

            mValidFormat = true;
            mCommitted = true;
            mCursorPos = -1;
            mSelectionPos = -1;
            mTextOffset = 0;
        }

        mValidFormat = (mValueTemp == "") || checkFormat(mValueTemp, mFormat);
    }

    return true;
}
コード例 #4
0
ファイル: Opls_Scan.cpp プロジェクト: orlandoacevedo/MCGPU
void Opls_Scan::addLineToTable(string line, int numOfLines)
{
    string hashNum;
    int secCol;
    double charge,sigma,epsilon;
    string name, extra;
    stringstream ss(line);

    //check to see what format it is opls, V value, or neither
    int format = checkFormat(line);

    if(format == 1)
    {
        ss >> hashNum >> secCol >> name >> charge >> sigma >> epsilon;
        char *atomtype = (char*)name.c_str();

        Atom temp = createAtom(0, -1, -1, -1, sigma, epsilon, charge, *atomtype);
        pair<map<string,Atom>::iterator,bool> ret;
        ret = oplsTable.insert( pair<string,Atom>(hashNum,temp) );

        if (ret.second==false)
        {
            errHashes.push_back(hashNum);
        }
    }
コード例 #5
0
ファイル: THERM.cpp プロジェクト: botvs/FinancialAnalytics
PlotLine * THERM::calculateCustom (QString &p, QPtrList<PlotLine> &d)
{
  // format1: MA_TYPE, MA_PERIOD, THRESHOLD, SMOOTHING_TYPE, SMOOTHING_PERIOD

  if (checkFormat(p, d, 5, 5))
    return 0;

  QStringList mal;
  getMATypes(mal);
  maType = mal.findIndex(formatStringList[0]);
  maPeriod = formatStringList[1].toInt();
  threshold = formatStringList[2].toDouble();
  smoothType = mal.findIndex(formatStringList[3]);
  smoothing = formatStringList[4].toInt();

  QPtrList<PlotLine> pll;
  pll.setAutoDelete(FALSE);
  getTHERM(pll);

  int loop;
  for (loop = pll.count() - 1; loop > 0; loop--)
    pll.remove(loop);

  return pll.at(0);
}
コード例 #6
0
ファイル: binutils.cpp プロジェクト: UIKit0/codesize
BuFile* buFileOpen(const char* path, bool preload, int offset)
{
    iovecStreamParams p = {path, preload, offset};

    // set default target; without a default target some logic inside bfd goes horribly wrong
    bfd_set_default_target("binary");

    // open file
    std::unique_ptr<bfd, bfd_boolean (*)(bfd*)> abfd(bfd_openr_iovec(path, 0, iovecOpen, &p, iovecRead, iovecClose, iovecStat), bfd_close);
    if (!abfd) return 0;

    // we should be working with an object file now
    if (!checkFormat(abfd.get(), bfd_object)) return 0;

    // decompress sections (we don't know if we'll need it)
    abfd->flags |= BFD_DECOMPRESS;

    // slurp symtab since all operations need it anyway
    std::vector<asymbol*> symtab = slurpSymtab(abfd.get());
    std::vector<asymbol*> dyntab = slurpDynamicSymtab(abfd.get());

    symtab.insert(symtab.end(), dyntab.begin(), dyntab.end());
    symtab.push_back(0);

    return new BuFile(std::move(abfd), std::move(symtab));
}
コード例 #7
0
ファイル: sound3d.c プロジェクト: BackupTheBerlios/gltron-svn
void fxShift(float shift, Uint8 *target, Uint8 *source, int len, int *consumed) {
  int i, j, k;
  float l;
  float pa = 0;

  if(checkFormat()) {
    *consumed = 0;
    return;
  }

  len /= 4; 

  for(i = 0; i < len; i++) { // LR pairs 
    for(j = 0; j < 2; j++) { // channels
      pa = i * shift;
      k = (int) pa;
      l = pa - k;

      *(Sint16*) (target + 2 * j + 4 * i) +=
	( *(Sint16*) (source + 2 * j + 4 * (k + 0) ) * ( 1 - l ) +
	  *(Sint16*) (source + 2 * j + 4 * (k + 2) ) * ( l ) );
      
    }
  }
  *consumed = ( (int)(len * shift + 0.49999) ) * 4;
}
コード例 #8
0
ファイル: tensor.cpp プロジェクト: JoeHowse/opencv
Tensor Tensor::reshape(const char* data, const std::vector<int>& shape, bool alloc, Format fmt)
{
    if (device_ == VK_NULL_HANDLE)
    {
        CV_Error(Error::StsError, "device is NULL");
        return *this;
    }

    CV_Assert(shape.size() > 0 && shape.size() <= 6);

    if (shape_ != shape) shape_ = shape;
    if (checkFormat(fmt) && fmt != format_) format_ = fmt;

    size_t new_size = shapeCount(shape_) * elementSize(format_);
    if (alloc || new_size > size_in_byte_)
        alloc = true;
    size_in_byte_ = new_size;

    if (alloc)
    {
        buffer_.reset(new Buffer(device_, size_in_byte_, data));
    }
    else if (data)
    {
        void* p = map();
        memcpy(p, data, size_in_byte_);
        unMap();
    }

    return *this;
}
コード例 #9
0
ファイル: Zmatrix_Scan.cpp プロジェクト: Kalan-Stowe/MCGPU
void Zmatrix_Scan::parseLine(string line, int numOfLines){

    string atomID, atomType, oplsA, oplsB, bondWith, bondDistance, angleWith, angleMeasure, dihedralWith, dihedralMeasure;

    stringstream ss;

    //check if line contains correct format
    int format = checkFormat(line);

    if(format == 1){
        //read in strings in columns and store the data in temporary variables
        ss << line;    	
        ss >> atomID >> atomType >> oplsA >> oplsB >> bondWith >> bondDistance >> angleWith >> angleMeasure >> dihedralWith >> dihedralMeasure;

        //setup structures for permanent encapsulation
        Atom lineAtom;
        Bond lineBond;
        Angle lineAngle;
        Dihedral lineDihedral;
		  
        if (oplsA.compare("-1") != 0)
        {
            lineAtom = oplsScanner->getAtom(oplsA);
            lineAtom.id = atoi(atomID.c_str());
            lineAtom.x = 0;
            lineAtom.y = 0;
            lineAtom.z = 0;
        }
        else//dummy atom
        {
        	char dummy = 'X';
            lineAtom = createAtom(atoi(atomID.c_str()), -1, -1, -1, -1, -1, -1, dummy);
        }
		  atomVector.push_back(lineAtom);

        if (bondWith.compare("0") != 0){
            lineBond.atom1 = lineAtom.id;
            lineBond.atom2 = atoi(bondWith.c_str());
            lineBond.distance = atof(bondDistance.c_str());
            lineBond.variable = false;
            bondVector.push_back(lineBond);
        }

        if (angleWith.compare("0") != 0){
            lineAngle.atom1 = lineAtom.id;
            lineAngle.atom2 = atoi(angleWith.c_str());
            lineAngle.value = atof(angleMeasure.c_str());
            lineAngle.variable = false;
            angleVector.push_back(lineAngle);
        }

        if (dihedralWith.compare("0") != 0){
            lineDihedral.atom1 = lineAtom.id;
            lineDihedral.atom2 = atoi(dihedralWith.c_str());
            lineDihedral.value = atof(dihedralMeasure.c_str());
            lineDihedral.variable = false;
            dihedralVector.push_back(lineDihedral);
        }
    } //end if format == 1
コード例 #10
0
ファイル: GraphicsDevice.cpp プロジェクト: jacob-meacham/Ego
bool GraphicsDevice::setGraphics(HWND hwnd, bool windowed, u32 width, u32 height) 
{	
	if(!hwnd) return false;
	if(!pd3d) return false;

	D3DDISPLAYMODE d3dDisplay;
	if(FAILED(pd3d->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3dDisplay)))
		return false;

	D3DPRESENT_PARAMETERS d3dpp;
	D3DFORMAT BPP;

	if(windowed) //If it is windowed, use the current resolution settings.
		BPP = d3dDisplay.Format;
	else //otherwise use the typical resolution format (ie 32 bit).
	{ 
		BPP = D3DFMT_X8R8G8B8;
		if(!checkFormat(BPP, windowed)) 
			return false;
	}
	
	ZeroMemory(&d3dpp, sizeof(D3DPRESENT_PARAMETERS));

	// These are standard D3DPRESENT_PARAMETERS settings.
	if(windowed) 
	{
		d3dpp.Windowed = true;
		d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
		d3dpp.BackBufferFormat = BPP;
	}
	else
	{
		d3dpp.Windowed = false;
		d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
		d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
		d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
		d3dpp.BackBufferWidth  = width;
		d3dpp.BackBufferHeight = height;
		d3dpp.BackBufferFormat = BPP;
		d3dpp.hDeviceWindow = hwnd;
	}
	
	//Create device, using software vertex processing and HAL.
	HRESULT res = pd3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING,
		&d3dpp, &pd3dDevice);

	if(FAILED(res)) { return false; }

	//Create Sprite interface, using newly minted device.
	if(FAILED(D3DXCreateSprite(pd3dDevice, &pSprite))) { return false; }

	// if all creations are successful, return true.
	return true;
}
コード例 #11
0
ファイル: PtexWriter.cpp プロジェクト: 400notout/oiio
PtexWriter* PtexWriter::edit(const char* path, bool incremental,
			     Ptex::MeshType mt, Ptex::DataType dt,
			     int nchannels, int alphachan, int nfaces,
			     Ptex::String& error, bool genmipmaps)
{
    if (!checkFormat(mt, dt, nchannels, alphachan, error))
	return 0;

    // try to open existing file (it might not exist)
    FILE* fp = fopen(path, "rb+");
    if (!fp && errno != ENOENT) {
	error = fileError("Can't open ptex file for update: ", path).c_str();
    }

    PtexWriterBase* w = 0;
    // use incremental writer iff incremental mode requested and file exists
    if (incremental && fp) {
	w = new PtexIncrWriter(path, fp, mt, dt, nchannels, alphachan, nfaces);
    }
    // otherwise use main writer
    else {
	PtexTexture* tex = 0;
	if (fp) {
	    // got an existing file, close and reopen with PtexReader
	    fclose(fp);

	    // open reader for existing file
	    tex = PtexTexture::open(path, error);
	    if (!tex) return 0;

	    // make sure header matches
	    bool headerMatch = (mt == tex->meshType() &&
				dt == tex->dataType() &&
				nchannels == tex->numChannels() &&
				alphachan == tex->alphaChannel() &&
				nfaces == tex->numFaces());
	    if (!headerMatch) {
		std::stringstream str;
		str << "PtexWriter::edit error: header doesn't match existing file, "
		    << "conversions not currently supported";
		error = str.str().c_str();
		return 0;
	    }
	}
	w = new PtexMainWriter(path, tex, mt, dt, nchannels, alphachan,
			       nfaces, genmipmaps);
    }

    if (!w->ok(error)) {
	w->release();
	return 0;
    }
    return w;
}
コード例 #12
0
ファイル: SYMBOL.cpp プロジェクト: botvs/FinancialAnalytics
PlotLine * SYMBOL::calculateCustom (QString &p, QPtrList<PlotLine> &d)
{
    // format1: SYMBOL

    if (checkFormat(p, d, 1, 1))
        return 0;

    symbol = formatStringList[0];

    return getSYMBOL();
}
コード例 #13
0
ファイル: sam_expr.c プロジェクト: samgmansfield/sip
int main(int argc, char *argv[]) {
  char stack[32][32];

  for(int i = 1; i < argc; i++) {
    push(stack, argv[i]);
  }
  
  checkFormat(stack);
  printf("%d\n", evaluate(stack));

  return 0;
}
コード例 #14
0
ファイル: textbox.cpp プロジェクト: DanGroom/NanoguiBlock
bool TxtBox::keyboardCharacterEvent (unsigned int codepoint)
{
   if (mEditable && focused())
   {
      std::ostringstream convert;
      convert << (char) codepoint;
      deleteSelection();
      mValueTemp.insert (mCursorPos, convert.str());
      mCursorPos++;
      mValidFormat = (mValueTemp == "") || checkFormat (mValueTemp, mFormat);
      return true;
   }
   return false;
}
コード例 #15
0
ファイル: sound3d.c プロジェクト: BackupTheBerlios/gltron-svn
void fxPan(float pan, float vol, Uint8 *buf, int len) {
  int i;

  float left_vol =  - vol * ( -1.0 + pan ) / 2.0;
  float right_vol = vol * ( 1.0 + pan ) / 2.0;

  if(checkFormat())
    return;

  for(i = 0; i < len; i += 4) {
    *(Sint16*) (buf + i) *= left_vol;
    *(Sint16*) (buf + i + 2) *= right_vol;
  }
}
コード例 #16
0
ファイル: GValue.cpp プロジェクト: zhengfasheng/mypro
GValue& GValue::setFormatString(const string& szFormat)
{
	if ( !checkFormat(szFormat) )
	{
		return *this;
	}
	//可能指定的长度不一样,这里先删除掉在申请
	if (m_pFormat)
	{
		delete m_pFormat;
	}

	m_pFormat = new (std::nothrow) string;
	*m_pFormat = szFormat;
	return *this;
}
コード例 #17
0
ファイル: ExScript.cpp プロジェクト: botvs/FinancialAnalytics
PlotLine * ExScript::calculateCustom (QString &p, QPtrList<PlotLine> &d)
{
  // format1: SCRIPT_PATH, COMMAND_LINE_SWITCHES, DATE, OPEN, HIGH, LOW, CLOSE, VOLUME, OI

  if (checkFormat(p, d, 9, 9))
    return 0;

  scriptPath = formatStringList[0];
  comlineParms = formatStringList[1];

  if (! formatStringList[2].compare("TRUE"))
    dateFlag = TRUE;
  else
    dateFlag = FALSE;

  if (! formatStringList[3].compare("TRUE"))
    openFlag = TRUE;
  else
    openFlag = FALSE;

  if (! formatStringList[4].compare("TRUE"))
    highFlag = TRUE;
  else
    highFlag = FALSE;

  if (! formatStringList[5].compare("TRUE"))
    lowFlag = TRUE;
  else
    lowFlag = FALSE;

  if (! formatStringList[6].compare("TRUE"))
    closeFlag = TRUE;
  else
    closeFlag = FALSE;

  if (! formatStringList[7].compare("TRUE"))
    volumeFlag = TRUE;
  else
    volumeFlag = FALSE;

  if (! formatStringList[8].compare("TRUE"))
    oiFlag = TRUE;
  else
    oiFlag = FALSE;

  return doScript();
}
コード例 #18
0
ファイル: parse.c プロジェクト: wwDSadan/myfmake
void parse(FILE* fm){
	int lineCount=0;
	char line[MAXLINE];
	while(fgets(line,MAXLINE,fm)){
		lineCount++;
        
		if(isEmpty(line))
			continue;
        
		checkFormat(line,lineCount);
        
		splitLineAndStoreTokens(line);
	}
	if(NULL==ENAME)
		errorHandle(NO_ELINE);
	showParseResult();
}
コード例 #19
0
ファイル: PtexWriter.cpp プロジェクト: 400notout/oiio
PtexWriter* PtexWriter::open(const char* path,
			     Ptex::MeshType mt, Ptex::DataType dt,
			     int nchannels, int alphachan, int nfaces,
			     Ptex::String& error, bool genmipmaps)
{
    if (!checkFormat(mt, dt, nchannels, alphachan, error))
	return 0;

    PtexMainWriter* w = new PtexMainWriter(path, 0,
					   mt, dt, nchannels, alphachan, nfaces,
					   genmipmaps);
    std::string errstr;
    if (!w->ok(error)) {
	w->release();
	return 0;
    }
    return w;
}
コード例 #20
0
ファイル: Image.cpp プロジェクト: Shorkaa/cvt
	void Image::copyRect( int x, int y, const Image& img, const Recti & rect )
	{
		checkFormat( img, __PRETTY_FUNCTION__, __LINE__, _mem->_format );
		int tx, ty;

		tx = -x + rect.x;
		ty = -y + rect.y;
		Recti rdst( 0, 0, ( int ) _mem->_width, ( int ) _mem->_height );
		rdst.translate( tx, ty );
		Recti rsrc( 0, 0, ( int ) img._mem->_width, ( int ) img._mem->_height );
		rsrc.intersect( rect );
		rsrc.intersect( rdst );
		if( rsrc.isEmpty() )
			return;
		rdst.copy( rsrc );
		rdst.translate( -tx, -ty );

		SIMD* simd = SIMD::instance();
		size_t dstride;
		uint8_t* dst = map( &dstride );
		uint8_t* dbase = dst;
		dst += rdst.y * dstride + bpp() * rdst.x;

		size_t sstride;
		const uint8_t* src = img.map( &sstride );
		const uint8_t* sbase = src;
		src += rsrc.y * sstride + rsrc.x * img.bpp();

		size_t n = rsrc.width * img.bpp();
		size_t i = rsrc.height;

		while( i-- ) {
			simd->Memcpy( dst, src, n );
			src += sstride;
			dst += dstride;
		}
		img.unmap( sbase );
		unmap( dbase );
	}
コード例 #21
0
ファイル: PP.cpp プロジェクト: botvs/FinancialAnalytics
PlotLine * PP::calculateCustom (QString &p, QPtrList<PlotLine> &d)
{
  // format1: PP_TYPE
  if (checkFormat(p, d, 1, 1))
    return 0;

  int t = ppList.findIndex(formatStringList[0]);
  if (t == -1)
  {
    qDebug("PP::calculateCustom: invalid PP_TYPE parm");
    return 0;
  }

  QPtrList<PlotLine> pll;
  pll.setAutoDelete(TRUE);
  getPP(pll);

  PlotLine *line = new PlotLine;
  PlotLine *tline = pll.at(t);
  line->copy(tline);

  return line;
}
コード例 #22
0
ファイル: LOWPASS.cpp プロジェクト: botvs/FinancialAnalytics
PlotLine * LOWPASS::calculateCustom (QString &p, QPtrList<PlotLine> &d)
{
  // format: DATA_ARRAY, FREQ, WIDTH

  if (checkFormat(p, d, 3, 3))
    return 0;

  double t = formatStringList[1].toDouble();
  if (t < 0.0)
    t = 0.0;
  if (t > 0.5)
    t = 0.5;
  freq = t;

  t = formatStringList[2].toDouble();
  if (t < 0.0001)
    t = 0.0001;
  if (t > 0.2)
    t = 0.2;
  width = t;

  PlotLine *pl = getLowpass(d.at(0), freq, width);
  return pl;
}
コード例 #23
0
void Audio::load(wave_t &wave)
{
	char	*end;

	if (strstr(wave.file, "media/"))
	{
		wave.data = get_file(wave.file, NULL);
	}
	else
	{
		get_zipfile("media/pak0.pk3", wave.file, (unsigned char **)&wave.data, NULL);
	}
	if (wave.data == NULL)
	{
		debugf("Unable to load wave file %s.\n", wave.file);
		memset(&wave, 0, sizeof(wave_t));
		return;
	}

	if ( checkFormat(wave.data, "WAVE") )
	{
		debugf("%s is not a wave file.\n", wave.file);
		memset(&wave, 0, sizeof(wave_t));
		return;
	}

	end = wave.data + 4 + *((int *)(wave.data + 4));
	wave.format = (waveFormat_t *)findChunk( wave.data + 12, "fmt ", &(wave.dataSize), end);
	wave.pcmData = findChunk( wave.data + 12, "data", &(wave.dataSize), end);
	wave.duration = wave.dataSize / (wave.format->sampleRate * wave.format->channels * (wave.format->sampleSize / 8));


	alGenBuffers(1, (unsigned int *)&wave.buffer);
	alBufferData(wave.buffer, alFormat(&wave), wave.pcmData, wave.dataSize, wave.format->sampleRate);
	return;
}
コード例 #24
0
ファイル: BARS.cpp プロジェクト: DigitalPig/qtstalker-qt4
PlotLine * BARS::calculateCustom (QString &p, Q3PtrList<PlotLine> &d)
{
  // format1 (BARS): TYPE
  // format2 (BARS): TYPE, COLOR
  // format3 (BARS): TYPE, REVERSAL
  // TODO: format4 (BARS): TYPE, REVERSAL, BOXSIZE

  int type = 0; // 0 == Bars, 1 == Candle, HACandle, 2 == PF
  formatList.clear();
  QStringList l = QStringList::split(",", p, FALSE);
  if (l.count() == 1)
    formatList.append(FormatString); // OHLC bars
  else
  {
    if (l.count() == 2)
    {
      bool ok;
      //formatStringList[1].toInt(&ok);
      l[1].toInt(&ok);
      if (! ok)
      {
        // Candle bars
        formatList.append(FormatString);
        formatList.append(FormatString);
        type = 1;
      }
      else
      {
        // PF bars
        formatList.append(FormatString);
        formatList.append(FormatInteger);
        type = 2;
      }
    }
    else
    {
      qDebug("BARS::calculateCustom: invalid parm count");
      return 0;
    }
  }

  if (checkFormat(p, d, 2, 1))
    return 0;

  method = formatStringList[0];

  if (type == 1)
    candleColor.setNamedColor(formatStringList[1]);

  if (type == 2)
    pfReversal = formatStringList[1].toInt();

  PlotLine *line = 0;
  if (! method.compare("OHLC"))
    line = calculateOHLC();

  if (! method.compare("Candle"))
    line = calculateCandle();

  if (! method.compare("HACandle"))
    line = calculateHACandle();

  if (! method.compare("PF"))
    line = calculatePF();

  return line;
}
コード例 #25
0
ファイル: textbox.cpp プロジェクト: SteveShaw/nanogui-sdl
bool TextBox::keyboardEvent(int key, int /* scancode */, int action, int modifiers)
{
    if (mEditable && focused()) {
        if (action == SDL_KEYDOWN /*|| action == GLFW_REPEAT*/)
        {
            if (key == SDLK_LEFT )
            {
                if (modifiers == SDLK_LSHIFT)
                {
                    if (mSelectionPos == -1)
                        mSelectionPos = mCursorPos;
                } else {
                    mSelectionPos = -1;
                }

                if (mCursorPos > 0)
                    mCursorPos--;
            } else if (key == SDLK_RIGHT) {
                if (modifiers == SDLK_LSHIFT) {
                    if (mSelectionPos == -1)
                        mSelectionPos = mCursorPos;
                } else {
                    mSelectionPos = -1;
                }

                if (mCursorPos < (int) mValueTemp.length())
                    mCursorPos++;
            } else if (key == SDLK_HOME) {
                if (modifiers == SDLK_LSHIFT) {
                    if (mSelectionPos == -1)
                        mSelectionPos = mCursorPos;
                } else {
                    mSelectionPos = -1;
                }

                mCursorPos = 0;
            } else if (key == SDLK_END) {
                if (modifiers == SDLK_LSHIFT) {
                    if (mSelectionPos == -1)
                        mSelectionPos = mCursorPos;
                } else {
                    mSelectionPos = -1;
                }

                mCursorPos = (int) mValueTemp.size();
            } else if (key == SDLK_BACKSPACE) {
                if (!deleteSelection()) {
                    if (mCursorPos > 0) {
                        mValueTemp.erase(mValueTemp.begin() + mCursorPos - 1);
                        mCursorPos--;
                    }
                }
            } else if (key == SDLK_DELETE) {
                if (!deleteSelection()) {
                    if (mCursorPos < (int) mValueTemp.length())
                        mValueTemp.erase(mValueTemp.begin() + mCursorPos);
                }
            }
            else if (key == SDLK_RETURN)
            {
                if (!mCommitted)
                    focusEvent(false);
            }
            else if (key == SDLK_a && modifiers == SDLK_RCTRL)
            {
                mCursorPos = (int) mValueTemp.length();
                mSelectionPos = 0;
            }
            else if (key == SDLK_x && modifiers == SDLK_RCTRL)
            {
                copySelection();
                deleteSelection();
            }
            else if (key == SDLK_c && modifiers == SDLK_RCTRL)
            {
                copySelection();
            }
            else if (key == SDLK_v && modifiers == SDLK_RCTRL)
            {
                deleteSelection();
                pasteFromClipboard();
            }

            mValidFormat =
                (mValueTemp == "") || checkFormat(mValueTemp, mFormat);
        }

        return true;
    }

    return false;
}
コード例 #26
0
ファイル: Image.cpp プロジェクト: Shorkaa/cvt
	void Image::checkFormatAndSize( const Image & img, const char* func, size_t lineNum ) const
	{
		checkFormat(img, func, lineNum, _mem->_format );
		checkSize(img, func, lineNum, _mem->_width, _mem->_height );
	}
コード例 #27
0
ファイル: textbox.cpp プロジェクト: eriser/vkit
bool TextBox::keyboardEvent(int key, int /* scancode */, int action, int modifiers) {
    if (mEditable && focused()) {
        if (action == GLFW_PRESS || action == GLFW_REPEAT) {
            if (key == GLFW_KEY_LEFT) {
                if (modifiers == GLFW_MOD_SHIFT) {
                    if (mSelectionPos == -1)
                        mSelectionPos = mCursorPos;
                } else {
                    mSelectionPos = -1;
                }

                if (mCursorPos > 0)
                    mCursorPos--;
            } else if (key == GLFW_KEY_RIGHT) {
                if (modifiers == GLFW_MOD_SHIFT) {
                    if (mSelectionPos == -1)
                        mSelectionPos = mCursorPos;
                } else {
                    mSelectionPos = -1;
                }

                if (mCursorPos < (int) mValueTemp.length())
                    mCursorPos++;
            } else if (key == GLFW_KEY_HOME) {
                if (modifiers == GLFW_MOD_SHIFT) {
                    if (mSelectionPos == -1)
                        mSelectionPos = mCursorPos;
                } else {
                    mSelectionPos = -1;
                }

                mCursorPos = 0;
            } else if (key == GLFW_KEY_END) {
                if (modifiers == GLFW_MOD_SHIFT) {
                    if (mSelectionPos == -1)
                        mSelectionPos = mCursorPos;
                } else {
                    mSelectionPos = -1;
                }

                mCursorPos = (int) mValueTemp.size();
            } else if (key == GLFW_KEY_BACKSPACE) {
                if (!deleteSelection()) {
                    if (mCursorPos > 0) {
                        mValueTemp.erase(mValueTemp.begin() + mCursorPos - 1);
                        mCursorPos--;
                    }
                }
            } else if (key == GLFW_KEY_DELETE) {
                if (!deleteSelection()) {
                    if (mCursorPos < (int) mValueTemp.length())
                        mValueTemp.erase(mValueTemp.begin() + mCursorPos);
                }
            } else if (key == GLFW_KEY_ENTER) {
                if (!mCommitted)
                    focusEvent(false);
            } else if (key == GLFW_KEY_A && modifiers == SYSTEM_COMMAND_MOD) {
                mCursorPos = (int) mValueTemp.length();
                mSelectionPos = 0;
            } else if (key == GLFW_KEY_X && modifiers == SYSTEM_COMMAND_MOD) {
                copySelection();
                deleteSelection();
            } else if (key == GLFW_KEY_C && modifiers == SYSTEM_COMMAND_MOD) {
                copySelection();
            } else if (key == GLFW_KEY_V && modifiers == SYSTEM_COMMAND_MOD) {
                deleteSelection();
                pasteFromClipboard();
            }

            mValidFormat =
                (mValueTemp == "") || checkFormat(mValueTemp, mFormat);
        }

        return true;
    }

    return false;
}
コード例 #28
0
	void GLframebuffermanager::checkFormats() {
		GLuint object;

		TypeZeroArray(m_formatSupports);

//		memset(m_formatSupports, 0xff, sizeof(m_formatSupports));

		glGenFramebuffersEXT(1, &object);
		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, object);

#if 0
		for (size_t i = 0; i < ArraySize(formats); i++) {
#if 0
			GLenum dataformat, datatype, iformat;

			TexFormat format = TexFormat::R32F;
			trTexFormat(format, dataformat, datatype, iformat);
#else
			GLenum iformat = formats[i].e;
#endif
			GLuint rbuf;
			glGenRenderbuffersEXT(1, &rbuf);

			glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rbuf);

			glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, iformat, 32, 32);

			if (glGetError() != GL_NO_ERROR) {
				glDeleteRenderbuffersEXT(1, &rbuf);
				Printf("NOT SUPPORT %s\n", formats[i].s);
				continue;
			}

			int realf, r, g, b, a;
			glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_INTERNAL_FORMAT_EXT, &realf);
			glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_RED_SIZE_EXT, &r);
			glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_GREEN_SIZE_EXT, &g);
			glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_BLUE_SIZE_EXT, &b);
			glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_ALPHA_SIZE_EXT, &a);

			glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, rbuf);

			GLenum status = glCheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER_EXT);

			if (status == GL_NO_ERROR || status == GL_FRAMEBUFFER_COMPLETE_EXT) {
				Printf("SUPPORT %s, internal is %s, %d %d %d %d\n", formats[i].s, getName(realf), r, g, b, a);
			} else {
				Printf("NOT SUPPORT %s\n", formats[i].s);
			}

			glDeleteRenderbuffersEXT(1, &rbuf);
		}
#else
		for (int i = TexFormat::AUTO+1; i < TexFormat::MAX_NUMBER; i++) {
			m_formatSupports[i] = checkFormat(i);
		}
#endif

		glDrawBuffer(GL_BACK);
		glReadBuffer(GL_BACK);

		glDeleteFramebuffersEXT(1, &object);

		glGetError();
	}
コード例 #29
0
ファイル: RNAz.c プロジェクト: wash/rnaz
int main(int argc, char *argv[])
{

  char *modelDir=NULL;              /* Directory with model files */
  struct svm_model* decision_model; /* SVM classification model */

  /* Command line options */
  int reverse=0;     /* Scan reverse complement */
  int showVersion=0; /* Shows version and exits */
  int showHelp=0;    /* Show short help and exits */
  int from=-1;       /* Scan slice from-to  */
  int to=-1;

  FILE *clust_file=stdin; /* Input file */
  FILE *out=stdout; /* Output file */

  struct aln *AS[MAX_NUM_NAMES];     
  struct aln *window[MAX_NUM_NAMES]; 
  char *tmpAln[MAX_NUM_NAMES];

  int n_seq;  /* number of input sequences */
  int length; /* length of alignment/window */
  int z_score_type;
  int decision_model_type;

  char *structure=NULL;
  char *singleStruc,*gapStruc, *output,*woGapsSeq;
  char strand[8];
  char warningString[2000];
  char warningString_regression[2000];
  char *string=NULL;
  double singleMFE,sumMFE,singleZ,sumZ,z,sci,id,decValue,prob,comb,entropy,GC;
  double min_en, real_en;
  int i,j,k,l,ll,r,countAln,nonGaps,singleGC;
  int (*readFunction)(FILE *clust,struct aln *alignedSeqs[]);
  char** lines=NULL;
  int directions[3]={FORWARD,0,0};
  int currDirection;
  struct gengetopt_args_info args;

  double meanMFE_fwd=0;
  double consensusMFE_fwd=0;
  double sci_fwd=0;
  double z_fwd=0;
  int strandGuess;
  int avoid_shuffle=0;
  double strandProb,strandDec;
  
  if (cmdline_parser (argc, argv, &args) != 0){
    usage();
    exit(EXIT_FAILURE);
  }

  if (args.help_given){
    help();
    exit(EXIT_SUCCESS);
  }

  if (args.version_given){
    version();
    exit(EXIT_SUCCESS);
  }

  if (args.outfile_given){
    out = fopen(args.outfile_arg, "w");
    if (out == NULL){
      fprintf(stderr, "ERROR: Can't open output file %s\n", args.outfile_arg);
      exit(1);
    }
  }
    

  /* Strand prediction implies both strands scored */
  if (args.predict_strand_flag){
    args.both_strands_flag=1;
  }
  
  
  if (args.forward_flag && !args.reverse_flag){
    directions[0]=FORWARD;
    directions[1]=directions[2]=0;
  }
  if (!args.forward_flag && args.reverse_flag){
    directions[0]=REVERSE;
    directions[1]=directions[2]=0;
  }
  if ((args.forward_flag && args.reverse_flag) || args.both_strands_flag){
    directions[0]=FORWARD;
    directions[1]=REVERSE;
  }

  if (args.window_given){
    if (sscanf(args.window_arg,"%d-%d",&from,&to)!=2){
      nrerror("ERROR: Invalid --window/-w command. "
              "Use it like '--window 100-200'\n");
    }
    printf("from:%d,to:%d\n",from,to);
  }

  
  if (args.inputs_num>=1){
    clust_file = fopen(args.inputs[0], "r"); 
    if (clust_file == NULL){
      fprintf(stderr, "ERROR: Can't open input file %s\n", args.inputs[0]);
      exit(1);
    }
  }

 
  /* Global RNA package variables */
  do_backtrack = 1; 
  dangles=2;

  switch(checkFormat(clust_file)){
  case CLUSTAL:
    readFunction=&read_clustal;
    break;
  case MAF:
    readFunction=&read_maf;
    break;
  case 0:
    nrerror("ERROR: Unknown alignment file format. Use Clustal W or MAF format.\n");
  }

  /* Set z-score type (mono/dinucleotide) here */
  z_score_type = 2;

  if (args.mononucleotide_given) z_score_type = 0;


  /* now let's decide which decision model to take */
  /* decision_model_type = 1 for normal model used in RNAz 1.0 */
  /* decision_model_type = 2 for normal model using dinucelotide background */
  /* decision_model_type = 3 for structural model using dinucelotide background */
  decision_model_type = 2;
  if (args.mononucleotide_given) decision_model_type = 1;
  if (args.locarnate_given) decision_model_type = 3;
  if ((args.mononucleotide_given) && args.locarnate_given){
    z_score_type=2;
    nrerror("ERROR: Structural decision model only trained with dinucleotide background model.\n");
  }

  if (args.no_shuffle_given) avoid_shuffle = 1;

  decision_model=get_decision_model(NULL, decision_model_type);

  /* Initialize Regression Models for mononucleotide */
  /* Not needed if we score with dinucleotides */
  if (z_score_type == 0) regression_svm_init();
  
  countAln=0;

  while ((n_seq=readFunction(clust_file, AS))!=0){

	if (n_seq ==1){
	  nrerror("ERROR: You need at least two sequences in the alignment.\n");
	}
	
	countAln++;
	
	length = (int) strlen(AS[0]->seq);
	
	/* if a slice is specified by the user */
  
	if ((from!=-1 || to!=-1) && (countAln==1)){
      
	  if ((from>=to)||(from<=0)||(to>length)){
		nrerror("ERROR: Invalid window range given.\n");
	  }
	  
	  sliceAln((const struct aln**)AS, (struct aln **)window, from, to);
	  length=to-from+1;
	} else { /* take complete alignment */
	  /* window=AS does not work..., deep copy seems not necessary here*/
	  from=1;
	  to=length;
	  sliceAln((const struct aln **)AS, (struct aln **)window, 1, length);
	}

	 /* Convert all Us to Ts for RNAalifold. There is a slight
	    difference in the results. During training we used alignments
	    with Ts, so we use Ts here as well. */

	for (i=0;i<n_seq;i++){
	  j=0;
	  while (window[i]->seq[j]){
		window[i]->seq[j]=toupper(window[i]->seq[j]);
		if (window[i]->seq[j]=='U') window[i]->seq[j]='T';
		++j;
	  }
	}
	
	k=0;
	while ((currDirection=directions[k++])!=0){
	  
	  if (currDirection==REVERSE){
		revAln((struct aln **)window);
		strcpy(strand,"reverse");
	  } else {
		strcpy(strand,"forward");
	  }

	  structure = (char *) space((unsigned) length+1);

	  for (i=0;window[i]!=NULL;i++){
		tmpAln[i]=window[i]->seq;
	  }
	  tmpAln[i]=NULL;

	  min_en = alifold(tmpAln, structure);
	  free_alifold_arrays();

	  comb=combPerPair(window,structure);
	  
	  sumZ=0.0;
	  sumMFE=0.0;
	  GC=0.0;

	  output=(char *)space(sizeof(char)*(length+160)*(n_seq+1)*3);

	  strcpy(warningString,"");
	  strcpy(warningString_regression,"");

	  for (i=0;i<n_seq;i++){
		singleStruc = space(strlen(window[i]->seq)+1);
		woGapsSeq = space(strlen(window[i]->seq)+1);
		j=0;
		nonGaps=0;
		singleGC=0;
		while (window[i]->seq[j]){
		  /* Convert all Ts to Us for RNAfold. There is a difference
		     between the results. With U in the function call, we get
		     the results as RNAfold gives on the command line. Since
		     this variant was also used during training, we use it here
		     as well. */
		  if (window[i]->seq[j]=='T') window[i]->seq[j]='U';
		  if (window[i]->seq[j]=='C') singleGC++;
		  if (window[i]->seq[j]=='G') singleGC++;
		  if (window[i]->seq[j]!='-'){
		    nonGaps++;
		    woGapsSeq[strlen(woGapsSeq)]=window[i]->seq[j];
		    woGapsSeq[strlen(woGapsSeq)]='\0';
		  }
		  ++j;
		}
		
		/* z-score is calculated here! */
		singleMFE = fold(woGapsSeq, singleStruc);
		free_arrays();
		/* z-score type may be overwritten. If it is out of training
		   bounds, we switch to shuffling if allowed (avoid_shuffle). */
		int z_score_type_orig = z_score_type;


		singleZ=mfe_zscore(woGapsSeq,singleMFE, &z_score_type, avoid_shuffle, warningString_regression);

		GC+=(double) singleGC/nonGaps;
		sumZ+=singleZ;
		sumMFE+=singleMFE;

		if (window[1]->strand!='?' && !args.window_given){
		  sprintf(output+strlen(output),
			  ">%s %d %d %c %d\n",
			  window[i]->name,window[i]->start,
			  window[i]->length,window[i]->strand,
			  window[i]->fullLength);
		} else {
		  sprintf(output+strlen(output),">%s\n",window[i]->name);
		}


    gapStruc= (char *) space(sizeof(char)*(strlen(window[i]->seq)+1));

    l=ll=0;

    while (window[i]->seq[l]!='\0'){
			if (window[i]->seq[l]!='-'){
			  gapStruc[l]=singleStruc[ll];
			  l++;
			  ll++;
			} else {
			  gapStruc[l]='-';
			  l++;
			}
    }
    char ch;
    ch = 'R';
    if (z_score_type == 1 || z_score_type == 3) ch = 'S';
		  		  
    sprintf(output+strlen(output),"%s\n%s ( %6.2f, z-score = %6.2f, %c)\n",
            window[i]->seq,gapStruc,singleMFE,singleZ,ch);
    z_score_type = z_score_type_orig;
		  

		free(woGapsSeq);
		free(singleStruc);
		
	  }

	  {
		int i; double s=0;
		extern int eos_debug;
		eos_debug=-1; /* shut off warnings about nonstandard pairs */
		for (i=0; window[i]!=NULL; i++) 
		  s += energy_of_struct(window[i]->seq, structure);
		real_en = s/i;
	  }

	  string = consensus((const struct aln**) window);
	  sprintf(output+strlen(output),
			  ">consensus\n%s\n%s (%6.2f = %6.2f + %6.2f) \n",
			  string, structure, min_en, real_en, min_en-real_en );
	  free(string);

	  id=meanPairID((const struct aln**)window);
	  entropy=NormShannonEntropy((const struct aln**)window);
	  z=sumZ/n_seq;
	  GC=(double)GC/n_seq;

	  if (sumMFE==0){ 
		/*Set SCI to 0 in the weird case of no structure in single
		  sequences*/
		sci=0;
	  } else {
		sci=min_en/(sumMFE/n_seq);
	  }

	  
	  	  
	  decValue=999;
	  prob=0;
	
	  classify(&prob,&decValue,decision_model,id,n_seq,z,sci,entropy,decision_model_type);

	  if (args.cutoff_given){
		if (prob<args.cutoff_arg){
		  continue;
		}
	  }

	  warning(warningString,id,n_seq,z,sci,entropy,(struct aln **)window,decision_model_type);
	  

 	  fprintf(out,"\n############################  RNAz "PACKAGE_VERSION"  ##############################\n\n"); 
 	  fprintf(out," Sequences: %u\n", n_seq); 

 	  if (args.window_given){ 
 		fprintf(out," Slice: %u to %u\n",from,to); 
 	  } 
 	  fprintf(out," Columns: %u\n",length);
 	  fprintf(out," Reading direction: %s\n",strand); 
	  fprintf(out," Mean pairwise identity: %6.2f\n", id);
	  fprintf(out," Shannon entropy: %2.5f\n", entropy);
	  fprintf(out," G+C content: %2.5f\n", GC);
 	  fprintf(out," Mean single sequence MFE: %6.2f\n", sumMFE/n_seq); 
 	  fprintf(out," Consensus MFE: %6.2f\n",min_en); 
 	  fprintf(out," Energy contribution: %6.2f\n",real_en); 
 	  fprintf(out," Covariance contribution: %6.2f\n",min_en-real_en); 
 	  fprintf(out," Combinations/Pair: %6.2f\n",comb); 
	  fprintf(out," Mean z-score: %6.2f\n",z);
	  fprintf(out," Structure conservation index: %6.2f\n",sci);
	  if (decision_model_type == 1) {
	    fprintf(out," Background model: mononucleotide\n");
	    fprintf(out," Decision model: sequence based alignment quality\n");
	  }
	  if (decision_model_type == 2) {
	    fprintf(out," Background model: dinucleotide\n");
	    fprintf(out," Decision model: sequence based alignment quality\n");
	  }
	  if (decision_model_type == 3) {
	    fprintf(out," Background model: dinucleotide\n");
	    fprintf(out," Decision model: structural RNA alignment quality\n");
	  }
 	  fprintf(out," SVM decision value: %6.2f\n",decValue); 
 	  fprintf(out," SVM RNA-class probability: %6f\n",prob); 
 	  if (prob>0.5){ 
 		fprintf(out," Prediction: RNA\n"); 
 	  } 
 	  else { 
 		fprintf(out," Prediction: OTHER\n"); 
 	  } 

	  fprintf(out,"%s",warningString_regression);

	  fprintf(out,"%s",warningString);
	  
 	  fprintf(out,"\n######################################################################\n\n"); 
	
 	  fprintf(out,"%s",output); 
	
	  fflush(out);

	  free(structure);
	  free(output);

	  if (currDirection==FORWARD && args.predict_strand_flag){
		meanMFE_fwd=sumMFE/n_seq;
		consensusMFE_fwd=min_en;
		sci_fwd=sci;
		z_fwd=z;
	  }

	  if (currDirection==REVERSE && args.predict_strand_flag){

		if (predict_strand(sci_fwd-sci, meanMFE_fwd-(sumMFE/n_seq),
						   consensusMFE_fwd-min_en, z_fwd-z, n_seq, id, 
						   &strandGuess, &strandProb, &strandDec, NULL)){
		  if (strandGuess==1){
			fprintf(out, "\n# Strand winner: forward (%.2f)\n",strandProb);
		  } else {
			fprintf(out, "\n# Strand winner: reverse (%.2f)\n",1-strandProb);
		  }
		} else {
		  fprintf(out, "\n# WARNING: No strand prediction (values out of range)\n");
		}
	  }
	}
	freeAln((struct aln **)AS);
	freeAln((struct aln **)window);
	
  }
  if (args.inputs_num>=1){
    fclose(clust_file);
  }
  cmdline_parser_free (&args);

  if (countAln==0){
	nrerror("ERROR: Empty alignment file\n");
  }
  
  
  svm_destroy_model(decision_model);
  regression_svm_free();
  
  
  return 0;
}
コード例 #30
0
ファイル: dmaTaskWnt.cpp プロジェクト: ATHLSolutions/sipxecs
/*
 * dmaStartup -- Start the threads that generate the 10ms interval signal,
 *      and that handle the audio input and output.
 */
OsStatus dmaStartup(int samplesPerFrame)
{
    if (!checkFormat(1, SAMPLES_PER_SEC, BITS_PER_SAMPLE))
    {
        osPrintf(" %3d channels, %5d samples/sec, %2d bits/sample: is NOT supported\n",
                1, SAMPLES_PER_SEC, BITS_PER_SAMPLE) ;

        // 12/16/2004: Allow thread to startup and attempt to open audio
        // channels.  It will likely fail, but the code down stream will
        // fire off alt heartbeat mechanism.
    }


    // start a thread to receive microphone input
    // mic thread will prime the device input queue
    hMicThread = (HANDLE)_beginthreadex(
            NULL,             // pointer to thread security attributes
            16000,            // initial thread stack size, in bytes
            MicThread,        // pointer to thread function
            (LPVOID) 0,       // argument for new thread
            CREATE_SUSPENDED, // creation flags
            (unsigned*)&dwMicThreadID    // pointer to returned thread identifier
    );

    assert(NULL != hMicThread);

    // start a thread to send audio out to the speaker
    // speaker thread will prime the device output queue
    hSpkrThread = (HANDLE)_beginthreadex(
            NULL,             // pointer to thread security attributes
            16000,            // initial thread stack size, in bytes
            SpkrThread,       // pointer to thread function
            (LPVOID) 0,       // argument for new thread
            CREATE_SUSPENDED, // creation flags
            (unsigned*)&dwSpkrThreadID    // pointer to returned thread identifier
    );

    assert(NULL != hSpkrThread);

    // All these threads were started with the SUSPENDED option so that
    // the following thread priority manipulations can happen without
    // yielding the CPU.  They will be resumed soon, but see the comment
    // next below...
    SetThreadPriority(hSpkrThread, THREAD_PRIORITY_TIME_CRITICAL);
    SetThreadPriority(hMicThread, THREAD_PRIORITY_TIME_CRITICAL);


    // Both the Microphone thread and the Speaker thread issue resume
    // commands for the other thread (Mic resumes Spkr, Spkr resumes Mic).
    // (Resuming a running thread is harmless).
    //
    // Exactly one of the two threads should be resumed here, and that one
    // will get the first opportunity to open its side of the audio device.
    // Once it has done so, it will issue the resume command for the other
    // thread, so that on systems with half-duplex audio devices we will be
    // consistent about which device will be opened and which will fail.
    //
    // Currently, we start the Speaker thread first, so that we will be
    // sure to open the output device on a half-duplex system.  If it is
    // decided that we want to open only the input device in such situations,
    // REPLACE the next statement with "ResumeThread(hMicThread);"

    ResumeThread(hSpkrThread);

    return OS_SUCCESS;
}