I want to make an app which will be able to streaming input and output in half duplex mode. that is it will record data and send it over UDP socket and in another mode play the stream recieved through the socket.


This following code i have written to implement half duplex streaming

Here goes the header file of the engine
Code:
#ifndef Push2TalkV1bbENGINE_H
#define Push2TalkV1bbENGINE_H

// INCLUDES
#include <e32base.h>
#include <aknviewappui.h> 
#include <e32des8.h>
#include <mda\common\audio.h>
#include <MdaAudioInputStream.h>	// audio input stream
#include <MdaAudioOutputStream.h>	// audio output stream

/*#include "Push2TalkV1b.hrh"
#include "Push2TalkV1bView.h"	
#include "Push2TalkV1bAppUi.h"	
*/
// FORWARD DECLARATIONS

// CLASS DECLARATION

/**
*  CPush2TalkV1bEngine application engine class.
*  
*/
class CPush2TalkV1bEngine : public CBase, MMdaAudioInputStreamCallback, 
	MMdaAudioOutputStreamCallback
{
public:
/*!
* NewL()
* 
* discussion Create new CPush2TalkV1bEngine object
* return a pointer to the created instance of CPush2TalkV1bEngine
*/
    static CPush2TalkV1bEngine* NewL();

/*!
* NewLC()
* 
* discussion Create new CPush2TalkV1bEngine object
* return a pointer to the created instance of CPush2TalkV1bEngine which 
*    has also been pushed to cleanup stack
*/
    static CPush2TalkV1bEngine* NewLC();


/*!
* ~CPush2TalkV1bEngine()
*
* discussion Destroy the object and release all memory objects
*/
	~CPush2TalkV1bEngine();
        

public: // New functions
	
/*!
* Play()
*
* discussion Plays the audio data sample
*/
	void Play();
/*!
* Record()
*
* discussion Records an audio data sample
*/
	void Record();
/*!
* Stop()
*
* discussion Stops the playing/recording of the audio data
*/
	void Stop();
	
/*!
* LoadAudioFileL()
*
* discussion Loads an audio data from a file
*/
	void LoadAudioFileL();
/*!
* SaveAudioFileL()
*
* discussion Saves the audio data into a file
*/
	void SaveAudioFileL();

	
private: // in-class methods

	
/*!
* MaiscOpenComplete()
*
* discussion A callback function that is called when 
*    CMdaAudioInputStream::Open() has completed, indicating that the audio 
*    input stream is ready for use.
*
* param aError KErrNone if the open succeeded, otherwise one of the system 
*    error codes.
*/
	virtual void MaiscOpenComplete(TInt aError);
/*!
* MaiscBufferCopied()
*
* discussion A callback function that is called when a chunk of audio data 
*    has been copied to the descriptor specified in a 
*    CMdaAudioInputStream::ReadL().
*
* param aError KErrNone if the copy succeeded, KErrAbort if the input stream
*    was closed for some reason, otherwise one of the system error codes.
*/
	virtual void MaiscBufferCopied(TInt aError, const TDesC8& aBuffer);
/*!
* MaiscRecordComplete()
*
* discussion A callback function that is called when the input stream is
*    closed using CMdaAudioInputStream::Stop(). 
*
* param aError KErrNone if the stop succeeded, otherwise one of the system
*    error codes.
*/	
	virtual void MaiscRecordComplete(TInt aError);

/*!
* MaoscOpenComplete()
*
* discussion A callback function that is called when 
*    CMdaAudioOutputStream::Open() has completed, indicating that the audio 
*    output stream is ready for use.
*
* param aError KErrNone if the open succeeded, otherwise one of the system 
*    error codes.
*/
	virtual void MaoscOpenComplete(TInt aError);
/*!
* MaoscBufferCopied()
*
* discussion A callback function that is called when a descriptor has been 
*    copied to the lower layers of MMF. It is also called when an error has 
*    occurred or when the client has stopped the stream playing before the 
*    descriptor has been fully copied (by calling 
*    CMdaAudioOutputStream::Stop())
*
* param aError KErrNone if the copy succeeded, otherwise one of the system
*    error codes. KErrAbort indicates that the client has stopped the stream
*    playing before the descriptor has been copied.
* param aBuffer reference to the buffer that has been copied.
*/
	virtual void MaoscBufferCopied(TInt aError, const TDesC8& aBuffer);
	
/*!
* MaoscPlayComplete()
*
* discussion A callback function that is called when playback terminates as
*    a result of a CMdaAudioOutputStream::Stop().
*
* param aError KErrNone if the close succeeded, otherwise one of the system
*    error codes.
*/
	virtual void MaoscPlayComplete(TInt aError);

public: // Functions from base classes

private: // Basic two-phase EPOC constructors

/*!
* ConstructL()
*
* discussion Perform the second phase construction of a CPush2TalkV1bEngine 
*    object
*/
    void ConstructL();

/*!
* CPush2TalkV1bEngine()
*
* discussion Perform the first phase of two phase construction 
*/
    CPush2TalkV1bEngine();

private:	

	// enumeration of input/output stream status
	enum TStatus
		{
		ENotReady,
		EOpen
		};

		
private: 	// data members

	// audio input stream object reference
	CMdaAudioInputStream* iInputStream;
	// audio output stream object reference
	CMdaAudioOutputStream* iOutputStream;
	// audio data stream settings for input and output streams
	TMdaAudioDataSettings iStreamSettings;
	// status enumeration of input stream
	TStatus iInputStatus;
	// status enumeration of output stream	
	TStatus iOutputStatus;
	// index of audio data block currently being played/recorded on the buffer
	TInt iStreamIdx;
	// application status message displayed to user
	TBuf<64> iMsg;
	// stream start (first audio block in buffer) and end index
	TInt iStreamStart;
	TInt iStreamEnd;
	//before finally writing to file this RBuf8 is updated continuously
	//*****************************************************************************
	RBuf8 fileBuf;
	
	TDes8* buffer;
	
	//TPtrC8 playBuf;
	//******************************************************************************
};

#endif // Push2TalkV1bbENGINE_H

The general idea is that we will instantiate the engine from appui and the record and play everything will be triggered from appui.

Though i know it is cumbersome to go through this huge codes still if anybodycan help then!!!

following is the part of implementation of the engine

Code:
// Standard EPOC 2nd phase constructor
void CPush2TalkV1bEngine::ConstructL()
	{
	// Construct input stream
	iInputStream = CMdaAudioInputStream::NewL(*this);
	// Construct output stream
	iOutputStream = CMdaAudioOutputStream::NewL(*this);

	// Stream buffer allocation
	buffer = new(ELeave) TBuf8<KStreamBufferSize>;
	buffer->SetMax();
		
	//RBuf initiation***********************************************************
	//Achtung! ****************************************************************
	
	fileBuf.CreateMaxL(KAppendSize);
	fileBuf.CleanupClosePushL();
	//************************************************************************
	
	iStreamStart=0;
	
	}

*
*
*
*
*
*
// ----------------------------------------------------------------------------
// CPush2TalkV1bEngine::Record()
//
// records audio data into the buffer
// ----------------------------------------------------------------------------
void CPush2TalkV1bEngine::Record()
	{
	// If either stream is active, return
	if (iInputStatus!=ENotReady || iOutputStatus!=ENotReady) 
		return;
	// open input stream
	// upon completion will receive callback in 
	// MMdaAudioInputStreamCallback::MaiscOpenComplete()
	iInputStream->Open(&iStreamSettings);
	}

**
*
*
*
*
*
*

void CPush2TalkV1bEngine::MaiscOpenComplete(TInt aError)
	{
	if (aError==KErrNone) 
		{				
		// input stream opened succesfully, set status
		iInputStatus = EOpen;
		// set stream properties, 16bit 8KHz mono
		iInputStream->SetAudioPropertiesL(iStreamSettings.iSampleRate, 
			iStreamSettings.iChannels);
		// set stream input gain to maximum
		iInputStream->SetGain(iInputStream->MaxGain());	
		// set stream priority to normal and time sensitive
		iInputStream->SetPriority(EPriorityNormal, EMdaPriorityPreferenceTime);				
	
		// issue ReadL() to read the first audio data block, 
		// subsequent calls to ReadL() will be issued 
		// in MMdaAudioInputStreamCallback::MaiscBufferCopied()
		iStreamIdx=0;
		iInputStream->ReadL(*buffer);
		} 
	else 
		{
		// input stream open failed
		iInputStatus = ENotReady;
	//	ShowMessageL(_L("Recording failed!"), true);
		}
	}

*
*
*
*
*
*
*
void CPush2TalkV1bEngine::MaiscBufferCopied(TInt aError, const TDesC8& aBuffer)
	{
	if (aError==KErrNone) 
		{
		
			//***************************************************************************************
			//***************************************************************************************
			//appending the data into RBuf
			//first time allocated size is 960
			
				fileBuf.Append(aBuffer);
			/*const TInt appendsize=fileBuf.Length()+KAppendSize;
			if(fileBuf.Length()<appendsize)*/
			if(iStreamIdx==(KStreamBufferCount-1))
				{
				fileBuf.ReAllocL(KAppendSize);
				iStreamIdx=0;
				}
			else
				iStreamIdx++;
			
			//****************************************************************************************	
			
		iInputStream->ReadL(*buffer);
		}
	else if (aError==KErrAbort) 
		{
		// recording was aborted, due to call to CMdaAudioInputStream::Stop()
		// this KErrAbort will occur each time the Stop() above is executed.
		iInputStatus = ENotReady;
		SaveAudioFileL();
		}
	else 
		{
		// error reading data from input
		iInputStatus = ENotReady;
		}
	}
This is the recording part..the code compiles and gets linked fine but crashes whenever the ConstructL part is over and the code hits either "record" or "play".

I cannot track the point where the code is leaving even in the debug mode.