diff options
author | Chris Warren-Smith | 2013-08-17 08:52:14 +1000 |
---|---|---|
committer | Chris Warren-Smith | 2013-08-17 08:52:14 +1000 |
commit | 1f4feaffb0c6dc49e8a5f4d2ca1ef10650185ca2 (patch) | |
tree | ee2756f1ea091f17b0e72d907d8af22f89213847 /backends/platform/tizen | |
parent | e2856ed85b08b4ab96e5a05cef793052e3232838 (diff) | |
download | scummvm-rg350-1f4feaffb0c6dc49e8a5f4d2ca1ef10650185ca2.tar.gz scummvm-rg350-1f4feaffb0c6dc49e8a5f4d2ca1ef10650185ca2.tar.bz2 scummvm-rg350-1f4feaffb0c6dc49e8a5f4d2ca1ef10650185ca2.zip |
TIZEN: updates for tizen 2.2 SDK
Diffstat (limited to 'backends/platform/tizen')
-rw-r--r-- | backends/platform/tizen/application.cpp | 22 | ||||
-rw-r--r-- | backends/platform/tizen/audio.cpp | 36 | ||||
-rw-r--r-- | backends/platform/tizen/audio.h | 4 | ||||
-rw-r--r-- | backends/platform/tizen/form.cpp | 25 | ||||
-rw-r--r-- | backends/platform/tizen/form.h | 9 | ||||
-rw-r--r-- | backends/platform/tizen/fs.cpp | 1 | ||||
-rw-r--r-- | backends/platform/tizen/graphics.cpp | 7 | ||||
-rw-r--r-- | backends/platform/tizen/system.cpp | 6 |
8 files changed, 78 insertions, 32 deletions
diff --git a/backends/platform/tizen/application.cpp b/backends/platform/tizen/application.cpp index 8236ebef67..a73efacf58 100644 --- a/backends/platform/tizen/application.cpp +++ b/backends/platform/tizen/application.cpp @@ -31,7 +31,7 @@ Application *TizenScummVM::createInstance() { return new TizenScummVM(); } -TizenScummVM::TizenScummVM() : _appForm(0) { +TizenScummVM::TizenScummVM() : _appForm(NULL) { logEntered(); } @@ -41,7 +41,7 @@ TizenScummVM::~TizenScummVM() { TizenSystem *system = (TizenSystem *)g_system; system->destroyBackend(); delete system; - g_system = 0; + g_system = NULL; } } @@ -68,17 +68,19 @@ bool TizenScummVM::OnAppTerminating(AppRegistry &appRegistry, bool forcedTermina } void TizenScummVM::OnUserEventReceivedN(RequestId requestId, IList *args) { + logEntered(); MessageBox messageBox; int modalResult; + String *message; - logEntered(); - - if (requestId == USER_MESSAGE_EXIT) { + switch (requestId) { + case USER_MESSAGE_EXIT: // normal program termination Terminate(); - } else if (requestId == USER_MESSAGE_EXIT_ERR) { + break; + + case USER_MESSAGE_EXIT_ERR: // assertion failure termination - String *message = NULL; if (args) { message = (String *)args->GetAt(0); } @@ -88,12 +90,15 @@ void TizenScummVM::OnUserEventReceivedN(RequestId requestId, IList *args) { messageBox.Construct(L"Oops...", *message, MSGBOX_STYLE_OK); messageBox.ShowAndWait(modalResult); Terminate(); - } else if (requestId == USER_MESSAGE_EXIT_ERR_CONFIG) { + break; + + case USER_MESSAGE_EXIT_ERR_CONFIG: // the config file was corrupted messageBox.Construct(L"Config file corrupted", L"Settings have been reverted, please restart.", MSGBOX_STYLE_OK); messageBox.ShowAndWait(modalResult); Terminate(); + break; } } @@ -132,7 +137,6 @@ void TizenScummVM::pauseGame(bool pause) { if (pause && g_engine && !g_engine->isPaused()) { _appForm->pushKey(Common::KEYCODE_SPACE); } - if (g_system) { ((TizenSystem *)g_system)->setMute(pause); } diff --git a/backends/platform/tizen/audio.cpp b/backends/platform/tizen/audio.cpp index 313a10eaa8..f9ac80a583 100644 --- a/backends/platform/tizen/audio.cpp +++ b/backends/platform/tizen/audio.cpp @@ -26,8 +26,9 @@ #include "backends/platform/tizen/audio.h" #include "backends/platform/tizen/system.h" -#define TIMER_INTERVAL 10 -#define VOLUME 99 +#define TIMER_INTERVAL 10 +#define VOLUME 96 +#define MIN_TIMER_INTERVAL 5 AudioThread::AudioThread() : _mixer(0), @@ -38,6 +39,7 @@ AudioThread::AudioThread() : _ready(0), _interval(TIMER_INTERVAL), _playing(-1), + _size(0), _muted(true) { } @@ -70,7 +72,7 @@ void AudioThread::setMute(bool on) { if (on) { _timer->Cancel(); } else { - _timer->StartAsRepeatable(_interval); + _timer->Start(_interval); } } } @@ -105,13 +107,14 @@ bool AudioThread::OnStart(void) { } } + _size = _audioBuffer[0].GetCapacity(); _timer = new Timer(); if (!_timer || IsFailed(_timer->Construct(*this))) { AppLog("Failed to create audio timer"); return false; } - if (IsFailed(_timer->StartAsRepeatable(_interval))) { + if (IsFailed(_timer->Start(_interval))) { AppLog("failed to start audio timer"); return false; } @@ -137,6 +140,7 @@ void AudioThread::OnStop(void) { if (_audioOut) { _audioOut->Reset(); + _audioOut->Unprepare(); delete _audioOut; } } @@ -161,21 +165,33 @@ void AudioThread::OnAudioOutBufferEndReached(Tizen::Media::AudioOut &src) { _tail = (_tail + 1) % NUM_AUDIO_BUFFERS; _ready--; } else { - // audio buffer empty: decrease timer inverval + // audio buffer empty: decrease timer interval _playing = -1; + _interval -= 1; + if (_interval < MIN_TIMER_INTERVAL) { + _interval = MIN_TIMER_INTERVAL; + } } + } void AudioThread::OnTimerExpired(Timer &timer) { if (_ready < NUM_AUDIO_BUFFERS) { - uint len = _audioBuffer[_head].GetCapacity(); - int samples = _mixer->mixCallback((byte *)_audioBuffer[_head].GetPointer(), len); - if (samples) { - _head = (_head + 1) % NUM_AUDIO_BUFFERS; - _ready++; + if (_playing != _head) { + if (_mixer->mixCallback((byte *)_audioBuffer[_head].GetPointer(), _size)) { + _head = (_head + 1) % NUM_AUDIO_BUFFERS; + _ready++; + } } + } else { + // audio buffer full: restore timer interval + _interval = TIMER_INTERVAL; } + if (_ready && _playing == -1) { OnAudioOutBufferEndReached(*_audioOut); } + + _timer->Start(_interval); } + diff --git a/backends/platform/tizen/audio.h b/backends/platform/tizen/audio.h index 8d7835042d..a304231578 100644 --- a/backends/platform/tizen/audio.h +++ b/backends/platform/tizen/audio.h @@ -54,6 +54,7 @@ public: bool isSilentMode(); void setMute(bool on); +private: bool OnStart(void); void OnStop(void); void OnAudioOutErrorOccurred(Tizen::Media::AudioOut &src, result r); @@ -62,12 +63,11 @@ public: void OnAudioOutBufferEndReached(Tizen::Media::AudioOut &src); void OnTimerExpired(Timer &timer); -private: Audio::MixerImpl *_mixer; Tizen::Base::Runtime::Timer *_timer; Tizen::Media::AudioOut *_audioOut; Tizen::Base::ByteBuffer _audioBuffer[NUM_AUDIO_BUFFERS]; - int _head, _tail, _ready, _interval, _playing; + int _head, _tail, _ready, _interval, _playing, _size; bool _muted; }; diff --git a/backends/platform/tizen/form.cpp b/backends/platform/tizen/form.cpp index 5050699ca9..10d51cc610 100644 --- a/backends/platform/tizen/form.cpp +++ b/backends/platform/tizen/form.cpp @@ -52,7 +52,7 @@ TizenAppForm::TizenAppForm() : _eventQueueLock(NULL), _state(kInitState), _buttonState(kLeftButton), - _shortcut(kShowKeypad) { + _shortcut(kEscapeKey) { } result TizenAppForm::Construct() { @@ -157,6 +157,8 @@ result TizenAppForm::OnInitializing(void) { AddOrientationEventListener(*this); AddTouchEventListener(*this); SetMultipointTouchEnabled(true); + SetFormBackEventListener(this); + SetFormMenuEventListener(this); // set focus to enable receiving key events SetEnabled(true); @@ -316,16 +318,16 @@ void TizenAppForm::invokeShortcut() { case kControlMouse: setButtonShortcut(); break; - + case kEscapeKey: pushKey(Common::KEYCODE_ESCAPE); break; - + case kGameMenu: _buttonState = kLeftButton; pushKey(Common::KEYCODE_F5); break; - + case kShowKeypad: showKeypad(); break; @@ -354,8 +356,6 @@ void TizenAppForm::OnTouchDoublePressed(const Control &source, if (_buttonState != kMoveOnly) { pushEvent(_buttonState == kLeftButton ? Common::EVENT_LBUTTONDOWN : Common::EVENT_RBUTTONDOWN, currentPosition); - pushEvent(_buttonState == kLeftButton ? Common::EVENT_LBUTTONDOWN : Common::EVENT_RBUTTONDOWN, - currentPosition); } } @@ -417,3 +417,16 @@ void TizenAppForm::OnTouchReleased(const Control &source, } } +void TizenAppForm::OnFormBackRequested(Form &source) { + logEntered(); + if (_state == kActiveState) { + invokeShortcut(); + } +} + +void TizenAppForm::OnFormMenuRequested(Form &source) { + logEntered(); + if (_state == kActiveState) { + setShortcut(); + } +} diff --git a/backends/platform/tizen/form.h b/backends/platform/tizen/form.h index 64c447d409..e419c14d24 100644 --- a/backends/platform/tizen/form.h +++ b/backends/platform/tizen/form.h @@ -29,6 +29,8 @@ #include <FBase.h> #include <FUiITouchEventListener.h> #include <FUiITextEventListener.h> +#include <FUiCtrlIFormBackEventListener.h> +#include <FUiCtrlIFormMenuEventListener.h> #include "config.h" #include "common/scummsys.h" @@ -40,6 +42,7 @@ using namespace Tizen::Ui; using namespace Tizen::Graphics; using namespace Tizen::Base::Runtime; +using namespace Tizen::Ui::Controls; // // TizenAppForm @@ -48,7 +51,9 @@ class TizenAppForm : public Controls::Form, public IRunnable, public IOrientationEventListener, - public ITouchEventListener { + public ITouchEventListener, + public IFormBackEventListener, + public IFormMenuEventListener { public: TizenAppForm(); @@ -89,6 +94,8 @@ private: void OnTouchReleased(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo); + void OnFormBackRequested(Form &source); + void OnFormMenuRequested(Form &source); void pushEvent(Common::EventType type, const Point ¤tPosition); void terminate(); diff --git a/backends/platform/tizen/fs.cpp b/backends/platform/tizen/fs.cpp index f8b32f4239..8145cd5638 100644 --- a/backends/platform/tizen/fs.cpp +++ b/backends/platform/tizen/fs.cpp @@ -339,7 +339,6 @@ bool TizenFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, boo if (_isVirtualDir && mode != Common::FSNode::kListFilesOnly && _path == "/") { // present well known TIZEN file system areas myList.push_back(new TizenFilesystemNode(kData)); - myList.push_back(new TizenFilesystemNode(kResource)); myList.push_back(new TizenFilesystemNode(kSdCard)); myList.push_back(new TizenFilesystemNode(kMedia)); myList.push_back(new TizenFilesystemNode(kShared)); diff --git a/backends/platform/tizen/graphics.cpp b/backends/platform/tizen/graphics.cpp index bf255cd264..2cafb9f781 100644 --- a/backends/platform/tizen/graphics.cpp +++ b/backends/platform/tizen/graphics.cpp @@ -100,6 +100,8 @@ void TizenGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) { } void TizenGraphicsManager::setReady() { + logEntered(); + _appForm->GetVisualElement()->SetShowState(true); _initState = false; } @@ -176,7 +178,9 @@ bool TizenGraphicsManager::loadEgl() { systemError("eglMakeCurrent() failed"); return false; } - + if (!_initState) { + _appForm->GetVisualElement()->SetShowState(true); + } logLeaving(); return true; } @@ -213,6 +217,7 @@ void TizenGraphicsManager::internUpdateScreen() { void TizenGraphicsManager::unloadGFXMode() { logEntered(); + _appForm->GetVisualElement()->SetShowState(false); if (_eglDisplay != EGL_NO_DISPLAY) { eglMakeCurrent(_eglDisplay, NULL, NULL, NULL); diff --git a/backends/platform/tizen/system.cpp b/backends/platform/tizen/system.cpp index 54d92146e5..3448dc1421 100644 --- a/backends/platform/tizen/system.cpp +++ b/backends/platform/tizen/system.cpp @@ -513,13 +513,15 @@ TizenAppForm *systemStart(Tizen::App::Application *app) { } if (E_SUCCESS != appForm->Construct() || - E_SUCCESS != appFrame->AddControl(*appForm)) { + E_SUCCESS != appFrame->AddControl(appForm)) { delete appForm; AppLog("Failed to construct appForm"); return NULL; } appFrame->SetCurrentForm(appForm); + appForm->GetVisualElement()->SetShowState(false); + logLeaving(); return appForm; } @@ -531,7 +533,7 @@ void systemError(const char *message) { AppLog("Fatal system error: %s", message); if (strspn(message, "Config file buggy:") > 0) { - Tizen::Io::File::Remove(DEFAULT_CONFIG_FILE); + Tizen::Io::File::Remove(App::GetInstance()->GetAppDataPath() + DEFAULT_CONFIG_FILE); Application::GetInstance()->SendUserEvent(USER_MESSAGE_EXIT_ERR_CONFIG, NULL); } else { ArrayList *args = new ArrayList(); |