mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 23:37:46 -04:00
UIQ3 update, some makefile unification, rm old configs, stuff
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@569 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
a6e5aa4181
commit
ca482e5de8
66 changed files with 1748 additions and 1377 deletions
|
@ -15,6 +15,7 @@
|
|||
#include "audio_mediaserver.h"
|
||||
#include "debug.h"
|
||||
|
||||
//#define DEBUG_UNDERFLOWS
|
||||
//#undef DEBUGPRINT
|
||||
//#define DEBUGPRINT(x...)
|
||||
|
||||
|
@ -31,16 +32,16 @@ const TInt KMaxUnderflows = 50; // max underflows/API errors we are going allow
|
|||
*
|
||||
*******************************************/
|
||||
|
||||
CGameAudioMS::CGameAudioMS(TInt aRate, TBool aStereo, TInt aWritesPerSec)
|
||||
: iRate(aRate), iStereo(aStereo), iWritesPerSec(aWritesPerSec)
|
||||
CGameAudioMS::CGameAudioMS(TInt aRate, TBool aStereo, TInt aWritesPerSec, TInt aVolume)
|
||||
: iRate(aRate), iStereo(aStereo), iWritesPerSec(aWritesPerSec), iVolume(aVolume)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CGameAudioMS* CGameAudioMS::NewL(TInt aRate, TBool aStereo, TInt aWritesPerSec)
|
||||
CGameAudioMS* CGameAudioMS::NewL(TInt aRate, TBool aStereo, TInt aWritesPerSec, TInt aVolume)
|
||||
{
|
||||
DEBUGPRINT(_L("CGameAudioMS::NewL(%i, %i, %i)"), aRate, aStereo, aWritesPerSec);
|
||||
CGameAudioMS* self = new(ELeave) CGameAudioMS(aRate, aStereo, aWritesPerSec);
|
||||
DEBUGPRINT(_L("CGameAudioMS::NewL(%i, %i, %i, %i)"), aRate, aStereo, aWritesPerSec, aVolume);
|
||||
CGameAudioMS* self = new(ELeave) CGameAudioMS(aRate, aStereo, aWritesPerSec, aVolume);
|
||||
CleanupStack::PushL(self);
|
||||
self->ConstructL();
|
||||
CleanupStack::Pop(); // self
|
||||
|
@ -85,25 +86,29 @@ void CGameAudioMS::ConstructL()
|
|||
iMdaAudioDataSettings.iCaps = TMdaAudioDataSettings::ESampleRateFixed | iMdaAudioDataSettings.iSampleRate;
|
||||
iMdaAudioDataSettings.iFlags = TMdaAudioDataSettings::ENoNetworkRouting;
|
||||
|
||||
int pcmFrames = iRate / iWritesPerSec;
|
||||
pcmFrames += iRate - (iRate / iWritesPerSec) * iWritesPerSec; // add division remainder too for our buffer size
|
||||
iBufferedFrames = iWritesPerSec / KUpdatesPerSec;
|
||||
iMaxWriteSamples = iRate / iWritesPerSec;
|
||||
if (iRate % iWritesPerSec)
|
||||
iMaxWriteSamples++;
|
||||
int bufferedFrames = iWritesPerSec / KUpdatesPerSec;
|
||||
|
||||
TInt bytesPerFrame = pcmFrames << (iStereo?2:1);
|
||||
iBufferSize = iMaxWriteSamples * (iStereo ? 4 : 2);
|
||||
iBufferSize *= bufferedFrames;
|
||||
for (TInt i=0 ; i<KSoundBuffers ; i++)
|
||||
{
|
||||
iSoundBuffers[i] = HBufC8::NewL(bytesPerFrame * iBufferedFrames);
|
||||
iSoundBuffers[i]->Des().FillZ (bytesPerFrame * iBufferedFrames);
|
||||
iSoundBuffers[i] = HBufC8::NewL(iBufferSize);
|
||||
iSoundBuffers[i]->Des().FillZ (iBufferSize);
|
||||
}
|
||||
|
||||
iCurrentBuffer = 0;
|
||||
iCurrentBufferSize = 0;
|
||||
|
||||
DEBUGPRINT(_L("sound: iMaxWriteSamples: %i, iBufferSize: %i"), iMaxWriteSamples, iBufferSize);
|
||||
|
||||
// here we actually test if we can create and open CMdaAudioOutputStream at all, but really create and use it later.
|
||||
iMdaAudioOutputStream = CMdaAudioOutputStream::NewL(iListener, iServer);
|
||||
if(iMdaAudioOutputStream) {
|
||||
iVolume = iMdaAudioOutputStream->MaxVolume();
|
||||
DEBUGPRINT(_L("MaxVolume: %i"), iVolume);
|
||||
if (iMdaAudioOutputStream) {
|
||||
if (iVolume < 0 || iVolume > iMdaAudioOutputStream->MaxVolume())
|
||||
iVolume = iMdaAudioOutputStream->MaxVolume();
|
||||
delete iMdaAudioOutputStream;
|
||||
iMdaAudioOutputStream = 0;
|
||||
}
|
||||
|
@ -113,11 +118,18 @@ void CGameAudioMS::ConstructL()
|
|||
// to be used when iSoundBuffers are used directly
|
||||
TInt16 *CGameAudioMS::NextFrameL(TInt aPcmFrames)
|
||||
{
|
||||
iCurrentPosition += aPcmFrames << (iStereo?1:0);
|
||||
iCurrentBufferSize += aPcmFrames << (iStereo?2:1);
|
||||
TInt mul = iStereo ? 4 : 2;
|
||||
TInt bytes = aPcmFrames * mul;
|
||||
iCurrentPosition += bytes / 2;
|
||||
iCurrentBufferSize += bytes;
|
||||
|
||||
if (++iFrameCount == iBufferedFrames)
|
||||
if (aPcmFrames > iMaxWriteSamples) {
|
||||
DEBUGPRINT(_L("too many samples: %i > %i"), aPcmFrames, iMaxWriteSamples);
|
||||
}
|
||||
|
||||
if (iCurrentBufferSize + iMaxWriteSamples * mul > iBufferSize)
|
||||
{
|
||||
//DEBUGPRINT(_L("write on iCurrentBufferSize %i"), iCurrentBufferSize);
|
||||
WriteBlockL();
|
||||
}
|
||||
|
||||
|
@ -162,9 +174,9 @@ void CGameAudioMS::WriteBlockL()
|
|||
}
|
||||
}
|
||||
|
||||
iFrameCount = 0;
|
||||
if (++iCurrentBuffer == KSoundBuffers)
|
||||
iCurrentBuffer = 0;
|
||||
iSoundBuffers[iCurrentBuffer]->Des().SetMax();
|
||||
iCurrentPosition = (TInt16*) iSoundBuffers[iCurrentBuffer]->Ptr();
|
||||
iCurrentBufferSize = 0;
|
||||
}
|
||||
|
@ -189,7 +201,6 @@ TInt16 *CGameAudioMS::ResumeL()
|
|||
iListener.iIsOpen = ETrue;
|
||||
iListener.iUnderflowed = 1;
|
||||
iListener.iLastError = 0;
|
||||
iFrameCount = 0;
|
||||
iCurrentBufferSize = 0;
|
||||
iCurrentPosition = (TInt16*) iSoundBuffers[iCurrentBuffer]->Ptr();
|
||||
return iCurrentPosition;
|
||||
|
@ -198,7 +209,9 @@ TInt16 *CGameAudioMS::ResumeL()
|
|||
// handles underflow condition
|
||||
void CGameAudioMS::UnderflowedL()
|
||||
{
|
||||
#ifdef DEBUG_UNDERFLOWS
|
||||
DEBUGPRINT(_L("UnderflowedL()"));
|
||||
#endif
|
||||
|
||||
if (iListener.iLastError != KErrUnderflow)
|
||||
{
|
||||
|
@ -243,23 +256,30 @@ void CGameAudioMS::WaitForOpenToCompleteL()
|
|||
User::LeaveIfError(KErrNotSupported);
|
||||
}
|
||||
|
||||
void CGameAudioMS::ChangeVolume(TInt aUp)
|
||||
TInt CGameAudioMS::ChangeVolume(TInt aUp)
|
||||
{
|
||||
//DEBUGPRINT(_L("CGameAudioMS::ChangeVolume(%i)"), aUp);
|
||||
|
||||
if (iMdaAudioOutputStream) {
|
||||
if (aUp) {
|
||||
if (iVolume < iMdaAudioOutputStream->MaxVolume()) iVolume+=5;
|
||||
iVolume += 5;
|
||||
if (iVolume > iMdaAudioOutputStream->MaxVolume())
|
||||
iVolume = iMdaAudioOutputStream->MaxVolume();
|
||||
} else {
|
||||
if (iVolume > 0) iVolume-=5;
|
||||
iVolume -= 5;
|
||||
if (iVolume < 0) iVolume = 0;
|
||||
}
|
||||
iMdaAudioOutputStream->SetVolume(iVolume);
|
||||
}
|
||||
|
||||
return iVolume;
|
||||
}
|
||||
|
||||
void TGameAudioEventListener::MaoscOpenComplete(TInt aError)
|
||||
{
|
||||
#ifdef DEBUG_UNDERFLOWS
|
||||
DEBUGPRINT(_L("CGameAudioMS::MaoscOpenComplete, error=%d"), aError);
|
||||
#endif
|
||||
|
||||
iIsOpen = ETrue;
|
||||
if(aError) {
|
||||
|
@ -284,7 +304,9 @@ void TGameAudioEventListener::MaoscBufferCopied(TInt aError, const TDesC8& aBuff
|
|||
|
||||
void TGameAudioEventListener::MaoscPlayComplete(TInt aError)
|
||||
{
|
||||
#ifdef DEBUG_UNDERFLOWS
|
||||
DEBUGPRINT(_L("CGameAudioMS::MaoscPlayComplete: %i"), aError);
|
||||
#endif
|
||||
if(aError) {
|
||||
iLastError = aError;
|
||||
iUnderflowed++; // never happened to me while testing, but just in case
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue