OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 #include "embedders/openglui/common/sound_handler.h" |
| 6 |
| 7 #include <string.h> |
| 8 |
| 9 #include "embedders/openglui/common/log.h" |
| 10 |
| 11 SoundHandler* SoundHandler::instance_ = NULL; |
| 12 |
| 13 SoundHandler::SoundHandler() |
| 14 : samples_() { |
| 15 } |
| 16 |
| 17 Sample* SoundHandler::GetSample(const char* path) { |
| 18 for (samples_t::iterator sp = samples_.begin(); |
| 19 sp != samples_.end(); |
| 20 ++sp) { |
| 21 Sample* sample = (*sp); |
| 22 if (strcmp(sample->path(), path) == 0) { |
| 23 return sample; |
| 24 } |
| 25 } |
| 26 Sample* sample = new Sample(path); |
| 27 if (sample->Load() != 0) { |
| 28 LOGI("Failed to load sample %s", path); |
| 29 delete sample; |
| 30 return NULL; |
| 31 } |
| 32 samples_.push_back(sample); |
| 33 return sample; |
| 34 } |
| 35 |
| 36 |
| 37 int32_t PlayBackgroundSound(const char* path) { |
| 38 return SoundHandler::instance()->PlayBackground(path); |
| 39 } |
| 40 |
| 41 void StopBackgroundSound() { |
| 42 SoundHandler::instance()->StopBackground(); |
| 43 } |
| 44 |
| 45 int32_t LoadSoundSample(const char* path) { |
| 46 return SoundHandler::instance()->LoadSample(path); |
| 47 } |
| 48 |
| 49 int32_t PlaySoundSample(const char* path) { |
| 50 return SoundHandler::instance()->PlaySample(path); |
| 51 } |
| 52 |
OLD | NEW |