Created
December 12, 2015 08:34
-
-
Save yorung/301c578cef5274a196b8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void Voice::Play(bool loop) | |
| { | |
| if (!IsReady()) { | |
| return; | |
| } | |
| auto playback = [](SLAndroidSimpleBufferQueueItf q, void* context_) { | |
| WaveContext* context = (WaveContext*)context_; | |
| int totalSize; | |
| const void* buf = RiffFindChunk(context->fileImg, "data", &totalSize); | |
| SLCall(q, Enqueue, (char*)buf, totalSize); | |
| }; | |
| auto doNothing = [](SLAndroidSimpleBufferQueueItf, void*) {}; | |
| SLCall(context->playerPlay, SetPlayState, SL_PLAYSTATE_STOPPED); | |
| SLCall(context->playerBufferQueue, RegisterCallback, loop ? playback : doNothing, context); | |
| SLCall(context->playerPlay, SetPlayState, SL_PLAYSTATE_PLAYING); | |
| playback(context->playerBufferQueue, context); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment