mirror of
https://github.com/rwengine/openrw.git
synced 2024-09-03 09:09:47 +02:00
Optimize usage of mutexes in streaming audio
This commit is contained in:
parent
a5ac546601
commit
1d6290f605
@ -1,4 +1,4 @@
|
||||
#include "audio/SoundSource.hpp"
|
||||
#include "audio/SoundSource.hpp"
|
||||
|
||||
#include <loaders/LoaderSDT.hpp>
|
||||
#include <rw/types.hpp>
|
||||
@ -285,10 +285,10 @@ void SoundSource::decodeFramesLegacy(size_t framesToDecode) {
|
||||
&decodingPacket);
|
||||
|
||||
if (len >= 0 && gotFrame) {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
// Write samples to audio buffer
|
||||
for (size_t i = 0;
|
||||
i < static_cast<size_t>(frame->nb_samples); i++) {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
// Interleave left/right channels
|
||||
for (size_t channel = 0; channel < channels;
|
||||
channel++) {
|
||||
@ -334,11 +334,10 @@ void SoundSource::decodeFrames(size_t framesToDecode) {
|
||||
// Decode audio packet
|
||||
|
||||
if (receiveFrame == 0 && sendPacket == 0) {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
// Write samples to audio buffer
|
||||
|
||||
for (size_t i = 0;
|
||||
i < static_cast<size_t>(frame->nb_samples); i++) {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
// Interleave left/right channels
|
||||
for (size_t channel = 0; channel < channels;
|
||||
channel++) {
|
||||
|
Loading…
Reference in New Issue
Block a user