www.pudn.com > SoundMixer_Example_v1_0.zip > CMixerThread.h


/*
*
============================================================================
* Name : CMixerThread.h
* Part of : SoundMixer
* Created : 03/01/2003 by Forum Nokia
* Description:
* This is the project specification file for SoundMixer.
* Initial content was generated by Series 60 AppWizard.
*
* Version : 1.0.0
* Copyright: Forum Nokia
*
============================================================================
*/

#ifndef __CMIXERTHREAD_H__
#define __CMIXERTHREAD_H__

// INCLUDES
#include <E32Base.h>
#include <mdaaudiooutputstream.h>
#include <mda\common\audio.h>
#include "TAudioShared.h"

// CLASS DECLARATION

/**
* CMixerThread is a class which is created to new thread
* for performance reasons. This class takes care of mixing
* maximum of 16 channels of sampled sound to audio output
* stream. Messages between client thread and mixer thread
* are handled via exceptions.
*/

class CMixerThread
: CBase
, MMdaAudioOutputStreamCallback
{
public:

/// Thread entry point
static TInt ThreadFunction( TAny* aData );

/// Default destructor
~CMixerThread();

private:

/// Default constructor
/// @param aData data pointer from creator thread
CMixerThread( TAny* aData );

/// Two phased constructor
/// @param aData data pointer from creator thread
static CMixerThread* Create( TAny* aData );

/// Second phase constructor
TInt Construct();

/// Second phase constructor which can leave
void ConstructL();

/// static exception handler function
/// @param aExc exception code
static void ExcHandler( TExcType aExc );

/// exception handler function
/// @param aExc exception code
void HandleException( TExcType aExc );

/// starts mixer
void StartMixer();

/// stops mixer
void StopMixer();

private: // MMdaAudioOutputStreamCallback

void MaoscPlayComplete( TInt aError );
void MaoscBufferCopied( TInt aError, const TDesC8&amt; aBuffer );
void MaoscOpenComplete( TInt aError );


private:

/// Fill mixing buffer with new data
void FillBuffer();



private:

CTrapCleanup* iCleanupStack;
CActiveScheduler* iActiveScheduler;
CMdaAudioOutputStream* iStream;
TMdaAudioDataSettings iSet;

TInt16* iBuffer; // buffer to CMdaAudioOutput
TInt* iMixBuffer; // 32-bit buffer to mixing
TPtrC8 iBufferPtr; // pointer to iBuffer

TInt iError; // contains CMdaAudioOutput errors

TAudioShared&amt; iShared; // reference to shared data with client

// current sample data pointers
TInt16* iAudioData[ KMaxChannels ];

// These are shifted by KAudioShift
TInt iAudioPos[ KMaxChannels ];
TInt iAudioEnd[ KMaxChannels ];
TInt iRepStart[ KMaxChannels ];
TInt iRepEnd[ KMaxChannels ];

};


#endif