cocos2d / cocos2d-x

Cocos2d-x is a suite of open-source, cross-platform, game-development tools utilized by millions of developers across the globe. Its core has evolved to serve as the foundation for Cocos Creator 1.x & 2.x.
https://www.cocos.com/en/cocos2d-x
18.11k stars 7.05k forks source link

Encapsule Audio Engine implementation for the platforms using OpenAL #16307

Open dumganhar opened 8 years ago

dumganhar commented 8 years ago

Currently, new AudioEngine uses the following technique:

Except Android and Tizen, other platforms could all use OpenAL. But now, we have separated folder for platforms using OpenAL, the bad thing is although they all use OpenAL , the source code are so different. :(

Perhaps, we need to encapsule this and only need cocos/audio/openal for these platforms that use OpenAL. In this way, it will be better for maintaining and better for adding new features.

Some folder structure may be like this:

cocos/audio/openal/AudioEngine-impl.cpp
cocos/audio/openal/AudioEngine-impl.h
cocos/audio/openal/PlatformSpecific.h
cocos/audio/openal/PlatformSpecific-win32.cpp
cocos/audio/openal/PlatformSpecific-osx.cpp
cocos/audio/openal/PlatformSpecific-ios.cpp
cocos/audio/openal/PlatformSpecific-linux.cpp
cocos/audio/openal/PlatformSpecific-winrt.cpp

Why Should We Need Specific?

Although they all use OpenAL to play sound, they should use platform dependence code to decode compressed file (.mp3/.ogg/.caf) into pcm buffer.

Any idea? @ricardoquesada @minggo .

minggo commented 8 years ago

@dumganhar i think you can refer to EditBox, please use the same rule as others.

dumganhar commented 8 years ago

Good point. :)

halx99 commented 5 years ago

I think the original design: AudioDecoderManager + AudioDecoder is good for multi-platforms diff implement to decode mp3,ogg,etc..

halx99 commented 5 years ago

@dumganhar By the way, the previously implement of Audio Engine doesn't support .ogg at Apple platforms, If you Refactor the audio engine, you can think to simply import vorbis libs to Apple xcode project.