?? csndmixer.cpp
字號:
/*
*
============================================================================
* Name : CSndMixer.cpp
* 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
*
============================================================================
*/
#include "CSndMixer.h"
#include "CMixerThread.h"
#include <e32svr.h>
CSndMixer* CSndMixer::NewL()
{
CSndMixer* self = new( ELeave )CSndMixer();
CleanupStack::PushL( self );
self->ConstructL();
CleanupStack::Pop( self );
return self;
}
void CSndMixer::ConstructL()
{
iShared.iMainVolume = 256; // default main volume
User::LeaveIfError( iMixerThread.Create( _L("Mixer"),
CMixerThread::ThreadFunction,
KDefaultStackSize,
NULL,
NULL) );
//
// Give all possible priority to audio
//
iMixerThread.SetPriority( EPriorityRealTime );
RThread().SetPriority( EPriorityAbsoluteLow );
User::LeaveIfError( iShared.iAliveMutex.CreateLocal( 1 ) );
User::LeaveIfError( iShared.iMutex.CreateLocal() );
iMixerThread.SetInitialParameter( &iShared );
iMixerThread.Resume();
iPaused = ETrue;
}
CSndMixer::CSndMixer()
{
}
CSndMixer::~CSndMixer()
{
if( iPaused )
{
SendCmd( ECmdStartMixer );
}
SendCmd( ECmdDestroyMixer );
//
iShared.iAliveMutex.Wait();
iShared.iAliveMutex.Close();
iShared.iMutex.Close();
}
void CSndMixer::Pause()
{
RDebug::Print( _L("CSndMixer::Pause") );
// check if mutex is already in wait ( pause mode )
if( iPaused )
{
return;
}
iPaused = ETrue;
SendCmd( ECmdStopMixer );
}
void CSndMixer::Resume()
{
RDebug::Print( _L("CSndMixer::Resume") );
if( !iPaused )
{
return;
}
iPaused = EFalse;
SendCmd( ECmdStartMixer );
}
void CSndMixer::Play( const TSample& aSample, TInt aChannel, TInt aFrequency, TInt aVolume )
{
iShared.iMutex.Wait();
iShared.iPlayStarted[ aChannel ] = ETrue;
iShared.iSample[ aChannel ] = aSample;
iShared.iFrequency[ aChannel ] = aFrequency;
iShared.iVolume[ aChannel ] = aVolume;
iShared.iMutex.Signal();
}
void CSndMixer::Stop( TInt aChannel )
{
iShared.iMutex.Wait();
iShared.iPlayStarted[ aChannel ] = ETrue;
iShared.iSample[ aChannel ] = iEmptySample;
iShared.iMutex.Signal();
}
void CSndMixer::SetVolume( TInt aVolume )
{
iShared.iMutex.Wait();
iShared.iMainVolume = aVolume;
iShared.iMutex.Signal();
}
TInt CSndMixer::Volume()
{
return iShared.iMainVolume;
}
void CSndMixer::SendCmd( TMixerCmd aCmd )
{
iShared.iMutex.Wait();
iShared.iCmd = aCmd;
iShared.iMutex.Signal();
iMixerThread.RaiseException( EExcUserInterrupt );
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -