mirror of
https://github.com/badaix/snapcast.git
synced 2025-04-29 02:07:55 +02:00
Add some more LOG_TAGs
This commit is contained in:
parent
ec6db408fa
commit
9b57dd21ba
7 changed files with 47 additions and 37 deletions
|
@ -29,6 +29,8 @@
|
|||
|
||||
static AvahiSimplePoll* simple_poll = nullptr;
|
||||
|
||||
static constexpr auto LOG_TAG = "Avahi";
|
||||
|
||||
|
||||
BrowseAvahi::BrowseAvahi() : client_(nullptr), sb_(nullptr)
|
||||
{
|
||||
|
@ -70,15 +72,15 @@ void BrowseAvahi::resolve_callback(AvahiServiceResolver* r, AVAHI_GCC_UNUSED Ava
|
|||
switch (event)
|
||||
{
|
||||
case AVAHI_RESOLVER_FAILURE:
|
||||
LOG(ERROR) << "(Resolver) Failed to resolve service '" << name << "' of type '" << type << "' in domain '" << domain
|
||||
<< "': " << avahi_strerror(avahi_client_errno(avahi_service_resolver_get_client(r))) << "\n";
|
||||
LOG(ERROR, LOG_TAG) << "(Resolver) Failed to resolve service '" << name << "' of type '" << type << "' in domain '" << domain
|
||||
<< "': " << avahi_strerror(avahi_client_errno(avahi_service_resolver_get_client(r))) << "\n";
|
||||
break;
|
||||
|
||||
case AVAHI_RESOLVER_FOUND:
|
||||
{
|
||||
char a[AVAHI_ADDRESS_STR_MAX], *t;
|
||||
|
||||
LOG(INFO) << "Service '" << name << "' of type '" << type << "' in domain '" << domain << "':\n";
|
||||
LOG(INFO, LOG_TAG) << "Service '" << name << "' of type '" << type << "' in domain '" << domain << "':\n";
|
||||
|
||||
avahi_address_snprint(a, sizeof(a), address);
|
||||
browseAvahi->result_.host = host_name;
|
||||
|
@ -90,15 +92,15 @@ void BrowseAvahi::resolve_callback(AvahiServiceResolver* r, AVAHI_GCC_UNUSED Ava
|
|||
browseAvahi->result_.iface_idx = interface;
|
||||
|
||||
t = avahi_string_list_to_string(txt);
|
||||
LOG(INFO) << "\t" << host_name << ":" << port << " (" << a << ")\n";
|
||||
LOG(DEBUG) << "\tTXT=" << t << "\n";
|
||||
LOG(DEBUG) << "\tProto=" << (int)protocol << "\n";
|
||||
LOG(DEBUG) << "\tcookie is " << avahi_string_list_get_service_cookie(txt) << "\n";
|
||||
LOG(DEBUG) << "\tis_local: " << !!(flags & AVAHI_LOOKUP_RESULT_LOCAL) << "\n";
|
||||
LOG(DEBUG) << "\tour_own: " << !!(flags & AVAHI_LOOKUP_RESULT_OUR_OWN) << "\n";
|
||||
LOG(DEBUG) << "\twide_area: " << !!(flags & AVAHI_LOOKUP_RESULT_WIDE_AREA) << "\n";
|
||||
LOG(DEBUG) << "\tmulticast: " << !!(flags & AVAHI_LOOKUP_RESULT_MULTICAST) << "\n";
|
||||
LOG(DEBUG) << "\tcached: " << !!(flags & AVAHI_LOOKUP_RESULT_CACHED) << "\n";
|
||||
LOG(INFO, LOG_TAG) << "\t" << host_name << ":" << port << " (" << a << ")\n";
|
||||
LOG(DEBUG, LOG_TAG) << "\tTXT=" << t << "\n";
|
||||
LOG(DEBUG, LOG_TAG) << "\tProto=" << (int)protocol << "\n";
|
||||
LOG(DEBUG, LOG_TAG) << "\tcookie is " << avahi_string_list_get_service_cookie(txt) << "\n";
|
||||
LOG(DEBUG, LOG_TAG) << "\tis_local: " << !!(flags & AVAHI_LOOKUP_RESULT_LOCAL) << "\n";
|
||||
LOG(DEBUG, LOG_TAG) << "\tour_own: " << !!(flags & AVAHI_LOOKUP_RESULT_OUR_OWN) << "\n";
|
||||
LOG(DEBUG, LOG_TAG) << "\twide_area: " << !!(flags & AVAHI_LOOKUP_RESULT_WIDE_AREA) << "\n";
|
||||
LOG(DEBUG, LOG_TAG) << "\tmulticast: " << !!(flags & AVAHI_LOOKUP_RESULT_MULTICAST) << "\n";
|
||||
LOG(DEBUG, LOG_TAG) << "\tcached: " << !!(flags & AVAHI_LOOKUP_RESULT_CACHED) << "\n";
|
||||
avahi_free(t);
|
||||
}
|
||||
}
|
||||
|
@ -120,12 +122,12 @@ void BrowseAvahi::browse_callback(AvahiServiceBrowser* b, AvahiIfIndex interface
|
|||
switch (event)
|
||||
{
|
||||
case AVAHI_BROWSER_FAILURE:
|
||||
LOG(ERROR) << "(Browser) " << avahi_strerror(avahi_client_errno(avahi_service_browser_get_client(b))) << "\n";
|
||||
LOG(ERROR, LOG_TAG) << "(Browser) " << avahi_strerror(avahi_client_errno(avahi_service_browser_get_client(b))) << "\n";
|
||||
avahi_simple_poll_quit(simple_poll);
|
||||
return;
|
||||
|
||||
case AVAHI_BROWSER_NEW:
|
||||
LOG(INFO) << "(Browser) NEW: service '" << name << "' of type '" << type << "' in domain '" << domain << "'\n";
|
||||
LOG(INFO, LOG_TAG) << "(Browser) NEW: service '" << name << "' of type '" << type << "' in domain '" << domain << "'\n";
|
||||
|
||||
/* We ignore the returned resolver object. In the callback
|
||||
function we free it. If the server is terminated before
|
||||
|
@ -134,17 +136,17 @@ void BrowseAvahi::browse_callback(AvahiServiceBrowser* b, AvahiIfIndex interface
|
|||
|
||||
if (!(avahi_service_resolver_new(browseAvahi->client_, interface, protocol, name, type, domain, AVAHI_PROTO_UNSPEC, (AvahiLookupFlags)0,
|
||||
resolve_callback, userdata)))
|
||||
LOG(ERROR) << "Failed to resolve service '" << name << "': " << avahi_strerror(avahi_client_errno(browseAvahi->client_)) << "\n";
|
||||
LOG(ERROR, LOG_TAG) << "Failed to resolve service '" << name << "': " << avahi_strerror(avahi_client_errno(browseAvahi->client_)) << "\n";
|
||||
|
||||
break;
|
||||
|
||||
case AVAHI_BROWSER_REMOVE:
|
||||
LOG(INFO) << "(Browser) REMOVE: service '" << name << "' of type '" << type << "' in domain '" << domain << "'\n";
|
||||
LOG(INFO, LOG_TAG) << "(Browser) REMOVE: service '" << name << "' of type '" << type << "' in domain '" << domain << "'\n";
|
||||
break;
|
||||
|
||||
case AVAHI_BROWSER_ALL_FOR_NOW:
|
||||
case AVAHI_BROWSER_CACHE_EXHAUSTED:
|
||||
LOG(INFO) << "(Browser) " << (event == AVAHI_BROWSER_CACHE_EXHAUSTED ? "CACHE_EXHAUSTED" : "ALL_FOR_NOW") << "\n";
|
||||
LOG(INFO, LOG_TAG) << "(Browser) " << (event == AVAHI_BROWSER_CACHE_EXHAUSTED ? "CACHE_EXHAUSTED" : "ALL_FOR_NOW") << "\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -159,7 +161,7 @@ void BrowseAvahi::client_callback(AvahiClient* c, AvahiClientState state, AVAHI_
|
|||
|
||||
if (state == AVAHI_CLIENT_FAILURE)
|
||||
{
|
||||
LOG(ERROR) << "Server connection failure: " << avahi_strerror(avahi_client_errno(c)) << "\n";
|
||||
LOG(ERROR, LOG_TAG) << "Server connection failure: " << avahi_strerror(avahi_client_errno(c)) << "\n";
|
||||
avahi_simple_poll_quit(simple_poll);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
static constexpr auto LOG_TAG = "Bonjour";
|
||||
|
||||
struct DNSServiceRefDeleter
|
||||
{
|
||||
void operator()(DNSServiceRef* ref)
|
||||
|
@ -241,7 +243,7 @@ bool BrowseBonjour::browse(const string& serviceName, mDNSResult& result, int /*
|
|||
return false;
|
||||
|
||||
if (resultCollection.size() != 1)
|
||||
LOG(NOTICE) << "Multiple servers found. Using first" << endl;
|
||||
LOG(NOTICE, LOG_TAG) << "Multiple servers found. Using first" << endl;
|
||||
|
||||
result = resultCollection[0];
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
static constexpr auto LOG_TAG = "FlacDecoder";
|
||||
|
||||
namespace decoder
|
||||
{
|
||||
|
||||
|
@ -83,7 +85,7 @@ bool FlacDecoder::decode(msg::PcmChunk* chunk)
|
|||
|
||||
if (lastError_)
|
||||
{
|
||||
LOG(ERROR) << "FLAC decode error: " << FLAC__StreamDecoderErrorStatusString[*lastError_] << "\n";
|
||||
LOG(ERROR, LOG_TAG) << "FLAC decode error: " << FLAC__StreamDecoderErrorStatusString[*lastError_] << "\n";
|
||||
lastError_ = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
@ -94,7 +96,7 @@ bool FlacDecoder::decode(msg::PcmChunk* chunk)
|
|||
double diffMs = static_cast<double>(cacheInfo_.cachedBlocks_) / (static_cast<double>(cacheInfo_.sampleRate_) / 1000.);
|
||||
auto us = static_cast<uint64_t>(diffMs * 1000.);
|
||||
tv diff(static_cast<int32_t>(us / 1000000), static_cast<int32_t>(us % 1000000));
|
||||
LOG(TRACE) << "Cached: " << cacheInfo_.cachedBlocks_ << ", " << diffMs << "ms, " << diff.sec << "s, " << diff.usec << "us\n";
|
||||
LOG(TRACE, LOG_TAG) << "Cached: " << cacheInfo_.cachedBlocks_ << ", " << diffMs << "ms, " << diff.sec << "s, " << diff.usec << "us\n";
|
||||
chunk->timestamp = chunk->timestamp - diff;
|
||||
}
|
||||
return true;
|
||||
|
@ -168,7 +170,7 @@ FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder* /*decod
|
|||
{
|
||||
if (buffer[channel] == nullptr)
|
||||
{
|
||||
LOG(ERROR) << "ERROR: buffer[" << channel << "] is NULL\n";
|
||||
LOG(ERROR, LOG_TAG) << "ERROR: buffer[" << channel << "] is NULL\n";
|
||||
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
|
||||
}
|
||||
|
||||
|
@ -211,7 +213,7 @@ void metadata_callback(const FLAC__StreamDecoder* /*decoder*/, const FLAC__Strea
|
|||
|
||||
void error_callback(const FLAC__StreamDecoder* /*decoder*/, FLAC__StreamDecoderErrorStatus status, void* client_data)
|
||||
{
|
||||
LOG(ERROR) << "Got error callback: " << FLAC__StreamDecoderErrorStatusString[status] << "\n";
|
||||
LOG(ERROR, LOG_TAG) << "Got error callback: " << FLAC__StreamDecoderErrorStatusString[status] << "\n";
|
||||
static_cast<FlacDecoder*>(client_data)->lastError_ = std::make_unique<FLAC__StreamDecoderErrorStatus>(status);
|
||||
}
|
||||
} // namespace callback
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
static constexpr auto LOG_TAG = "OpusDecoder";
|
||||
|
||||
namespace decoder
|
||||
{
|
||||
|
||||
|
@ -74,7 +76,7 @@ bool OggDecoder::decode(msg::PcmChunk* chunk)
|
|||
if (result < 0)
|
||||
{
|
||||
/* missing or corrupt data at this page position */
|
||||
LOG(ERROR) << "Corrupt or missing data in bitstream; continuing...\n";
|
||||
LOG(ERROR, LOG_TAG) << "Corrupt or missing data in bitstream; continuing...\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -232,12 +234,12 @@ SampleFormat OggDecoder::setHeader(msg::CodecHeader* chunk)
|
|||
std::string comment(*ptr);
|
||||
if (comment.find("SAMPLE_FORMAT=") == 0)
|
||||
sampleFormat_.setFormat(comment.substr(comment.find("=") + 1));
|
||||
LOG(INFO) << "comment: " << comment << "\n";
|
||||
LOG(INFO, LOG_TAG) << "comment: " << comment << "\n";
|
||||
;
|
||||
++ptr;
|
||||
}
|
||||
|
||||
LOG(INFO) << "Encoded by: " << vc.vendor << "\n";
|
||||
LOG(INFO, LOG_TAG) << "Encoded by: " << vc.vendor << "\n";
|
||||
|
||||
return sampleFormat_;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#define NUM_BUFFERS 2
|
||||
|
||||
static constexpr auto LOG_TAG = "CoreAudioPlayer";
|
||||
|
||||
// http://stackoverflow.com/questions/4863811/how-to-use-audioqueue-to-play-a-sound-for-mac-osx-in-c
|
||||
// https://gist.github.com/andormade/1360885
|
||||
|
@ -80,7 +81,7 @@ std::vector<PcmDevice> CoreAudioPlayer::pcm_list(void)
|
|||
char buf[1024];
|
||||
theAddress = {kAudioDevicePropertyDeviceName, kAudioDevicePropertyScopeOutput, 0};
|
||||
AudioObjectGetPropertyData(devids[i], &theAddress, 0, NULL, &maxlen, buf);
|
||||
LOG(DEBUG) << "device: " << i << ", name: " << buf << ", channels: " << channels << "\n";
|
||||
LOG(DEBUG, LOG_TAG) << "device: " << i << ", name: " << buf << ", channels: " << channels << "\n";
|
||||
|
||||
result.push_back(PcmDevice(i, buf));
|
||||
}
|
||||
|
@ -99,7 +100,7 @@ void CoreAudioPlayer::playerCallback(AudioQueueRef queue, AudioQueueBufferRef bu
|
|||
size_t bufferedMs = bufferedFrames * 1000 / pubStream_->getFormat().rate() + (ms_ * (NUM_BUFFERS - 1));
|
||||
/// 15ms DAC delay. Based on trying.
|
||||
bufferedMs += 15;
|
||||
// LOG(INFO) << "buffered: " << bufferedFrames << ", ms: " << bufferedMs << ", mSampleTime: " << timestamp.mSampleTime << "\n";
|
||||
// LOG(INFO, LOG_TAG) << "buffered: " << bufferedFrames << ", ms: " << bufferedMs << ", mSampleTime: " << timestamp.mSampleTime << "\n";
|
||||
|
||||
/// TODO: sometimes this bufferedMS or AudioTimeStamp wraps around 1s (i.e. we're 1s out of sync (behind)) and recovers later on
|
||||
chronos::usec delay(bufferedMs * 1000);
|
||||
|
@ -108,11 +109,11 @@ void CoreAudioPlayer::playerCallback(AudioQueueRef queue, AudioQueueBufferRef bu
|
|||
{
|
||||
if (chronos::getTickCount() - lastChunkTick > 5000)
|
||||
{
|
||||
LOG(NOTICE) << "No chunk received for 5000ms. Closing Audio Queue.\n";
|
||||
LOG(NOTICE, LOG_TAG) << "No chunk received for 5000ms. Closing Audio Queue.\n";
|
||||
uninitAudioQueue(queue);
|
||||
return;
|
||||
}
|
||||
// LOG(INFO) << "Failed to get chunk. Playing silence.\n";
|
||||
// LOG(INFO, LOG_TAG) << "Failed to get chunk. Playing silence.\n";
|
||||
memset(buffer, 0, buff_size_);
|
||||
}
|
||||
else
|
||||
|
@ -149,7 +150,7 @@ void CoreAudioPlayer::worker()
|
|||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
LOG(ERROR) << "Exception in worker: " << e.what() << "\n";
|
||||
LOG(ERROR, LOG_TAG) << "Exception in worker: " << e.what() << "\n";
|
||||
chronos::sleep(100);
|
||||
}
|
||||
}
|
||||
|
@ -186,7 +187,7 @@ void CoreAudioPlayer::initAudioQueue()
|
|||
frames_ = (sampleFormat.rate() * ms_) / 1000;
|
||||
ms_ = frames_ * 1000 / sampleFormat.rate();
|
||||
buff_size_ = frames_ * sampleFormat.frameSize();
|
||||
LOG(INFO) << "frames: " << frames_ << ", ms: " << ms_ << ", buffer size: " << buff_size_ << "\n";
|
||||
LOG(INFO, LOG_TAG) << "frames: " << frames_ << ", ms: " << ms_ << ", buffer size: " << buff_size_ << "\n";
|
||||
|
||||
AudioQueueBufferRef buffers[NUM_BUFFERS];
|
||||
for (int i = 0; i < NUM_BUFFERS; i++)
|
||||
|
@ -196,7 +197,7 @@ void CoreAudioPlayer::initAudioQueue()
|
|||
callback(this, queue, buffers[i]);
|
||||
}
|
||||
|
||||
LOG(ERROR) << "CoreAudioPlayer::worker\n";
|
||||
LOG(ERROR, LOG_TAG) << "CoreAudioPlayer::worker\n";
|
||||
AudioQueueCreateTimeline(queue, &timeLine_);
|
||||
AudioQueueStart(queue, NULL);
|
||||
CFRunLoopRun();
|
||||
|
|
|
@ -137,7 +137,7 @@ oboe::DataCallbackResult OboePlayer::onAudioReady(oboe::AudioStream* /*oboeStrea
|
|||
|
||||
if (!stream_->getPlayerChunk(audioData, delay, numFrames))
|
||||
{
|
||||
// LOG(INFO) << "Failed to get chunk. Playing silence.\n";
|
||||
// LOG(INFO, LOG_TAG) << "Failed to get chunk. Playing silence.\n";
|
||||
memset(audioData, 0, numFrames * stream_->getFormat().frameSize());
|
||||
}
|
||||
else
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include <chrono>
|
||||
|
||||
static constexpr auto LOG_TAG = "TimeProvider";
|
||||
|
||||
TimeProvider::TimeProvider() : diffToServer_(0)
|
||||
{
|
||||
|
@ -47,7 +48,7 @@ void TimeProvider::setDiffToServer(double ms)
|
|||
/// clear diffBuffer if last update is older than a minute
|
||||
if (!diffBuffer_.empty() && (diff > 60s))
|
||||
{
|
||||
LOG(INFO) << "Last time sync older than a minute. Clearing time buffer\n";
|
||||
LOG(INFO, LOG_TAG) << "Last time sync older than a minute. Clearing time buffer\n";
|
||||
diffToServer_ = static_cast<chronos::usec::rep>(ms * 1000);
|
||||
diffBuffer_.clear();
|
||||
}
|
||||
|
@ -55,8 +56,8 @@ void TimeProvider::setDiffToServer(double ms)
|
|||
|
||||
diffBuffer_.add(static_cast<chronos::usec::rep>(ms * 1000));
|
||||
diffToServer_ = diffBuffer_.median();
|
||||
// LOG(INFO) << "setDiffToServer: " << ms << ", diff: " << diffToServer_ / 1000000 << " s, " << (diffToServer_ / 1000) % 1000 << "." << diffToServer_ % 1000
|
||||
// << " ms\n";
|
||||
// LOG(INFO, LOG_TAG) << "setDiffToServer: " << ms << ", diff: " << diffToServer_ / 1000000 << " s, " << (diffToServer_ / 1000) % 1000 << "." <<
|
||||
// diffToServer_ % 1000 << " ms\n";
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Reference in a new issue