Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(319)

Side by Side Diff: runtime/embedders/openglui/common/sound_handler.cc

Issue 13042015: Various OpenGLUI changes: (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/openglui/common/sound_handler.h" 5 #include "embedders/openglui/common/sound_handler.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "embedders/openglui/common/log.h" 9 #include "embedders/openglui/common/log.h"
10 10
11 SoundHandler* SoundHandler::instance_ = NULL; 11 SoundHandler* SoundHandler::instance_ = NULL;
12 12
13 SoundHandler::SoundHandler() 13 SoundHandler::SoundHandler()
14 : samples_() { 14 : samples_() {
15 instance_ = this;
15 } 16 }
16 17
17 Sample* SoundHandler::GetSample(const char* path) { 18 Sample* SoundHandler::GetSample(const char* path) {
18 for (samples_t::iterator sp = samples_.begin(); 19 for (samples_t::iterator sp = samples_.begin();
19 sp != samples_.end(); 20 sp != samples_.end();
20 ++sp) { 21 ++sp) {
21 Sample* sample = (*sp); 22 Sample* sample = (*sp);
22 if (strcmp(sample->path(), path) == 0) { 23 if (strcmp(sample->path(), path) == 0) {
24 LOGI("Returning cached sample %s", path);
23 return sample; 25 return sample;
24 } 26 }
25 } 27 }
26 Sample* sample = new Sample(path); 28 Sample* sample = new Sample(path);
27 if (sample->Load() != 0) { 29 if (sample->Load() != 0) {
28 LOGI("Failed to load sample %s", path); 30 LOGI("Failed to load sample %s", path);
29 delete sample; 31 delete sample;
30 return NULL; 32 return NULL;
31 } 33 }
32 samples_.push_back(sample); 34 samples_.push_back(sample);
35 LOGI("Adding sample %s to cache", path);
33 return sample; 36 return sample;
34 } 37 }
35 38
36 int32_t PlayBackgroundSound(const char* path) { 39 int32_t PlayBackgroundSound(const char* path) {
37 return SoundHandler::instance()->PlayBackground(path); 40 return SoundHandler::instance()->PlayBackground(path);
38 } 41 }
39 42
40 void StopBackgroundSound() { 43 void StopBackgroundSound() {
41 SoundHandler::instance()->StopBackground(); 44 SoundHandler::instance()->StopBackground();
42 } 45 }
43 46
44 int32_t LoadSoundSample(const char* path) { 47 int32_t LoadSoundSample(const char* path) {
45 return SoundHandler::instance()->LoadSample(path); 48 return SoundHandler::instance()->LoadSample(path);
46 } 49 }
47 50
48 int32_t PlaySoundSample(const char* path) { 51 int32_t PlaySoundSample(const char* path) {
49 return SoundHandler::instance()->PlaySample(path); 52 return SoundHandler::instance()->PlaySample(path);
50 } 53 }
51 54
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698