| 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 #ifndef EMBEDDERS_ANDROID_SOUND_SERVICE_H_ | 5 #ifndef EMBEDDERS_ANDROID_SOUND_SERVICE_H_ |
| 6 #define EMBEDDERS_ANDROID_SOUND_SERVICE_H_ | 6 #define EMBEDDERS_ANDROID_SOUND_SERVICE_H_ |
| 7 | 7 |
| 8 #include <android_native_app_glue.h> | 8 #include <android_native_app_glue.h> |
| 9 #include <SLES/OpenSLES.h> | 9 #include <SLES/OpenSLES.h> |
| 10 #include <SLES/OpenSLES_Android.h> | 10 #include <SLES/OpenSLES_Android.h> |
| 11 #include <SLES/OpenSLES_AndroidConfiguration.h> | 11 #include <SLES/OpenSLES_AndroidConfiguration.h> |
| 12 #include <vector> |
| 13 #include "embedders/android/sample.h" |
| 12 #include "embedders/android/types.h" | 14 #include "embedders/android/types.h" |
| 13 | 15 |
| 14 class SoundService { | 16 class SoundService { |
| 15 public: | 17 public: |
| 16 explicit SoundService(android_app* application); | 18 explicit SoundService(android_app* application); |
| 17 int32_t Start(); | 19 int32_t Start(); |
| 18 void Stop(); | 20 void Stop(); |
| 19 | 21 |
| 20 int32_t PlayBackground(const char* path); | 22 int32_t PlayBackground(const char* path); |
| 21 void StopBackground(); | 23 void StopBackground(); |
| 22 | 24 |
| 25 // Optional, for preloading. |
| 26 int32_t LoadSample(const char* path) { |
| 27 return (GetSample(path) == NULL) ? -1 : 0; |
| 28 } |
| 29 |
| 30 int32_t PlaySample(const char* path); |
| 31 |
| 23 private: | 32 private: |
| 33 typedef std::vector<Sample*> samples_t; |
| 34 |
| 35 int32_t CreateAudioPlayer(SLEngineItf engine_if, |
| 36 const SLInterfaceID extra_if, |
| 37 SLDataSource data_source, |
| 38 SLDataSink data_sink, |
| 39 SLObjectItf& player_out, |
| 40 SLPlayItf& player_if_out); |
| 41 |
| 42 int32_t StartSamplePlayer(); |
| 43 Sample* GetSample(const char* path); |
| 44 |
| 24 android_app* application_; | 45 android_app* application_; |
| 25 SLObjectItf engine_; | 46 SLObjectItf engine_; |
| 26 SLEngineItf engine_if_; | 47 SLEngineItf engine_if_; |
| 27 SLObjectItf output_mix_; | 48 SLObjectItf output_mix_; |
| 28 SLObjectItf background_player_; | 49 SLObjectItf background_player_; |
| 29 SLPlayItf background_player_if_; | 50 SLPlayItf background_player_if_; |
| 30 SLSeekItf background_player_seek_if_; | 51 SLSeekItf background_player_seek_if_; |
| 52 SLObjectItf sample_player_; |
| 53 SLPlayItf sample_player_if_; |
| 54 SLBufferQueueItf sample_player_queue_; |
| 55 samples_t samples_; |
| 31 }; | 56 }; |
| 32 | 57 |
| 33 void PlayBackground(const char* path); | 58 int32_t PlayBackgroundSound(const char* path); |
| 34 void StopBackground(); | 59 void StopBackgroundSound(); |
| 35 #endif // EMBEDDERS_ANDROID_SOUND_SERVICE_H_ | 60 #endif // EMBEDDERS_ANDROID_SOUND_SERVICE_H_ |
| OLD | NEW |