Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "embedders/android/context.h" | 5 #include "embedders/android/context.h" |
| 6 #include "embedders/android/dart_host.h" | 6 #include "embedders/android/dart_host.h" |
| 7 #include "embedders/android/eventloop.h" | 7 #include "embedders/android/eventloop.h" |
| 8 #include "embedders/android/graphics.h" | 8 #include "embedders/android/graphics.h" |
| 9 #include "embedders/android/input_service.h" | 9 #include "embedders/android/input_service.h" |
| 10 #include "embedders/android/vm_glue.h" | 10 #include "embedders/android/vm_glue.h" |
| 11 | 11 |
| 12 SoundService* psound_service; | 12 SoundService* psound_service; |
| 13 | 13 |
| 14 void android_main(android_app* application) { | 14 void android_main(android_app* application) { |
| 15 Timer timer; | 15 Timer timer; |
| 16 Graphics graphics(application, &timer); | 16 Graphics graphics(application, &timer); |
| 17 VMGlue vmGlue(&graphics); | 17 VMGlue vmGlue(&graphics); |
| 18 InputService inputService(application, &vmGlue, | 18 InputService inputService(application, &vmGlue, |
| 19 graphics.width(), graphics.height()); | 19 graphics.width(), graphics.height()); |
| 20 SoundService sound_service(application); | 20 SoundService sound_service(application); |
| 21 psound_service = &sound_service; | 21 Context appContext = { |
|
vsm
2013/01/09 21:17:21
I was getting a compiler warning with this style o
gram
2013/01/09 22:33:28
I just did field init instead.
| |
| 22 Context context; | 22 &graphics, |
| 23 context.graphics = &graphics; | 23 &inputService, |
| 24 context.input_handler = &inputService; | 24 &sound_service, |
| 25 context.sound_service = psound_service; | 25 &timer, |
| 26 context.timer = &timer; | 26 &vmGlue |
| 27 context.vm_glue = &vmGlue; | 27 }; |
| 28 EventLoop eventLoop(application); | 28 EventLoop eventLoop(application); |
| 29 DartHost host(&context); | 29 DartHost host(&appContext); |
| 30 eventLoop.Run(&host, &context); | 30 eventLoop.Run(&host, &appContext); |
| 31 } | 31 } |
| 32 | 32 |
| 33 void PlayBackground(const char* path) { | 33 int32_t PlayBackgroundSound(const char* path) { |
| 34 psound_service->PlayBackground(path); | 34 return psound_service->PlayBackground(path); |
| 35 } | 35 } |
| 36 | 36 |
| 37 void StopBackground() { | 37 void StopBackgroundSound() { |
| 38 psound_service->StopBackground(); | 38 psound_service->StopBackground(); |
| 39 } | 39 } |
| 40 | |
| 41 int32_t LoadSoundSample(const char* path) { | |
| 42 return psound_service->LoadSample(path); | |
| 43 } | |
| 44 | |
| 45 int32_t PlaySoundSample(const char* path) { | |
| 46 return psound_service->PlaySample(path); | |
| 47 } | |
| OLD | NEW |