Exemple #1
0
int CSound::LoadWV(const char *pFilename)
{
	// don't waste memory on sound when we are stress testing
	if(g_Config.m_DbgStress)
		return -1;

	// no need to load sound when we are running with no sound
	if(!m_SoundEnabled)
		return -1;

	if(!m_pStorage)
		return -1;

	ms_File = m_pStorage->OpenFile(pFilename, IOFLAG_READ, IStorageTW::TYPE_ALL);
	if(!ms_File)
	{
		dbg_msg("sound/wv", "failed to open file. filename='%s'", pFilename);
		return -1;
	}

	int SampleID = AllocID();
	if(SampleID < 0)
		return -1;

	// read the whole file into memory
	int DataSize = io_length(ms_File);

	if(DataSize <= 0)
	{
		io_close(ms_File);
		dbg_msg("sound/wv", "failed to open file. filename='%s'", pFilename);
		return -1;
	}

	char *pData = new char[DataSize];
	io_read(ms_File, pData, DataSize);

	SampleID = DecodeWV(SampleID, pData, DataSize);

	delete[] pData;
	io_close(ms_File);
	ms_File = NULL;

	if(g_Config.m_Debug)
		dbg_msg("sound/wv", "loaded %s", pFilename);

	RateConvert(SampleID);
	return SampleID;
}
Exemple #2
0
int CSound::LoadWVFromMem(const void *pData, unsigned DataSize, bool FromEditor = false)
{
	// don't waste memory on sound when we are stress testing
	if(g_Config.m_DbgStress)
		return -1;

	// no need to load sound when we are running with no sound
	if(!m_SoundEnabled && !FromEditor)
		return -1;

	if(!pData)
		return -1;

	int SampleID = AllocID();
	if(SampleID < 0)
		return -1;

	SampleID = DecodeWV(SampleID, pData, DataSize);

	RateConvert(SampleID);
	return SampleID;
}
Exemple #3
0
BOOLEAN Re_AsocReq(Signal_t *signal)
{
	FrmDesc_t *pfrmDesc;
	Frame_t *rdu;
	MacAddr_t Sta;
	U16 aid = 0;
	StatusCode asStatus;
	U8 lsInterval;
	Element WPA;
	Element asSsid;
	Element asRates;
	//Element extRates;
	U16 cap;
	U8 ZydasMode = 0;
	int i;
	U8 tmpMaxRate = 0x02;
	U8 MaxRate;
	U16 notifyStatus = STA_ASOC_REQ;
	U16 notifyStatus1 = STA_ASSOCIATED;
	TypeSubtype type = ST_ASOC_RSP;
	U8	Preamble = 0;
	U8	HigestBasicRate = 0;
	U8	vapId = 0;
	U8	Len;
	BOOLEAN bErpSta = FALSE;

	ZDEBUG("Re_AsocReq");
	pfrmDesc = signal->frmInfo.frmDesc;
	rdu = pfrmDesc->mpdu;
	lsInterval = listenInt(pfrmDesc->mpdu);
	//FPRINT_V("lsInterval", lsInterval);
	cap = cap(pfrmDesc->mpdu);
	memcpy((U8 *)&Sta, (U8 *)addr2(rdu), 6);
	
	if ((isGroup(addr2(rdu))) ||  (!getElem(rdu, EID_SSID, &asSsid))
		|| (!getElem(rdu, EID_SUPRATES, &asRates))){
		freeFdesc(pfrmDesc);
		return TRUE;
	}
	
	if ((eLen(&asSsid) != eLen(&dot11DesiredSsid) || 
		memcmp(&asSsid, &dot11DesiredSsid, eLen(&dot11DesiredSsid)+2) != 0)){
		freeFdesc(pfrmDesc);
		return TRUE;
	}		
	//chaeck capability
	if (cap & CAP_SHORT_PREAMBLE)
		Preamble = 1;
	else
		Preamble = 0;
		
	// Privacy not match
	if (cap & CAP_PRIVACY){
		if (!mPrivacyInvoked){
			freeFdesc(pfrmDesc);
			return TRUE;
		}	
	}
	else {
		if (mPrivacyInvoked){
			freeFdesc(pfrmDesc);
			return TRUE;
		}	
	}		
	Len = eLen(&asRates);	
	for (i=0; i<Len; i++){
		if ( (asRates.buf[2+i] & 0x7f) > tmpMaxRate ){
			tmpMaxRate = (asRates.buf[2+i] & 0x7f);
			if (asRates.buf[2+i] & 0x80)
				HigestBasicRate = asRates.buf[2+i];
		}	
				
		if (((asRates.buf[2+i] & 0x7f) == 0x21) && (!(cap & CAP_PBCC_ENABLE))){ //Zydas 16.5M
			void *reg = pdot11Obj->reg;
			
			ZydasMode = 1;
			mZyDasModeClient = TRUE;
			//FPRINT("ZydasMode");
		}	
	}	
	
	MaxRate = RateConvert((tmpMaxRate & 0x7f), cap);			
	
	if (signal->id == SIG_REASSOC_REQ)	
		notifyStatus = STA_REASOC_REQ;
		
	if (!pdot11Obj->StatusNotify(notifyStatus, (U8 *)&Sta)){ //Accept it
		if (mDynKeyMode == DYN_KEY_TKIP){	
			if (getElem(rdu, EID_WPA, &WPA)){
				//zd1205_OctetDump("AssocRequest = ", asRdu->body, asRdu->bodyLen);
				//zd1205_OctetDump("AssocRequest WPA_IE = ", &WPA.buf[2], WPA.buf[1]);
				
				if (pdot11Obj->AssocRequest((U8 *)&Sta, rdu->body, rdu->bodyLen)){ //reject
					asStatus = SC_UNSPEC_FAILURE;
					goto check_failed;
					//we need reason code here
				}	
			}
			else{
				asStatus = SC_UNSPEC_FAILURE;
				goto wpa_check_failed;		
		}		
		}		

wpa_check_ok:			
		if (!UpdateStaStatus(&Sta, STATION_STATE_ASOC, vapId)){
			asStatus = SC_AP_FULL;
		}
		else{
			AssocInfoUpdate(&Sta, MaxRate, lsInterval, ZydasMode, Preamble, bErpSta, vapId);
			aid = AIdLookup(&Sta);
			asStatus = SC_SUCCESSFUL;
			if (signal->id == SIG_REASSOC_REQ)	
				notifyStatus1 = STA_REASSOCIATED;
			pdot11Obj->StatusNotify(notifyStatus1, (U8 *)&Sta);
		}
	}
	else{
wpa_check_failed:	
		asStatus = SC_UNSPEC_FAILURE;
	}	
	
	aid |= 0xC000;
	if (aid != 0xC000){
		#ifdef B500_DEBUG
			FPRINT_V("Aid", aid);
			FPRINT_V("MaxRate", MaxRate);
		#endif

	}	
	
check_failed:
	if (signal->id == SIG_REASSOC_REQ)	
		type = ST_REASOC_RSP;	
	mkRe_AsocRspFrm(pfrmDesc, type, &Sta, mCap, asStatus, aid, &mBrates, NULL, vapId);
	sendMgtFrame(signal, pfrmDesc);

	return FALSE;
}
Exemple #4
0
int CSound::LoadWV(const char *pFilename)
{
	CSample *pSample;
	int SampleID = -1;
	char aError[100];
	WavpackContext *pContext;

	// don't waste memory on sound when we are stress testing
	if(g_Config.m_DbgStress)
		return -1;

	// no need to load sound when we are running with no sound
	if(!m_SoundEnabled)
		return 1;

	if(!m_pStorage)
		return -1;

	ms_File = m_pStorage->OpenFile(pFilename, IOFLAG_READ, IStorage::TYPE_ALL);
	if(!ms_File)
	{
		dbg_msg("sound/wv", "failed to open file. filename='%s'", pFilename);
		return -1;
	}

	SampleID = AllocID();
	if(SampleID < 0)
		return -1;
	pSample = &m_aSamples[SampleID];

	pContext = WavpackOpenFileInput(ReadData, aError);
	if (pContext)
	{
		int m_aSamples = WavpackGetNumSamples(pContext);
		int BitsPerSample = WavpackGetBitsPerSample(pContext);
		unsigned int SampleRate = WavpackGetSampleRate(pContext);
		int m_aChannels = WavpackGetNumChannels(pContext);
		int *pData;
		int *pSrc;
		short *pDst;
		int i;

		pSample->m_Channels = m_aChannels;
		pSample->m_Rate = SampleRate;

		if(pSample->m_Channels > 2)
		{
			dbg_msg("sound/wv", "file is not mono or stereo. filename='%s'", pFilename);
			return -1;
		}

		/*
		if(snd->rate != 44100)
		{
			dbg_msg("sound/wv", "file is %d Hz, not 44100 Hz. filename='%s'", snd->rate, filename);
			return -1;
		}*/

		if(BitsPerSample != 16)
		{
			dbg_msg("sound/wv", "bps is %d, not 16, filname='%s'", BitsPerSample, pFilename);
			return -1;
		}

		pData = (int *)mem_alloc(4*m_aSamples*m_aChannels, 1);
		WavpackUnpackSamples(pContext, pData, m_aSamples); // TODO: check return value
		pSrc = pData;

		pSample->m_pData = (short *)mem_alloc(2*m_aSamples*m_aChannels, 1);
		pDst = pSample->m_pData;

		for (i = 0; i < m_aSamples*m_aChannels; i++)
			*pDst++ = (short)*pSrc++;

		mem_free(pData);

		pSample->m_NumFrames = m_aSamples;
		pSample->m_LoopStart = -1;
		pSample->m_LoopEnd = -1;
		pSample->m_PausedAt = 0;
	}
	else
	{
		dbg_msg("sound/wv", "failed to open %s: %s", pFilename, aError);
	}

	io_close(ms_File);
	ms_File = NULL;

	if(g_Config.m_Debug)
		dbg_msg("sound/wv", "loaded %s", pFilename);

	RateConvert(SampleID);
	return SampleID;
}