mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-21 13:06:15 +02:00
more tolerant resyncing
This commit is contained in:
parent
b5fc614f84
commit
adf346b772
3 changed files with 7 additions and 8 deletions
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
// source: https://github.com/hrydgard/native/blob/master/android/native-audio-so.cpp
|
||||||
|
|
||||||
// This is kinda ugly, but for simplicity I've left these as globals just like in the sample,
|
// This is kinda ugly, but for simplicity I've left these as globals just like in the sample,
|
||||||
// as there's not really any use case for this where we have multiple audio devices yet.
|
// as there's not really any use case for this where we have multiple audio devices yet.
|
||||||
|
@ -91,7 +92,7 @@ static void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context)
|
||||||
|
|
||||||
// diff = 0;
|
// diff = 0;
|
||||||
// chronos::usec delay((250 - diff) * 1000);
|
// chronos::usec delay((250 - diff) * 1000);
|
||||||
chronos::usec delay(250 * 1000);
|
chronos::usec delay(150 * 1000);
|
||||||
|
|
||||||
if (player->pubStream_->getPlayerChunk(buffer[curBuffer], delay, player->frames_))
|
if (player->pubStream_->getPlayerChunk(buffer[curBuffer], delay, player->frames_))
|
||||||
{
|
{
|
||||||
|
@ -197,8 +198,8 @@ void OpenslPlayer::initOpensl()
|
||||||
|
|
||||||
SLAndroidConfigurationItf playerConfig;
|
SLAndroidConfigurationItf playerConfig;
|
||||||
result = (*bqPlayerObject)->GetInterface(bqPlayerObject, SL_IID_ANDROIDCONFIGURATION, &playerConfig);
|
result = (*bqPlayerObject)->GetInterface(bqPlayerObject, SL_IID_ANDROIDCONFIGURATION, &playerConfig);
|
||||||
// SLint32 streamType = SL_ANDROID_STREAM_MEDIA;
|
SLint32 streamType = SL_ANDROID_STREAM_MEDIA;
|
||||||
SLint32 streamType = SL_ANDROID_STREAM_VOICE;
|
// SLint32 streamType = SL_ANDROID_STREAM_VOICE;
|
||||||
result = (*playerConfig)->SetConfiguration(playerConfig, SL_ANDROID_KEY_STREAM_TYPE, &streamType, sizeof(SLint32));
|
result = (*playerConfig)->SetConfiguration(playerConfig, SL_ANDROID_KEY_STREAM_TYPE, &streamType, sizeof(SLint32));
|
||||||
|
|
||||||
result = (*bqPlayerObject)->Realize(bqPlayerObject, SL_BOOLEAN_FALSE);
|
result = (*bqPlayerObject)->Realize(bqPlayerObject, SL_BOOLEAN_FALSE);
|
||||||
|
|
|
@ -89,9 +89,7 @@ int main (int argc, char **argv)
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
logO << "1\n";
|
|
||||||
op.parse(argc, argv);
|
op.parse(argc, argv);
|
||||||
logO << "2\n";
|
|
||||||
}
|
}
|
||||||
catch (const std::invalid_argument& e)
|
catch (const std::invalid_argument& e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -303,7 +303,7 @@ bool Stream::getPlayerChunk(void* outputBuffer, const cs::usec& outputBufferDacT
|
||||||
{
|
{
|
||||||
if (buffer_.full())
|
if (buffer_.full())
|
||||||
{
|
{
|
||||||
if (cs::usec(abs(median_)) > cs::msec(1))
|
if (cs::usec(abs(median_)) > cs::msec(2))
|
||||||
{
|
{
|
||||||
logO << "pBuffer->full() && (abs(median_) > 1): " << median_ << "\n";
|
logO << "pBuffer->full() && (abs(median_) > 1): " << median_ << "\n";
|
||||||
sleep_ = cs::usec(shortMedian_);
|
sleep_ = cs::usec(shortMedian_);
|
||||||
|
@ -319,7 +319,7 @@ bool Stream::getPlayerChunk(void* outputBuffer, const cs::usec& outputBufferDacT
|
||||||
*/ }
|
*/ }
|
||||||
else if (shortBuffer_.full())
|
else if (shortBuffer_.full())
|
||||||
{
|
{
|
||||||
if (cs::usec(abs(shortMedian_)) > cs::msec(5))
|
if (cs::usec(abs(shortMedian_)) > cs::msec(20))
|
||||||
{
|
{
|
||||||
logO << "pShortBuffer->full() && (abs(shortMedian_) > 5): " << shortMedian_ << "\n";
|
logO << "pShortBuffer->full() && (abs(shortMedian_) > 5): " << shortMedian_ << "\n";
|
||||||
sleep_ = cs::usec(shortMedian_);
|
sleep_ = cs::usec(shortMedian_);
|
||||||
|
@ -329,7 +329,7 @@ bool Stream::getPlayerChunk(void* outputBuffer, const cs::usec& outputBufferDacT
|
||||||
setRealSampleRate(format_.rate + -shortMedian_ / 100);
|
setRealSampleRate(format_.rate + -shortMedian_ / 100);
|
||||||
}
|
}
|
||||||
*/ }
|
*/ }
|
||||||
else if (miniBuffer_.full() && (cs::usec(abs(miniBuffer_.median())) > cs::msec(50)))
|
else if (miniBuffer_.full() && (cs::usec(abs(miniBuffer_.median())) > cs::msec(200)))
|
||||||
{
|
{
|
||||||
logO << "pMiniBuffer->full() && (abs(pMiniBuffer->mean()) > 50): " << miniBuffer_.median() << "\n";
|
logO << "pMiniBuffer->full() && (abs(pMiniBuffer->mean()) > 50): " << miniBuffer_.median() << "\n";
|
||||||
sleep_ = cs::usec((cs::msec::rep)miniBuffer_.mean());
|
sleep_ = cs::usec((cs::msec::rep)miniBuffer_.mean());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue