mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-14 17:46:45 +02:00
Check if enough alsa frames are available
This commit is contained in:
parent
57aa683f93
commit
2c7cbc0d75
4 changed files with 30 additions and 28 deletions
|
@ -31,6 +31,24 @@
|
|||
#if defined(HAS_OPUS)
|
||||
#include "decoder/opus_decoder.hpp"
|
||||
#endif
|
||||
|
||||
#ifdef HAS_ALSA
|
||||
#include "player/alsa_player.hpp"
|
||||
#include "player/alsa_player_test.hpp"
|
||||
#endif
|
||||
#ifdef HAS_OPENSL
|
||||
#include "player/opensl_player.hpp"
|
||||
#endif
|
||||
#ifdef HAS_OBOE
|
||||
#include "player/oboe_player.hpp"
|
||||
#endif
|
||||
#ifdef HAS_COREAUDIO
|
||||
#include "player/coreaudio_player.hpp"
|
||||
#endif
|
||||
#ifdef WINDOWS
|
||||
#include "player/wasapi_player.h"
|
||||
#endif
|
||||
|
||||
#include "browseZeroConf/browse_mdns.hpp"
|
||||
#include "common/aixlog.hpp"
|
||||
#include "common/snap_exception.hpp"
|
||||
|
|
|
@ -19,31 +19,17 @@
|
|||
#ifndef CONTROLLER_H
|
||||
#define CONTROLLER_H
|
||||
|
||||
#include "client_connection.hpp"
|
||||
#include "client_settings.hpp"
|
||||
#include "decoder/decoder.hpp"
|
||||
#include "message/message.hpp"
|
||||
#include "message/server_settings.hpp"
|
||||
#include "message/stream_tags.hpp"
|
||||
#include "metadata.hpp"
|
||||
#include "player/player.hpp"
|
||||
#include "stream.hpp"
|
||||
#include <atomic>
|
||||
#include <thread>
|
||||
#ifdef HAS_ALSA
|
||||
#include "player/alsa_player.hpp"
|
||||
#endif
|
||||
#ifdef HAS_OPENSL
|
||||
#include "player/opensl_player.hpp"
|
||||
#endif
|
||||
#ifdef HAS_OBOE
|
||||
#include "player/oboe_player.hpp"
|
||||
#endif
|
||||
#ifdef HAS_COREAUDIO
|
||||
#include "player/coreaudio_player.hpp"
|
||||
#endif
|
||||
#ifdef WINDOWS
|
||||
#include "player/wasapi_player.h"
|
||||
#endif
|
||||
#include "client_connection.hpp"
|
||||
#include "client_settings.hpp"
|
||||
#include "metadata.hpp"
|
||||
#include "stream.hpp"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
|
|
|
@ -494,6 +494,13 @@ void AlsaPlayer::worker()
|
|||
}
|
||||
}
|
||||
|
||||
if (framesAvail < static_cast<snd_pcm_sframes_t>(frames_))
|
||||
{
|
||||
this_thread::sleep_for(10ms);
|
||||
continue;
|
||||
}
|
||||
|
||||
// LOG(TRACE, LOG_TAG) << "res: " << result << ", framesAvail: " << framesAvail << ", delay: " << framesDelay << ", frames: " << frames_ << "\n";
|
||||
chronos::usec delay(static_cast<chronos::usec::rep>(1000 * (double)framesDelay / format.msRate()));
|
||||
// LOG(TRACE, LOG_TAG) << "delay: " << framesDelay << ", delay[ms]: " << delay.count() / 1000 << ", avail: " << framesAvail << "\n";
|
||||
|
||||
|
|
|
@ -41,15 +41,6 @@ public:
|
|||
return val;
|
||||
}
|
||||
|
||||
T front()
|
||||
{
|
||||
std::unique_lock<std::mutex> mlock(mutex_);
|
||||
while (queue_.empty())
|
||||
cond_.wait(mlock);
|
||||
|
||||
return queue_.front();
|
||||
}
|
||||
|
||||
void abort_wait()
|
||||
{
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue