From 7b00db03123ae6a4761d0fc42bac0a5be6b4ad28 Mon Sep 17 00:00:00 2001 From: Lars Persson Date: Fri, 18 Jul 2008 19:02:40 +0000 Subject: Symbian soundsmixer update. (Compile fix) svn-id: r33098 --- backends/platform/symbian/src/SymbianOS.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'backends/platform/symbian/src/SymbianOS.cpp') diff --git a/backends/platform/symbian/src/SymbianOS.cpp b/backends/platform/symbian/src/SymbianOS.cpp index dfeb24d825..9e0b8d7c22 100644 --- a/backends/platform/symbian/src/SymbianOS.cpp +++ b/backends/platform/symbian/src/SymbianOS.cpp @@ -33,7 +33,7 @@ #include "gui/Actions.h" #include "gui/Key.h" #include "gui/message.h" - +#include "sound/mixer_intern.h" #include "..\..\sdl\main.cpp" #ifdef SAMPLES_PER_SEC_8000 // the GreanSymbianMMP format cannot handle values for defines :( @@ -246,9 +246,9 @@ void OSystem_SDL_Symbian::symbianMixCallback(void *sys, byte *samples, int len) if (!this_->_mixer) return; -#ifdef S60 +#if defined (S60) && !defined(S60V3) // If not stereo then we need to downmix - if (_channels != 2) { + if (this_->_mixer->_channels != 2) { this_->_mixer->mixCallback(_stereo_mix_buffer, len * 2); int16 *bitmixDst = (int16 *)samples; -- cgit v1.2.3 From 0f03a7bcd82ae6e07521cfaf599b41ac6b38f5ef Mon Sep 17 00:00:00 2001 From: Lars Persson Date: Fri, 18 Jul 2008 20:40:48 +0000 Subject: Introduced cache for filereading to fix slowness in AGOS among others. svn-id: r33099 --- backends/platform/symbian/src/SymbianOS.cpp | 91 ++++++++++++++++++++++++++--- 1 file changed, 82 insertions(+), 9 deletions(-) (limited to 'backends/platform/symbian/src/SymbianOS.cpp') diff --git a/backends/platform/symbian/src/SymbianOS.cpp b/backends/platform/symbian/src/SymbianOS.cpp index 9e0b8d7c22..5544cf0887 100644 --- a/backends/platform/symbian/src/SymbianOS.cpp +++ b/backends/platform/symbian/src/SymbianOS.cpp @@ -42,10 +42,22 @@ #define SAMPLES_PER_SEC 16000 #endif +#define KInputBufferLength 128 +// Symbian libc file functionality in order to provide shared file handles +struct TSymbianFileEntry { + RFile iFileHandle; + char iInputBuffer[KInputBufferLength]; + TInt iInputBufferLen; + TInt iInputPos; +}; + +#define FILE void ////////// extern "C" /////////////////////////////////////////////////// namespace Symbian { + + // Show a simple Symbian Info win with Msg & exit void FatalError(const char *msg) { TPtrC8 msgPtr((const TUint8 *)msg); @@ -443,15 +455,9 @@ void OSystem_SDL_Symbian::initZones() { } } -// Symbian libc file functionality in order to provide shared file handles -struct TSymbianFileEntry { - RFile iFileHandle; -}; - -#define FILE void - FILE* symbian_fopen(const char* name, const char* mode) { TSymbianFileEntry* fileEntry = new TSymbianFileEntry; + fileEntry->iInputPos = KErrNotFound; if (fileEntry != NULL) { TInt modeLen = strlen(mode); @@ -509,9 +515,71 @@ void symbian_fclose(FILE* handle) { } size_t symbian_fread(const void* ptr, size_t size, size_t numItems, FILE* handle) { - TPtr8 pointer( (unsigned char*) ptr, size*numItems); + TSymbianFileEntry* entry = ((TSymbianFileEntry*)(handle)); + TUint32 totsize = size*numItems; + TPtr8 pointer ( (unsigned char*) ptr, totsize); + + // Nothing cached and we want to load at least KInputBufferLength bytes + if(totsize >= KInputBufferLength) { + TUint32 totLength = 0; + if(entry->iInputPos != KErrNotFound) + { + TPtr8 cacheBuffer( (unsigned char*) entry->iInputBuffer+entry->iInputPos, entry->iInputBufferLen - entry->iInputPos, KInputBufferLength); + pointer.Append(cacheBuffer); + entry->iInputPos = KErrNotFound; + totLength+=pointer.Length(); + pointer.Set(totLength+(unsigned char*) ptr, 0, totsize-totLength); + } + + entry->iFileHandle.Read(pointer); + totLength+=pointer.Length(); - ((TSymbianFileEntry*)(handle))->iFileHandle.Read(pointer); + pointer.Set((unsigned char*) ptr, totLength, totsize); + + } + else { + // Nothing in buffer + if(entry->iInputPos == KErrNotFound) { + TPtr8 cacheBuffer( (unsigned char*) entry->iInputBuffer, KInputBufferLength); + entry->iFileHandle.Read(cacheBuffer); + + if(cacheBuffer.Length() >= totsize) { + pointer.Copy(cacheBuffer.Left(totsize)); + entry->iInputPos = totsize; + entry->iInputBufferLen = cacheBuffer.Length(); + } + else { + pointer.Copy(cacheBuffer); + entry->iInputPos = KErrNotFound; + } + + } + else { + TPtr8 cacheBuffer( (unsigned char*) entry->iInputBuffer, KInputBufferLength, entry->iInputBufferLen); + + if(entry->iInputPos+totsize < entry->iInputBufferLen) { + pointer.Copy(cacheBuffer.Mid(entry->iInputPos, totsize)); + entry->iInputPos+=totsize; + } + else { + + pointer.Copy(cacheBuffer.Mid(entry->iInputPos, entry->iInputBufferLen-entry->iInputPos)); + cacheBuffer.SetLength(0); + entry->iFileHandle.Read(cacheBuffer); + + if(cacheBuffer.Length() >= totsize-pointer.Length()) { + TUint32 restSize = totsize-pointer.Length(); + pointer.Append(cacheBuffer.Left(restSize)); + entry->iInputPos = restSize; + entry->iInputBufferLen = cacheBuffer.Length(); + } + else { + pointer.Append(cacheBuffer); + entry->iInputPos = KErrNotFound; + } + } + } + } return pointer.Length()/size; } @@ -519,6 +587,7 @@ size_t symbian_fread(const void* ptr, size_t size, size_t numItems, FILE* handle size_t symbian_fwrite(const void* ptr, size_t size, size_t numItems, FILE* handle) { TPtrC8 pointer( (unsigned char*) ptr, size*numItems); + ((TSymbianFileEntry*)(handle))->iInputPos = KErrNotFound; if (((TSymbianFileEntry*)(handle))->iFileHandle.Write(pointer) == KErrNone) { return numItems; } @@ -528,6 +597,7 @@ size_t symbian_fwrite(const void* ptr, size_t size, size_t numItems, FILE* handl bool symbian_feof(FILE* handle) { TInt pos = 0; + if (((TSymbianFileEntry*)(handle))->iFileHandle.Seek(ESeekCurrent, pos) == KErrNone) { TInt size = 0; @@ -549,6 +619,7 @@ long int symbian_ftell(FILE* handle) { } int symbian_fseek(FILE* handle, long int offset, int whence) { + TSeek seekMode = ESeekStart; TInt pos = offset; @@ -564,6 +635,8 @@ int symbian_fseek(FILE* handle, long int offset, int whence) { break; } + + ((TSymbianFileEntry*)(handle))->iInputPos = KErrNotFound; return ((TSymbianFileEntry*)(handle))->iFileHandle.Seek(seekMode, pos); } -- cgit v1.2.3 From 4657a52b077740c0c1da6208019ba886d0da2242 Mon Sep 17 00:00:00 2001 From: Lars Persson Date: Fri, 18 Jul 2008 22:07:52 +0000 Subject: Fixed typo in filehandling svn-id: r33104 --- backends/platform/symbian/src/SymbianOS.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends/platform/symbian/src/SymbianOS.cpp') diff --git a/backends/platform/symbian/src/SymbianOS.cpp b/backends/platform/symbian/src/SymbianOS.cpp index 5544cf0887..d362d27d74 100644 --- a/backends/platform/symbian/src/SymbianOS.cpp +++ b/backends/platform/symbian/src/SymbianOS.cpp @@ -555,7 +555,7 @@ size_t symbian_fread(const void* ptr, size_t size, size_t numItems, FILE* handle } else { - TPtr8 cacheBuffer( (unsigned char*) entry->iInputBuffer, KInputBufferLength, entry->iInputBufferLen); + TPtr8 cacheBuffer( (unsigned char*) entry->iInputBuffer, entry->iInputBufferLen, KInputBufferLength); if(entry->iInputPos+totsize < entry->iInputBufferLen) { pointer.Copy(cacheBuffer.Mid(entry->iInputPos, totsize)); -- cgit v1.2.3 From 6cff2e82399bd9fb7ff87378f84d9f83aedfed5a Mon Sep 17 00:00:00 2001 From: Lars Persson Date: Sat, 19 Jul 2008 07:08:37 +0000 Subject: eof was not working properly with caching svn-id: r33108 --- backends/platform/symbian/src/SymbianOS.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'backends/platform/symbian/src/SymbianOS.cpp') diff --git a/backends/platform/symbian/src/SymbianOS.cpp b/backends/platform/symbian/src/SymbianOS.cpp index d362d27d74..660b0c69ed 100644 --- a/backends/platform/symbian/src/SymbianOS.cpp +++ b/backends/platform/symbian/src/SymbianOS.cpp @@ -597,13 +597,18 @@ size_t symbian_fwrite(const void* ptr, size_t size, size_t numItems, FILE* handl bool symbian_feof(FILE* handle) { TInt pos = 0; + TSymbianFileEntry* entry = ((TSymbianFileEntry*)(handle)); - if (((TSymbianFileEntry*)(handle))->iFileHandle.Seek(ESeekCurrent, pos) == KErrNone) { + if (entry->iFileHandle.Seek(ESeekCurrent, pos) == KErrNone) { TInt size = 0; - if (((TSymbianFileEntry*)(handle))->iFileHandle.Size(size) == KErrNone) { - if (pos == size) + if (entry->iFileHandle.Size(size) == KErrNone) { + if(entry->iInputPos == KErrNotFound && pos == size) + return true; + + if(entry->iInputPos != KErrNotFound && pos == size && entry->iInputPos == entry->iInputBufferLen) return true; + return false; } } -- cgit v1.2.3