Commit 18a8429f authored by Sébastien Blin's avatar Sébastien Blin

audioinput: do not use getAvailableData()

In a conference, we don't want to wait on all tracks
because if a participant is in hold, the sound will
be cut for all participants.

This patch force the mix to occurs for every frame
even if there is no data.

Change-Id: I6ed4c50f771356f4a4cb642f4213a4865567eb8f
Gitlab: #273
parent 5af73248
......@@ -31,7 +31,6 @@
#include "smartools.h"
#include <future>
#include <chrono>
#include <memory>
namespace jami {
......@@ -51,6 +50,7 @@ AudioInput::AudioInput(const std::string& id) :
[] {})
{
JAMI_DBG() << "Creating audio input with id: " << id;
wakeUp_ = std::chrono::high_resolution_clock::now() + MS_PER_PACKET;
loop_.start();
}
......@@ -120,8 +120,13 @@ AudioInput::readFromDevice()
return;
}
if (not mainBuffer.waitForDataAvailable(id_, MS_PER_PACKET))
return;
// Note: read for device is called in an audio thread and we don't
// want to have a loop which takes 100% of the CPU.
// Here, we basically want to mix available data without any glitch
// and even if one buffer doesn't have audio data (call in hold,
// connections issues, etc). So mix every MS_PER_PACKET
std::this_thread::sleep_until(wakeUp_);
wakeUp_ += MS_PER_PACKET;
auto samples = mainBuffer.getData(id_);
if (not samples)
......
......@@ -24,6 +24,7 @@
#include <atomic>
#include <future>
#include <mutex>
#include <chrono>
#include "audio/audiobuffer.h"
#include "media_device.h"
......@@ -99,6 +100,8 @@ private:
ThreadLoop loop_;
void process();
std::chrono::time_point<std::chrono::high_resolution_clock> wakeUp_;
};
} // namespace jami
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment