mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-31 18:06:15 +02:00
Add "Init start" and "Init done" loglines
to detect if the player hangs and to kill and restart snapclient
This commit is contained in:
parent
a013558e81
commit
ea3eb988a9
2 changed files with 10 additions and 6 deletions
|
@ -29,9 +29,11 @@ using namespace std;
|
|||
static constexpr auto LOG_TAG = "OboePlayer";
|
||||
static constexpr double kDefaultLatency = 50;
|
||||
|
||||
|
||||
OboePlayer::OboePlayer(const PcmDevice& pcmDevice, std::shared_ptr<Stream> stream) : Player(pcmDevice, stream)
|
||||
{
|
||||
LOG(DEBUG, LOG_TAG) << "Contructor\n";
|
||||
LOG(INFO, LOG_TAG) << "Init start\n";
|
||||
char* env = getenv("SAMPLE_RATE");
|
||||
if (env)
|
||||
oboe::DefaultStreamValues::SampleRate = cpt::stoi(env, oboe::DefaultStreamValues::SampleRate);
|
||||
|
@ -46,8 +48,8 @@ OboePlayer::OboePlayer(const PcmDevice& pcmDevice, std::shared_ptr<Stream> strea
|
|||
oboe::AudioStreamBuilder builder;
|
||||
auto result = builder.setSharingMode(oboe::SharingMode::Exclusive)
|
||||
->setPerformanceMode(oboe::PerformanceMode::LowLatency)
|
||||
->setChannelCount(stream->getFormat().channels)
|
||||
->setSampleRate(stream->getFormat().rate)
|
||||
->setChannelCount(stream->getFormat().channels())
|
||||
->setSampleRate(stream->getFormat().rate())
|
||||
->setFormat(oboe::AudioFormat::I16)
|
||||
->setCallback(this)
|
||||
->setDirection(oboe::Direction::Output)
|
||||
|
@ -67,6 +69,7 @@ OboePlayer::OboePlayer(const PcmDevice& pcmDevice, std::shared_ptr<Stream> strea
|
|||
{
|
||||
out_stream_->setBufferSizeInFrames(4 * out_stream_->getFramesPerBurst());
|
||||
}
|
||||
LOG(INFO, LOG_TAG) << "Init done\n";
|
||||
}
|
||||
|
||||
|
||||
|
@ -85,8 +88,6 @@ OboePlayer::~OboePlayer()
|
|||
|
||||
double OboePlayer::getCurrentOutputLatencyMillis() const
|
||||
{
|
||||
// if (!mIsLatencyDetectionSupported)
|
||||
// return -1;
|
||||
// Get the time that a known audio frame was presented for playing
|
||||
auto result = out_stream_->getTimestamp(CLOCK_MONOTONIC);
|
||||
double outputLatencyMillis = kDefaultLatency;
|
||||
|
|
|
@ -158,6 +158,8 @@ void OpenslPlayer::initOpensl()
|
|||
if (active_)
|
||||
return;
|
||||
|
||||
LOG(INFO, LOG_TAG) << "Init start\n";
|
||||
|
||||
const SampleFormat& format = stream_->getFormat();
|
||||
|
||||
|
||||
|
@ -225,7 +227,7 @@ void OpenslPlayer::initOpensl()
|
|||
|
||||
SLuint32 bitsPerSample = SL_PCMSAMPLEFORMAT_FIXED_16;
|
||||
SLuint32 containerSize = SL_PCMSAMPLEFORMAT_FIXED_16;
|
||||
switch (format.bits)
|
||||
switch (format.bits())
|
||||
{
|
||||
case 8:
|
||||
bitsPerSample = SL_PCMSAMPLEFORMAT_FIXED_8;
|
||||
|
@ -244,7 +246,7 @@ void OpenslPlayer::initOpensl()
|
|||
containerSize = SL_PCMSAMPLEFORMAT_FIXED_32;
|
||||
break;
|
||||
default:
|
||||
throw SnapException("Unsupported sample format: " + cpt::to_string(format.bits));
|
||||
throw SnapException("Unsupported sample format: " + cpt::to_string(format.bits()));
|
||||
}
|
||||
|
||||
|
||||
|
@ -297,6 +299,7 @@ void OpenslPlayer::initOpensl()
|
|||
result = (*bqPlayerBufferQueue)->Enqueue(bqPlayerBufferQueue, buffer[curBuffer], sizeof(buffer[curBuffer]));
|
||||
throwUnsuccess(kPhaseInit, "PlayerBufferQueue::Enqueue", result);
|
||||
curBuffer ^= 1;
|
||||
LOG(INFO, LOG_TAG) << "Init done\n";
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue