mirror of
https://github.com/godotengine/godot
synced 2024-09-06 04:24:04 +00:00
Merge pull request #54404 from ibrahn/pulsedriver-less-cowref
This commit is contained in:
commit
26c03bcccd
|
@ -382,15 +382,15 @@ void AudioDriverPulseAudio::thread_func(void *p_udata) {
|
||||||
ad->start_counting_ticks();
|
ad->start_counting_ticks();
|
||||||
|
|
||||||
if (!ad->active) {
|
if (!ad->active) {
|
||||||
for (unsigned int i = 0; i < ad->pa_buffer_size; i++) {
|
ad->samples_out.fill(0);
|
||||||
ad->samples_out.write[i] = 0;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
ad->audio_server_process(ad->buffer_frames, ad->samples_in.ptrw());
|
ad->audio_server_process(ad->buffer_frames, ad->samples_in.ptrw());
|
||||||
|
|
||||||
|
int16_t *out_ptr = ad->samples_out.ptrw();
|
||||||
|
|
||||||
if (ad->channels == ad->pa_map.channels) {
|
if (ad->channels == ad->pa_map.channels) {
|
||||||
for (unsigned int i = 0; i < ad->pa_buffer_size; i++) {
|
for (unsigned int i = 0; i < ad->pa_buffer_size; i++) {
|
||||||
ad->samples_out.write[i] = ad->samples_in[i] >> 16;
|
out_ptr[i] = ad->samples_in[i] >> 16;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Uneven amount of channels
|
// Uneven amount of channels
|
||||||
|
@ -399,11 +399,11 @@ void AudioDriverPulseAudio::thread_func(void *p_udata) {
|
||||||
|
|
||||||
for (unsigned int i = 0; i < ad->buffer_frames; i++) {
|
for (unsigned int i = 0; i < ad->buffer_frames; i++) {
|
||||||
for (int j = 0; j < ad->pa_map.channels - 1; j++) {
|
for (int j = 0; j < ad->pa_map.channels - 1; j++) {
|
||||||
ad->samples_out.write[out_idx++] = ad->samples_in[in_idx++] >> 16;
|
out_ptr[out_idx++] = ad->samples_in[in_idx++] >> 16;
|
||||||
}
|
}
|
||||||
uint32_t l = ad->samples_in[in_idx++] >> 16;
|
uint32_t l = ad->samples_in[in_idx++] >> 16;
|
||||||
uint32_t r = ad->samples_in[in_idx++] >> 16;
|
uint32_t r = ad->samples_in[in_idx++] >> 16;
|
||||||
ad->samples_out.write[out_idx++] = (l + r) / 2;
|
out_ptr[out_idx++] = (l + r) / 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue