MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / _buffer_callback

Method _buffer_callback

platform/android/audio_driver_opensl.cpp:40–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38/* Structure for passing information to callback function */
39
40void AudioDriverOpenSL::_buffer_callback(
41 SLAndroidSimpleBufferQueueItf queueItf) {
42 bool mix = true;
43
44 if (pause) {
45 mix = false;
46 } else {
47 mix = mutex.try_lock();
48 }
49
50 if (mix) {
51 audio_server_process(buffer_size, mixdown_buffer);
52 } else {
53 int32_t *src_buff = mixdown_buffer;
54 for (unsigned int i = 0; i < buffer_size * 2; i++) {
55 src_buff[i] = 0;
56 }
57 }
58
59 if (mix) {
60 mutex.unlock();
61 }
62
63 const int32_t *src_buff = mixdown_buffer;
64
65 int16_t *ptr = (int16_t *)buffers[last_free];
66 last_free = (last_free + 1) % BUFFER_COUNT;
67
68 for (unsigned int i = 0; i < buffer_size * 2; i++) {
69 ptr[i] = src_buff[i] >> 16;
70 }
71
72 (*queueItf)->Enqueue(queueItf, ptr, 4 * buffer_size);
73}
74
75void AudioDriverOpenSL::_buffer_callbacks(
76 SLAndroidSimpleBufferQueueItf queueItf,

Callers 1

_buffer_callbacksMethod · 0.80

Calls 2

try_lockMethod · 0.45
unlockMethod · 0.45

Tested by

no test coverage detected