亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? audiostreamengine.cpp

?? 使用Streaming方式進(jìn)行AMR-NB和PCM格式的錄音和播放
?? CPP
?? 第 1 頁 / 共 2 頁
字號(hào):
// If EFalse, the default PCM is used. If the platform does not support AMR-NB,
// PCM will be used no matter what the argument's value is.
// ----------------------------------------------------------------------------
void CAudioStreamEngine::SetEncodingL(TBool aAmr)
	{
	// Act only if the new encoding differs from the current one
	if (iUseAMR != aAmr)
		{
		iUseAMR = aAmr;
		if (iUseAMR)
			{
			// Try to set AMR-NB encoding, this will indicate whether it is supported
			// by the platform or not.
			TRAPD(err, iInputStream->SetDataTypeL(KMMFFourCCCodeAMR));
			if (err != KErrNone)
				{
				ShowMessage(_L("AMR-NB not supported,\nusing PCM."), ETrue);	
				iCurrentEncoding = iDefaultEncoding;
				iUseAMR = EFalse;
				// We do not need to invalidate the buffer or change buffer settings, 
				// since the encoding was not changed -> just return.
				return;  
				}
			else
				{
				iCurrentEncoding = KMMFFourCCCodeAMR;
				iAudioFile.Zero();  // Empty the audio file name				
				iAudioFile.Append(KAudioFileAMR);
				iFrameCount = KFrameCountAMR;
				iFrameSize = KFrameSizeAMR;
				ShowMessage(_L("Encoding set to AMR-NB."), ETrue);	
				}
			}
		else
			{
			// If we get here, the encoding has previously been changed to AMR. Switch back to
			// PCM.
			iCurrentEncoding = iDefaultEncoding;
			iAudioFile.Zero();  // Empty the audio file name				
			iAudioFile.Append(KAudioFilePCM);
			iFrameCount = KFrameCountPCM;
			iFrameSize = KFrameSizePCM;
			ShowMessage(_L("Encoding set to PCM."), ETrue);	
			}

		// Make sure the user re-records or reloads the audio file, so that we do not 
		// accidentally try to play PCM data using AMR or vice versa.
		iBufferOK = EFalse;	
		if (iStreamBuffer) delete iStreamBuffer;
		iStreamBuffer = NULL; // In case the following NewL leaves
		iStreamBuffer = HBufC8::NewMaxL(iFrameSize * iFrameCount);
		iStreamStart=0;
		iStreamEnd=iFrameCount - 1;
		}	
	}

// ----------------------------------------------------------------------------
// CAudioStreamEngine::ShowMessage(
//     const TDesC& aMsg, TBool aReset=EFalse)
//
// displays text referenced by aMsg in the label, will append the aMsg in the 
// existing text in label if aReset is EFalse, otherwise will reset the label 
// text.
// ----------------------------------------------------------------------------
void CAudioStreamEngine::ShowMessage(const TDesC& aMsg, TBool aReset=EFalse)
	{
	if (aReset) 	// if ETrue, clear the message on the label prior to output
		iMsg.Zero();
	iMsg.Append(aMsg);
	TRAPD(error, iAppUi->GetView()->ShowMessageL(iMsg));
	PanicIfError(error);
	}

// ----------------------------------------------------------------------------
// TPtr8& CAudioStreamEngine::GetFrame(TUint aFrameIdx)
//
// Returns a modifiable pointer to a single frame inside the audio buffer 
// ----------------------------------------------------------------------------
TPtr8& CAudioStreamEngine::GetFrame(TUint aFrameIdx)
	{
	  __ASSERT_ALWAYS(aFrameIdx < iFrameCount, 
  									User::Panic(_L("AudioStreamEx"), 1));
  								
	  iFramePtr.Set((TUint8*)(iStreamBuffer->Ptr() + (aFrameIdx * iFrameSize)),
  								 iFrameSize,
  								 iFrameSize);
	  return iFramePtr;
	}

// ----------------------------------------------------------------------------
// TPtr8& CAudioStreamEngine::GetPlaybackFrames(TUint aLastFrame)
//
// Returns a modifiable pointer to the requested frames inside the audio buffer
// (from the first frame to aLastFrame). 
// ----------------------------------------------------------------------------
TPtr8& CAudioStreamEngine::GetPlaybackFrames(TUint aLastFrame)
	{
	__ASSERT_ALWAYS(aLastFrame < iFrameCount, 
  								User::Panic(_L("AudioStreamEx"), 2));
  								
	iFramePtr.Set((TUint8*)(iStreamBuffer->Ptr()),
  								 (aLastFrame + 1) * iFrameSize,
  								 (aLastFrame + 1) * iFrameSize);
  	return iFramePtr;
	}


//
// MMdaAudioInputStream callbacks (MMdaAudioInputStreamCallback)
//
// ----------------------------------------------------------------------------
// CAudioStreamEngine::MaiscOpenComplete(
//     TInt aError)
//
// called upon completion of CMdaAudioInputStream::Open(),
// if the stream was opened succesfully (aError==KErrNone), it's ready for use.
// upon succesful open, the first audio data block will be read from the input
// stream.
// ----------------------------------------------------------------------------
void CAudioStreamEngine::MaiscOpenComplete(TInt aError)
	{
	if (aError==KErrNone) 
		{
		// Input stream opened succesfully, set status
		iInputStatus = EOpen;
		// Set the data type (encoding)
		TRAPD(error, iInputStream->SetDataTypeL(iCurrentEncoding));
		PanicIfError(error);

		// set stream input gain to maximum
		iInputStream->SetGain(iInputStream->MaxGain());	
		// set stream priority to normal and time sensitive
		iInputStream->SetPriority(EPriorityNormal, EMdaPriorityPreferenceTime);				
		ShowMessage(_L("Recording..."), ETrue);
		
		// Emtpy the buffer and issue ReadL() to read the first audio data block, 
		// subsequent calls to ReadL() will be issued 
		// in MMdaAudioInputStreamCallback::MaiscBufferCopied()
		iStreamBuffer->Des().FillZ(iFrameCount * iFrameSize);
		iStreamIdx=0;
		TRAPD(error2, iInputStream->ReadL(GetFrame(iStreamIdx)));
		PanicIfError(error2);
		} 
	else 
		{
		// input stream open failed
		iInputStatus = ENotReady;
		ShowMessage(_L("Recording failed!"), ETrue);
		}
	}

// ----------------------------------------------------------------------------
// CAudioStreamEngine::MaiscBufferCopied(
//     TInt aError, const TDesC8& aBuffer)
//
// called when a block of audio data has been read and is available at the 
// buffer reference *aBuffer.  calls to ReadL() will be issued until all blocks
// in the audio data buffer (iStreamBuffer) are filled.
// ----------------------------------------------------------------------------
void CAudioStreamEngine::MaiscBufferCopied(TInt aError, const TDesC8& /*aBuffer*/)
	{
	
	if (aError==KErrNone) 
		{
		// stop recording if at the end of the buffer
		iStreamIdx++;
		if (iStreamIdx == iFrameCount)
		    {
		    ShowMessage(_L("\nRecording complete!"), EFalse);
		    iStreamEnd = iStreamIdx - 1;
	    	iBufferOK = ETrue;
			iInputStatus = ENotReady;
			// NOTE: In 2nd Edition we MUST NOT call iInputStream->Stop() here, because
			// this will cause a crash on 2nd Edition, FP1 devices.
			// Since iInputStream->Stop() is not called, the callback method
			// MaiscRecordComplete() will not be called either after exiting this method.
			// In 3rd Edition, however, iInputStream->Stop() MUST be called in order to reach
			// MaiscRecordComplete(), otherwise the stream will "hang".
			#ifdef __SERIES60_3X__
				iInputStream->Stop();
			#endif
		    return;
		  	}		
		
		// issue ReadL() for next frame		
		TRAPD(error, iInputStream->ReadL(GetFrame(iStreamIdx)));
		PanicIfError(error);
		}
	else if (aError==KErrAbort) 
		{
		// Recording was aborted, due to call to CMdaAudioInputStream::Stop()
		// This KErrAbort will occur each time the Stop() method in this class is executed.
		// Also, MaiscRecordComplete() will be called after exiting this method.
	    iStreamEnd = iStreamIdx - 1;
	    iBufferOK = ETrue;
		iInputStatus = ENotReady;
		}
	else 
		{
		ShowMessage(_L("\nError reading data \nfrom input"), EFalse);
		iInputStatus = ENotReady;
		}
	}

// ----------------------------------------------------------------------------
// CAudioStreamEngine::MaiscRecordComplete(
//     TInt aError)
//
// called when input stream is closed by CMdaAudioInputStream::Stop()
// ----------------------------------------------------------------------------
void CAudioStreamEngine::MaiscRecordComplete(TInt aError)
	{	
	iInputStatus = ENotReady;
	if (aError==KErrNone) 
		{
		// normal stream closure
		}
	else 
		{
		// completed with error(s)
		}
	}


// MMdaAudioOutputStream callbacks (MMdaAudioOutputStreamCallback)

// ----------------------------------------------------------------------------
// CAudioStreamEngine::MaoscOpenComplete(
//     TInt aError)
//
// called upon completion of CMdaAudioOutputStream::Open(),
// if the stream was opened succesfully (aError==KErrNone), it's ready for use.
// upon succesful open, the first audio data block will be written to the 
// output stream.
// ----------------------------------------------------------------------------
void CAudioStreamEngine::MaoscOpenComplete(TInt aError)
	{
	if (aError==KErrNone) 
		{
		// output stream opened succesfully, set status
		iOutputStatus = EOpen;
		// Set the data type (encoding). Should not fail, since we already
		// have tested support for this encoding in SetEncodingL with the 
		// corresponding input stream!
		TRAPD(error, iOutputStream->SetDataTypeL(iCurrentEncoding));
		PanicIfError(error);
		
		// set volume to 1/4th of stream max volume
		iOutputStream->SetVolume(iOutputStream->MaxVolume()/4);
		// set stream priority to normal and time sensitive
		iOutputStream->SetPriority(EPriorityNormal, 
			EMdaPriorityPreferenceTime);				
		ShowMessage(_L("Playing "), ETrue);

		if (iUseAMR)
			{
			// In case of AMR, the whole recorded/loaded buffer is played back at once, not frame by frame. 
			// The buffer might not be fully recorded, so we will only play back the part
			// that is filled with data.
			iStreamIdx = iStreamEnd;
			TRAPD(error2, iOutputStream->WriteL(GetPlaybackFrames(iStreamEnd)));
			PanicIfError(error2);
			}
		else
			{
			// PCM needs to be played back frame by frame, otherwise some older devices might
			// run into buffer overflow situations.
			iStreamIdx = 0;
			TRAPD(error3, iOutputStream->WriteL(GetFrame(iStreamIdx)));
			PanicIfError(error3);
			}
		}
	else 
		{
		// output stream open failed
		iOutputStatus = ENotReady;
		ShowMessage(_L("Playback failed!"), ETrue);
		}		
	}

// ----------------------------------------------------------------------------
// CAudioStreamEngine::MaoscBufferCopied(
//     TInt aError, const TDesC8& aBuffer)
//
// called when a block of audio data has been written to MMF. calls to WriteL() 
// will be issued until all blocks in the audio data buffer (iStreamBuffer) are 
// written.
// ----------------------------------------------------------------------------
void CAudioStreamEngine::MaoscBufferCopied(TInt aError, const TDesC8& /*aBuffer*/)
	{	
	if (aError==KErrNone) 
		{
		if (iStreamIdx==iStreamEnd)
			{
			ShowMessage(_L("\nPlayback complete!"), EFalse);
			iOutputStatus = ENotReady;
			// NOTE: In 2nd Edition we MUST NOT call iOutputStream->Stop() here, because
			// this will cause a crash on 2nd Edition, FP1 devices.
			// Since iOutputStream->Stop() is not called, the callback method
			// MaiscRecordComplete() will not be called either after exiting this method.
			// In 3rd Edition, however, iOutputStream->Stop() MUST be called in order to reach
			// MaiscRecordComplete(), otherwise the stream will "hang".
			#ifdef __SERIES60_3X__
				iOutputStream->Stop();
			#endif
			}
		else 
			{
			iStreamIdx++;
			TRAPD(error, iOutputStream->WriteL(GetFrame(iStreamIdx)));	
			PanicIfError(error);
			}
		}
	else if (aError==KErrAbort) 
		{
		// Playing was aborted, due to call to CMdaAudioOutputStream::Stop().
		// MaoscRecordComplete() will be called after exiting this method.
		iOutputStatus = ENotReady;
		}
	else 
		{
		ShowMessage(_L("\nError writing data \nto output"), EFalse);			
		iOutputStatus = ENotReady;
		}
	}


// ----------------------------------------------------------------------------
// CAudioStreamEngine::MaoscPlayComplete(
//     TInt aError)
//
// called when output stream is closed by CMdaAudioOutputStream::Stop() or if 
// end of audio data has been reached, in this case KErrUnderflow will be 
// returned.
// ----------------------------------------------------------------------------
void CAudioStreamEngine::MaoscPlayComplete(TInt aError)
	{
	iOutputStatus = ENotReady;
	if (aError==KErrNone) 
		{
		// normal stream closure
		}	
	else if (aError==KErrUnderflow) 
		{
		// end of audio data stream was reached because of stream underflow,
		}
	else 
		{
		// completed with error(s)
		}	
	}

// END OF FILE

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
69p69国产精品| 亚洲免费在线视频一区 二区| 国产日产亚洲精品系列| 亚洲成人免费视| 国产91对白在线观看九色| 欧美精品日韩综合在线| 国产精品福利影院| 国产精品伊人色| 91精品视频网| 亚洲成人手机在线| 欧美午夜理伦三级在线观看| 国产精品视频免费| 国产一区二区精品久久| 欧美大片国产精品| 日韩激情av在线| 欧洲精品在线观看| 亚洲免费av高清| eeuss影院一区二区三区| 国产亚洲精品精华液| 奇米色777欧美一区二区| 日韩av网站免费在线| 久久精品亚洲国产奇米99| 一区二区三区四区在线免费观看| 国产毛片一区二区| 欧美成人vps| 九九**精品视频免费播放| 日韩欧美国产综合一区| 日本成人中文字幕在线视频| 正在播放亚洲一区| 日韩成人一区二区三区在线观看| 欧美系列一区二区| 午夜精品久久久久久久| 欧美日韩电影一区| 免费在线观看不卡| 26uuu色噜噜精品一区二区| 国产乱淫av一区二区三区| 欧美成人三级在线| 国产福利一区二区| ...中文天堂在线一区| 97久久超碰国产精品电影| 亚洲免费观看高清完整版在线| 91丝袜高跟美女视频| 亚洲一区二区中文在线| 欧美日韩久久一区| 久久不见久久见免费视频1| 久久色在线观看| 99视频精品全部免费在线| 一区二区三区久久| 欧美日韩一区高清| 激情综合五月天| 中文字幕一区二区三区蜜月| 日本二三区不卡| 午夜视频在线观看一区二区| 久久久久国产精品人| 国产精品自拍毛片| 国产精品女同互慰在线看| 91极品美女在线| 日韩av一级电影| 中文字幕在线免费不卡| 欧美日韩午夜精品| 国产精品性做久久久久久| 亚洲欧美国产三级| 欧美一区在线视频| av毛片久久久久**hd| 五月婷婷色综合| 国产偷国产偷亚洲高清人白洁| 色婷婷久久久久swag精品 | 岛国av在线一区| 亚洲美女在线一区| 精品国产污污免费网站入口 | 久久精品二区亚洲w码| 精品国产不卡一区二区三区| 成人性色生活片免费看爆迷你毛片| 亚洲激情综合网| 精品久久久久久亚洲综合网| 色综合久久中文字幕综合网 | 日韩欧美精品在线| 色综合网色综合| 国产美女精品在线| 日韩精品乱码av一区二区| 一区在线观看免费| 精品久久久久久久久久久久久久久 | 国产色婷婷亚洲99精品小说| 在线免费观看日本欧美| 国产精品乡下勾搭老头1| 日韩电影在线观看电影| 亚洲精品视频自拍| 欧美激情在线看| 久久无码av三级| 欧美刺激脚交jootjob| 欧美亚洲国产bt| 色综合久久久久综合体| 国产成人免费视频网站| 精品影院一区二区久久久| 天天操天天干天天综合网| 亚洲欧美福利一区二区| 国产精品毛片大码女人| 久久久久久久久97黄色工厂| 日韩欧美中文一区二区| 欧美精选午夜久久久乱码6080| 日本精品一区二区三区四区的功能| 国产+成+人+亚洲欧洲自线| 国产一区二区精品久久91| 韩国av一区二区| 久久成人av少妇免费| 喷水一区二区三区| 日本视频一区二区三区| 日韩电影在线观看一区| 婷婷一区二区三区| 日韩av午夜在线观看| 风间由美一区二区av101| 国产乱子伦视频一区二区三区| 精品在线你懂的| 国产麻豆精品在线观看| 国产高清无密码一区二区三区| 国产精品一区一区三区| 国产激情偷乱视频一区二区三区| 国产一区二区在线观看免费| 国产主播一区二区| 国产成人欧美日韩在线电影| 成人午夜视频福利| 色综合色综合色综合| 91传媒视频在线播放| 欧美群妇大交群中文字幕| 欧美肥大bbwbbw高潮| 欧美精品一级二级| 日韩午夜在线影院| 国产欧美一区二区精品仙草咪| 欧美激情一区三区| 亚洲美女在线国产| 天天爽夜夜爽夜夜爽精品视频| 免费亚洲电影在线| 国产69精品久久久久777| 色一情一乱一乱一91av| 这里只有精品99re| 久久综合丝袜日本网| 亚洲欧洲日韩在线| 五月天亚洲精品| 国产麻豆精品在线| 色屁屁一区二区| 欧美一级久久久| 欧美国产综合色视频| 亚洲国产精品影院| 国产精品一区二区久激情瑜伽| 99re这里只有精品首页| 9191国产精品| 国产精品免费视频观看| 性久久久久久久久| 国产aⅴ综合色| 欧洲精品一区二区| 久久久久国产精品麻豆| 亚洲一区二区三区爽爽爽爽爽| 久久er99精品| 欧美日韩精品一区二区在线播放| 亚洲精品在线三区| 一区二区三区不卡在线观看| 久久91精品国产91久久小草| 91在线免费播放| 精品国产一区二区在线观看| 亚洲精品伦理在线| 国产美女精品一区二区三区| 欧美日韩在线播放| 国产精品另类一区| 国模冰冰炮一区二区| 欧美少妇一区二区| 亚洲欧洲日产国码二区| 久久精品国产精品亚洲红杏| 精品视频资源站| 国产精品家庭影院| 国产精品一级片| 欧美sm美女调教| 亚洲成年人影院| 91视频www| 亚洲国产成人在线| 国产一区二区在线电影| 日韩视频在线观看一区二区| 亚洲女厕所小便bbb| 99综合电影在线视频| 久久免费视频色| 久久99国产精品久久99果冻传媒| 欧美视频自拍偷拍| 亚洲精品大片www| 成人av在线资源网站| 久久精品一区二区三区不卡牛牛| 奇米一区二区三区av| 欧美体内she精高潮| 亚洲一区中文日韩| 色8久久精品久久久久久蜜| 国产精品久久久久影院色老大| 国产美女精品在线| 国产日韩欧美激情| 国产精品一区在线| 欧美国产一区二区| 豆国产96在线|亚洲| 国产精品网站一区| 91精品国产乱码| 午夜精彩视频在线观看不卡| 欧美视频一区二区三区四区 | 欧美卡1卡2卡| 日韩国产在线观看|