Skip to content

Commit

Permalink
TIZEN: updates for tizen 2.2 SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisws committed Aug 16, 2013
1 parent e2856ed commit 1f4feaf
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 32 deletions.
22 changes: 13 additions & 9 deletions backends/platform/tizen/application.cpp
Expand Up @@ -31,7 +31,7 @@ Application *TizenScummVM::createInstance() {
return new TizenScummVM();
}

TizenScummVM::TizenScummVM() : _appForm(0) {
TizenScummVM::TizenScummVM() : _appForm(NULL) {
logEntered();
}

Expand All @@ -41,7 +41,7 @@ TizenScummVM::~TizenScummVM() {
TizenSystem *system = (TizenSystem *)g_system;
system->destroyBackend();
delete system;
g_system = 0;
g_system = NULL;
}
}

Expand All @@ -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);
}
Expand All @@ -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;
}
}

Expand Down Expand Up @@ -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);
}
Expand Down
36 changes: 26 additions & 10 deletions backends/platform/tizen/audio.cpp
Expand Up @@ -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),
Expand All @@ -38,6 +39,7 @@ AudioThread::AudioThread() :
_ready(0),
_interval(TIMER_INTERVAL),
_playing(-1),
_size(0),
_muted(true) {
}

Expand Down Expand Up @@ -70,7 +72,7 @@ void AudioThread::setMute(bool on) {
if (on) {
_timer->Cancel();
} else {
_timer->StartAsRepeatable(_interval);
_timer->Start(_interval);
}
}
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -137,6 +140,7 @@ void AudioThread::OnStop(void) {

if (_audioOut) {
_audioOut->Reset();
_audioOut->Unprepare();
delete _audioOut;
}
}
Expand All @@ -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);
}

4 changes: 2 additions & 2 deletions backends/platform/tizen/audio.h
Expand Up @@ -54,6 +54,7 @@ class AudioThread:
bool isSilentMode();
void setMute(bool on);

private:
bool OnStart(void);
void OnStop(void);
void OnAudioOutErrorOccurred(Tizen::Media::AudioOut &src, result r);
Expand All @@ -62,12 +63,11 @@ class AudioThread:
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;
};

Expand Down
25 changes: 19 additions & 6 deletions backends/platform/tizen/form.cpp
Expand Up @@ -52,7 +52,7 @@ TizenAppForm::TizenAppForm() :
_eventQueueLock(NULL),
_state(kInitState),
_buttonState(kLeftButton),
_shortcut(kShowKeypad) {
_shortcut(kEscapeKey) {
}

result TizenAppForm::Construct() {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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();
}
}
9 changes: 8 additions & 1 deletion backends/platform/tizen/form.h
Expand Up @@ -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"
Expand All @@ -40,6 +42,7 @@
using namespace Tizen::Ui;
using namespace Tizen::Graphics;
using namespace Tizen::Base::Runtime;
using namespace Tizen::Ui::Controls;

//
// TizenAppForm
Expand All @@ -48,7 +51,9 @@ class TizenAppForm :
public Controls::Form,
public IRunnable,
public IOrientationEventListener,
public ITouchEventListener {
public ITouchEventListener,
public IFormBackEventListener,
public IFormMenuEventListener {

public:
TizenAppForm();
Expand Down Expand Up @@ -89,6 +94,8 @@ class TizenAppForm :
void OnTouchReleased(const Control &source,
const Point &currentPosition,
const TouchEventInfo &touchInfo);
void OnFormBackRequested(Form &source);
void OnFormMenuRequested(Form &source);

void pushEvent(Common::EventType type, const Point &currentPosition);
void terminate();
Expand Down
1 change: 0 additions & 1 deletion backends/platform/tizen/fs.cpp
Expand Up @@ -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));
Expand Down
7 changes: 6 additions & 1 deletion backends/platform/tizen/graphics.cpp
Expand Up @@ -100,6 +100,8 @@ void TizenGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) {
}

void TizenGraphicsManager::setReady() {
logEntered();
_appForm->GetVisualElement()->SetShowState(true);
_initState = false;
}

Expand Down Expand Up @@ -176,7 +178,9 @@ bool TizenGraphicsManager::loadEgl() {
systemError("eglMakeCurrent() failed");
return false;
}

if (!_initState) {
_appForm->GetVisualElement()->SetShowState(true);
}
logLeaving();
return true;
}
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions backends/platform/tizen/system.cpp
Expand Up @@ -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;
}
Expand All @@ -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();
Expand Down

0 comments on commit 1f4feaf

Please sign in to comment.