Route all logging through the Void::Log facade
Delete the echoion Logger adapter (Logger.{hpp,cpp}) and the
ILogger/LoggerRegistry indirection. Core::installLogging() builds the
console + split-file Void::Logging::MultiLogger and installs it as the
process-wide Void::Log sink via Void::Log::make_sink (logSink_ owns it for
the process lifetime). The ~450 ECHOION_LOG_* call sites across EchoionCore
are rewritten to Void::Log::<level>("<Subsystem>", "{}", <expr>) with
per-file module tags (warning->warn, critical->fatal); the pre-formatted
message is passed as the single "{}" argument. Build green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
0e08ccaefa
commit
2d7651c308
42 files changed
+550
-792
No files matched your search
+128
-128
@@ -1,5 +1,5 @@
|
||||
#include "ConfigManager.hpp"
|
||||
#include "LoggerInterface.hpp"
|
||||
#include <Void/Log/Log.hpp>
|
||||
#include "echoion/core/MusicManager.hpp"
|
||||
#include <Events.hpp>
|
||||
#include <algorithm>
|
||||
@@ -34,7 +34,7 @@ namespace Echoion::Core
|
||||
// needed
|
||||
if (networkConfig.proxy.has_value() && networkConfig.proxy->enabled()) {
|
||||
networkClient_->setProxy(networkConfig.proxy);
|
||||
ECHOION_LOG_INFO(std::format(
|
||||
Void::Log::info("MusicManager", "{}", std::format(
|
||||
"NetworkClient using {} proxy: {}:{}",
|
||||
(networkConfig.proxy->kind == Void::Net::ProxyConfig::Kind::Socks5) ? "SOCKS5" : "HTTP",
|
||||
networkConfig.proxy->host, networkConfig.proxy->port));
|
||||
@@ -45,12 +45,12 @@ namespace Echoion::Core
|
||||
// Configure YouTube cookies if provided
|
||||
if (youtubeConfig.youtubeCookiesPath.has_value()) {
|
||||
youTubeClient_->setCookiesPath(*youtubeConfig.youtubeCookiesPath);
|
||||
ECHOION_LOG_INFO(std::format("Using YouTube cookies from file: {}",
|
||||
Void::Log::info("MusicManager", "{}", std::format("Using YouTube cookies from file: {}",
|
||||
*youtubeConfig.youtubeCookiesPath));
|
||||
} else if (youtubeConfig.cookiesFromBrowser.has_value()) {
|
||||
youTubeClient_->setCookiesFromBrowser(
|
||||
*youtubeConfig.cookiesFromBrowser);
|
||||
ECHOION_LOG_INFO(
|
||||
Void::Log::info("MusicManager", "{}",
|
||||
std::format("Using YouTube cookies from browser: {}",
|
||||
*youtubeConfig.cookiesFromBrowser));
|
||||
}
|
||||
@@ -78,7 +78,7 @@ namespace Echoion::Core
|
||||
|
||||
auto ytResult = youTubeClient_->initialize();
|
||||
if (!ytResult) {
|
||||
ECHOION_LOG_WARNING(
|
||||
Void::Log::warn("MusicManager", "{}",
|
||||
std::format("Failed to initialize YouTube client: {}",
|
||||
ytResult.error().message));
|
||||
}
|
||||
@@ -95,7 +95,7 @@ namespace Echoion::Core
|
||||
// Set proxy config from NetworkConfig if enabled
|
||||
if (networkConfig.proxy.has_value() && networkConfig.proxy->enabled()) {
|
||||
audioDecoder_->setProxyConfig(networkConfig.proxy);
|
||||
ECHOION_LOG_INFO(
|
||||
Void::Log::info("MusicManager", "{}",
|
||||
std::format("AudioDecoder using {} proxy: {}:{}",
|
||||
(networkConfig.proxy->kind == Void::Net::ProxyConfig::Kind::Socks5) ? "SOCKS5" : "HTTP",
|
||||
networkConfig.proxy->host,
|
||||
@@ -106,7 +106,7 @@ namespace Echoion::Core
|
||||
subscriptionManager_ = std::make_unique<SubscriptionManager>();
|
||||
auto subResult = subscriptionManager_->initialize(database);
|
||||
if (!subResult) {
|
||||
ECHOION_LOG_WARNING(
|
||||
Void::Log::warn("MusicManager", "{}",
|
||||
std::format("Failed to initialize subscription manager: {}",
|
||||
subResult.error().message));
|
||||
// Not fatal - continue without subscriptions
|
||||
@@ -114,7 +114,7 @@ namespace Echoion::Core
|
||||
|
||||
volume_ = botConfig.defaultVolume;
|
||||
|
||||
ECHOION_LOG_INFO("MusicManager initialized");
|
||||
Void::Log::info("MusicManager", "{}", "MusicManager initialized");
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ namespace Echoion::Core
|
||||
std::error_code ec;
|
||||
std::filesystem::remove(filepath, ec);
|
||||
if (!ec) {
|
||||
ECHOION_LOG_DEBUG(
|
||||
Void::Log::debug("MusicManager", "{}",
|
||||
std::format("Cleaned up temp file: {}", filepath));
|
||||
}
|
||||
}
|
||||
@@ -164,13 +164,13 @@ namespace Echoion::Core
|
||||
}
|
||||
}
|
||||
|
||||
ECHOION_LOG_INFO("MusicManager shutdown");
|
||||
Void::Log::info("MusicManager", "{}", "MusicManager shutdown");
|
||||
}
|
||||
|
||||
Api::Result<std::string> MusicManager::play(const std::string& query,
|
||||
uint64_t clientId)
|
||||
{
|
||||
ECHOION_LOG_INFO(
|
||||
Void::Log::info("MusicManager", "{}",
|
||||
std::format("Play request: '{}' from client {}", query, clientId));
|
||||
auto startTime = std::chrono::steady_clock::now();
|
||||
|
||||
@@ -184,18 +184,18 @@ namespace Echoion::Core
|
||||
|
||||
auto track = resolveQuery(query);
|
||||
auto afterResolve = std::chrono::steady_clock::now();
|
||||
ECHOION_LOG_DEBUG(
|
||||
Void::Log::debug("MusicManager", "{}",
|
||||
std::format("resolveQuery took {} ms",
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
afterResolve - startTime)
|
||||
.count()));
|
||||
if (!track) {
|
||||
ECHOION_LOG_ERROR(std::format("Failed to resolve query '{}': {}",
|
||||
Void::Log::error("MusicManager", "{}", std::format("Failed to resolve query '{}': {}",
|
||||
query, track.error().message));
|
||||
return std::unexpected(track.error());
|
||||
}
|
||||
|
||||
ECHOION_LOG_INFO(std::format(
|
||||
Void::Log::info("MusicManager", "{}", std::format(
|
||||
"Resolved track: {} - {} ({}:{}", track->title, track->artist,
|
||||
track->source == Api::TrackSource::YouTube ? "YouTube" : "Unknown",
|
||||
track->streamUrl.has_value() ? "direct" : "needs extraction"));
|
||||
@@ -209,22 +209,22 @@ namespace Echoion::Core
|
||||
.isPlaying = true,
|
||||
.position = std::chrono::milliseconds(0)};
|
||||
|
||||
ECHOION_LOG_DEBUG("Getting stream URL...");
|
||||
Void::Log::debug("MusicManager", "{}", "Getting stream URL...");
|
||||
auto streamStart = std::chrono::steady_clock::now();
|
||||
auto streamUrl = getStreamUrl(*track);
|
||||
ECHOION_LOG_DEBUG(std::format(
|
||||
Void::Log::debug("MusicManager", "{}", std::format(
|
||||
"getStreamUrl took {} ms",
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::steady_clock::now() - streamStart)
|
||||
.count()));
|
||||
if (!streamUrl) {
|
||||
ECHOION_LOG_ERROR(std::format("Failed to get stream URL: {}",
|
||||
Void::Log::error("MusicManager", "{}", std::format("Failed to get stream URL: {}",
|
||||
streamUrl.error().message));
|
||||
currentTrack_.reset();
|
||||
return std::unexpected(streamUrl.error());
|
||||
}
|
||||
|
||||
ECHOION_LOG_DEBUG("Opening audio source...");
|
||||
Void::Log::debug("MusicManager", "{}", "Opening audio source...");
|
||||
auto openResult = audioDecoder_->openSource(*streamUrl);
|
||||
|
||||
// If direct open fails and we have a proxy, try downloading through
|
||||
@@ -232,11 +232,11 @@ namespace Echoion::Core
|
||||
const auto& networkConfig = configManager_->getNetwork();
|
||||
if (!openResult && networkConfig.proxy.has_value() &&
|
||||
networkConfig.proxy->enabled()) {
|
||||
ECHOION_LOG_INFO(
|
||||
Void::Log::info("MusicManager", "{}",
|
||||
"Direct open failed, trying download through proxy...");
|
||||
auto downloadedPath = downloadAudioForPlayback(*streamUrl);
|
||||
if (downloadedPath) {
|
||||
ECHOION_LOG_INFO(std::format("Downloaded audio to: {}",
|
||||
Void::Log::info("MusicManager", "{}", std::format("Downloaded audio to: {}",
|
||||
*downloadedPath));
|
||||
openResult = audioDecoder_->openSource(*downloadedPath);
|
||||
if (openResult) {
|
||||
@@ -246,14 +246,14 @@ namespace Echoion::Core
|
||||
tempFiles_.insert(*downloadedPath);
|
||||
}
|
||||
} else {
|
||||
ECHOION_LOG_WARNING(
|
||||
Void::Log::warn("MusicManager", "{}",
|
||||
std::format("Failed to download through proxy: {}",
|
||||
downloadedPath.error().message));
|
||||
}
|
||||
}
|
||||
|
||||
if (!openResult) {
|
||||
ECHOION_LOG_ERROR(std::format("Failed to open audio source: {}",
|
||||
Void::Log::error("MusicManager", "{}", std::format("Failed to open audio source: {}",
|
||||
openResult.error().message));
|
||||
currentTrack_.reset();
|
||||
return std::unexpected(openResult.error());
|
||||
@@ -286,23 +286,23 @@ namespace Echoion::Core
|
||||
if (!playbackThread_.joinable() || !playbackThreadRunning_) {
|
||||
// Join old thread if it exists but isn't running
|
||||
if (playbackThread_.joinable()) {
|
||||
ECHOION_LOG_INFO("Joining old playback thread before "
|
||||
Void::Log::info("MusicManager", "{}", "Joining old playback thread before "
|
||||
"starting new one...");
|
||||
playbackThread_.join();
|
||||
}
|
||||
playbackThread_ =
|
||||
std::jthread(&MusicManager::playbackThread, this);
|
||||
ECHOION_LOG_INFO("Playback thread started");
|
||||
Void::Log::info("MusicManager", "{}", "Playback thread started");
|
||||
}
|
||||
|
||||
cv_.notify_one();
|
||||
|
||||
ECHOION_LOG_INFO(std::format("Now playing: {} - {}", track->title,
|
||||
Void::Log::info("MusicManager", "{}", std::format("Now playing: {} - {}", track->title,
|
||||
track->artist));
|
||||
return std::format("{} - {}", track->title, track->artist);
|
||||
}
|
||||
|
||||
ECHOION_LOG_DEBUG("Already playing, adding to queue");
|
||||
Void::Log::debug("MusicManager", "{}", "Already playing, adding to queue");
|
||||
auto queueId = queueTrack(*track, clientId);
|
||||
if (!queueId) {
|
||||
return std::unexpected(queueId.error());
|
||||
@@ -324,7 +324,7 @@ namespace Echoion::Core
|
||||
// Capture current position before pausing
|
||||
playbackPosition_ = getPlaybackPosition();
|
||||
isPaused_ = true;
|
||||
ECHOION_LOG_INFO(
|
||||
Void::Log::info("MusicManager", "{}",
|
||||
std::format("Playback paused at {}ms", playbackPosition_.count()));
|
||||
return {};
|
||||
}
|
||||
@@ -343,10 +343,10 @@ namespace Echoion::Core
|
||||
isPaused_ = false;
|
||||
bool needToStartThread = false;
|
||||
if (playbackThread_.joinable() && !playbackThreadRunning_) {
|
||||
ECHOION_LOG_INFO(
|
||||
Void::Log::info("MusicManager", "{}",
|
||||
"Joining finished playback thread before starting new one...");
|
||||
playbackThread_.join();
|
||||
ECHOION_LOG_INFO("Old thread joined");
|
||||
Void::Log::info("MusicManager", "{}", "Old thread joined");
|
||||
needToStartThread = true;
|
||||
}
|
||||
|
||||
@@ -368,13 +368,13 @@ namespace Echoion::Core
|
||||
}
|
||||
|
||||
playbackThread_ = std::jthread(&MusicManager::playbackThread, this);
|
||||
ECHOION_LOG_INFO("Started playback thread");
|
||||
Void::Log::info("MusicManager", "{}", "Started playback thread");
|
||||
}
|
||||
|
||||
// Notify the thread to process
|
||||
cv_.notify_one();
|
||||
|
||||
ECHOION_LOG_INFO(std::format("Playback resumed from {}ms",
|
||||
Void::Log::info("MusicManager", "{}", std::format("Playback resumed from {}ms",
|
||||
playbackPosition_.count()));
|
||||
return {};
|
||||
}
|
||||
@@ -393,7 +393,7 @@ namespace Echoion::Core
|
||||
}
|
||||
|
||||
cv_.notify_one();
|
||||
ECHOION_LOG_INFO("Playback stopped");
|
||||
Void::Log::info("MusicManager", "{}", "Playback stopped");
|
||||
|
||||
// Publish playback stopped event
|
||||
emit(Api::Events::PlaybackStopped{
|
||||
@@ -443,14 +443,14 @@ namespace Echoion::Core
|
||||
audioDecoder_->closeSource();
|
||||
auto openResult = audioDecoder_->openSource(*streamUrl);
|
||||
if (!openResult) {
|
||||
ECHOION_LOG_ERROR(std::format("Failed to open stream: {}",
|
||||
Void::Log::error("MusicManager", "{}", std::format("Failed to open stream: {}",
|
||||
openResult.error().message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cv_.notify_one();
|
||||
ECHOION_LOG_INFO(std::format("Skipped {} track(s)", count));
|
||||
Void::Log::info("MusicManager", "{}", std::format("Skipped {} track(s)", count));
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -477,7 +477,7 @@ namespace Echoion::Core
|
||||
currentTrack_->position = position;
|
||||
}
|
||||
|
||||
ECHOION_LOG_INFO(std::format("Seeked to {} ms", position.count()));
|
||||
Void::Log::info("MusicManager", "{}", std::format("Seeked to {} ms", position.count()));
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -490,7 +490,7 @@ namespace Echoion::Core
|
||||
|
||||
float oldVolume = volume_;
|
||||
volume_ = volume;
|
||||
ECHOION_LOG_INFO(std::format("Volume set to {}", volume));
|
||||
Void::Log::info("MusicManager", "{}", std::format("Volume set to {}", volume));
|
||||
|
||||
// Publish volume changed event
|
||||
emit(Api::Events::VolumeChanged{
|
||||
@@ -507,12 +507,12 @@ namespace Echoion::Core
|
||||
{
|
||||
// Validate track before adding to queue - check if we can get a stream
|
||||
// URL
|
||||
ECHOION_LOG_INFO(
|
||||
Void::Log::info("MusicManager", "{}",
|
||||
std::format("Validating track before queueing: {} - {}",
|
||||
track.title, track.artist));
|
||||
auto streamUrl = getStreamUrl(track);
|
||||
if (!streamUrl) {
|
||||
ECHOION_LOG_WARNING(std::format(
|
||||
Void::Log::warn("MusicManager", "{}", std::format(
|
||||
"Track validation failed for '{} - {}': {}", track.title,
|
||||
track.artist, streamUrl.error().message));
|
||||
return Api::fail(Api::ErrorCode::ServiceUnavailable,
|
||||
@@ -564,7 +564,7 @@ namespace Echoion::Core
|
||||
}
|
||||
}
|
||||
|
||||
ECHOION_LOG_INFO(
|
||||
Void::Log::info("MusicManager", "{}",
|
||||
std::format("Queued: {} - {}", track.title, track.artist));
|
||||
|
||||
// Check if we should auto-start playback
|
||||
@@ -576,7 +576,7 @@ namespace Echoion::Core
|
||||
needToStartThread =
|
||||
!playbackThread_.joinable() && !playbackThreadRunning_;
|
||||
|
||||
ECHOION_LOG_DEBUG(std::format(
|
||||
Void::Log::debug("MusicManager", "{}", std::format(
|
||||
"queueTrack debug: shouldStart={}, "
|
||||
"needToStartThread={}, isPlaying_={}, "
|
||||
"thread_joinable={}, thread_running={}, queue_size={}",
|
||||
@@ -586,15 +586,15 @@ namespace Echoion::Core
|
||||
}
|
||||
|
||||
if (shouldStart) {
|
||||
ECHOION_LOG_INFO("Auto-starting playback for first track in queue");
|
||||
Void::Log::info("MusicManager", "{}", "Auto-starting playback for first track in queue");
|
||||
|
||||
// Check if we need to handle an old thread that's done but still
|
||||
// joinable
|
||||
if (playbackThread_.joinable() && !playbackThreadRunning_) {
|
||||
ECHOION_LOG_INFO("Joining finished playback thread before "
|
||||
Void::Log::info("MusicManager", "{}", "Joining finished playback thread before "
|
||||
"starting new one...");
|
||||
playbackThread_.join();
|
||||
ECHOION_LOG_INFO("Old thread joined");
|
||||
Void::Log::info("MusicManager", "{}", "Old thread joined");
|
||||
needToStartThread = true;
|
||||
}
|
||||
|
||||
@@ -615,7 +615,7 @@ namespace Echoion::Core
|
||||
|
||||
playbackThread_ =
|
||||
std::jthread(&MusicManager::playbackThread, this);
|
||||
ECHOION_LOG_INFO("Started playback thread for auto-play");
|
||||
Void::Log::info("MusicManager", "{}", "Started playback thread for auto-play");
|
||||
}
|
||||
|
||||
// Notify the thread to process
|
||||
@@ -660,7 +660,7 @@ namespace Echoion::Core
|
||||
}
|
||||
}
|
||||
|
||||
ECHOION_LOG_INFO(std::format("Removed track at position {}", position));
|
||||
Void::Log::info("MusicManager", "{}", std::format("Removed track at position {}", position));
|
||||
|
||||
// Publish track removed event
|
||||
emit(Api::Events::TrackRemoved{
|
||||
@@ -684,7 +684,7 @@ namespace Echoion::Core
|
||||
shuffleIndex_ = 0;
|
||||
}
|
||||
|
||||
ECHOION_LOG_INFO("Queue cleared");
|
||||
Void::Log::info("MusicManager", "{}", "Queue cleared");
|
||||
|
||||
// Publish queue cleared event
|
||||
emit(Api::Events::QueueCleared{
|
||||
@@ -735,7 +735,7 @@ namespace Echoion::Core
|
||||
}
|
||||
}
|
||||
|
||||
ECHOION_LOG_INFO(std::format("Moved track from {} to {}", from, to));
|
||||
Void::Log::info("MusicManager", "{}", std::format("Moved track from {} to {}", from, to));
|
||||
|
||||
// Publish queue reordered event
|
||||
emit(
|
||||
@@ -757,14 +757,14 @@ namespace Echoion::Core
|
||||
// Build shuffled indices for current queue
|
||||
rebuildShuffledIndices();
|
||||
shuffleIndex_ = 0;
|
||||
ECHOION_LOG_INFO(
|
||||
Void::Log::info("MusicManager", "{}",
|
||||
std::format("Shuffle enabled - queue shuffled with {} tracks",
|
||||
shuffledIndices_.size()));
|
||||
} else {
|
||||
// Clear shuffle state
|
||||
shuffledIndices_.clear();
|
||||
shuffleIndex_ = 0;
|
||||
ECHOION_LOG_INFO("Shuffle disabled");
|
||||
Void::Log::info("MusicManager", "{}", "Shuffle disabled");
|
||||
}
|
||||
|
||||
// Publish shuffle changed event
|
||||
@@ -788,7 +788,7 @@ namespace Echoion::Core
|
||||
std::shuffle(shuffledIndices_.begin(), shuffledIndices_.end(), rng_);
|
||||
shuffleIndex_ = 0;
|
||||
|
||||
ECHOION_LOG_DEBUG(std::format("Rebuilt shuffled indices: {} tracks",
|
||||
Void::Log::debug("MusicManager", "{}", std::format("Rebuilt shuffled indices: {} tracks",
|
||||
shuffledIndices_.size()));
|
||||
}
|
||||
|
||||
@@ -805,14 +805,14 @@ namespace Echoion::Core
|
||||
std::shuffle(shuffledIndices_.begin() + shuffleIndex_,
|
||||
shuffledIndices_.end(), rng_);
|
||||
|
||||
ECHOION_LOG_DEBUG(std::format("Reshuffled remaining {} tracks",
|
||||
Void::Log::debug("MusicManager", "{}", std::format("Reshuffled remaining {} tracks",
|
||||
shuffledIndices_.size() - shuffleIndex_));
|
||||
}
|
||||
|
||||
Api::Result<bool> MusicManager::toggleRepeat()
|
||||
{
|
||||
repeat_ = !repeat_;
|
||||
ECHOION_LOG_INFO(repeat_ ? "Repeat enabled" : "Repeat disabled");
|
||||
Void::Log::info("MusicManager", "{}", repeat_ ? "Repeat enabled" : "Repeat disabled");
|
||||
|
||||
// Publish repeat changed event
|
||||
emit(Api::Events::RepeatChanged{
|
||||
@@ -843,7 +843,7 @@ namespace Echoion::Core
|
||||
youTubeClient_->extractPlaylistId(playlistIdOrUrl);
|
||||
if (extractedId) {
|
||||
playlistId = *extractedId;
|
||||
ECHOION_LOG_DEBUG(std::format(
|
||||
Void::Log::debug("MusicManager", "{}", std::format(
|
||||
"Extracted playlist ID '{}' from URL", playlistId));
|
||||
} else {
|
||||
return Api::fail(Api::ErrorCode::InvalidArgument,
|
||||
@@ -861,7 +861,7 @@ namespace Echoion::Core
|
||||
playlistLoadedCount_ = 0;
|
||||
playlistTotalCount_ = 0;
|
||||
|
||||
ECHOION_LOG_INFO(
|
||||
Void::Log::info("MusicManager", "{}",
|
||||
std::format("Starting async playlist load: {}", playlistId));
|
||||
|
||||
// Publish playlist load started event
|
||||
@@ -910,7 +910,7 @@ namespace Echoion::Core
|
||||
|
||||
// Start playback immediately on first track
|
||||
if (isFirst) {
|
||||
ECHOION_LOG_INFO(
|
||||
Void::Log::info("MusicManager", "{}",
|
||||
std::format("First track resolved: {} - {}. "
|
||||
"Starting playback...",
|
||||
track.title, track.artist));
|
||||
@@ -931,7 +931,7 @@ namespace Echoion::Core
|
||||
if (!isPlaying_ && !queue_.empty()) {
|
||||
// Trigger playback start
|
||||
cv_.notify_one();
|
||||
ECHOION_LOG_INFO(
|
||||
Void::Log::info("MusicManager", "{}",
|
||||
"Playback started from playlist");
|
||||
}
|
||||
});
|
||||
@@ -942,13 +942,13 @@ namespace Echoion::Core
|
||||
// known
|
||||
[this, playlistId](size_t totalTracks) {
|
||||
playlistTotalCount_ = totalTracks;
|
||||
ECHOION_LOG_INFO(
|
||||
Void::Log::info("MusicManager", "{}",
|
||||
std::format("Playlist '{}' has {} tracks, resolving...",
|
||||
playlistId, totalTracks));
|
||||
},
|
||||
// On complete callback
|
||||
[this, &added, playlistId]() {
|
||||
ECHOION_LOG_INFO(std::format(
|
||||
Void::Log::info("MusicManager", "{}", std::format(
|
||||
"Playlist streaming complete. Added {} tracks",
|
||||
added.load()));
|
||||
playlistLoading_ = false;
|
||||
@@ -994,7 +994,7 @@ namespace Echoion::Core
|
||||
// Safety check: if playbackStartTime_ is not initialized, return base
|
||||
// position
|
||||
if (playbackStartTime_.time_since_epoch().count() == 0) {
|
||||
ECHOION_LOG_DEBUG(
|
||||
Void::Log::debug("MusicManager", "{}",
|
||||
"getPlaybackPosition: playbackStartTime_ not initialized");
|
||||
return playbackBasePosition_;
|
||||
}
|
||||
@@ -1006,7 +1006,7 @@ namespace Echoion::Core
|
||||
|
||||
// Sanity check: position shouldn't be negative or more than 24 hours
|
||||
if (position.count() < 0 || position.count() > 86400000) {
|
||||
ECHOION_LOG_WARNING(
|
||||
Void::Log::warn("MusicManager", "{}",
|
||||
std::format("getPlaybackPosition: Invalid position: {}ms",
|
||||
position.count()));
|
||||
return std::chrono::milliseconds(0);
|
||||
@@ -1049,7 +1049,7 @@ namespace Echoion::Core
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(pendingSearchMutex_);
|
||||
pendingSearches_[clientId] = results;
|
||||
ECHOION_LOG_DEBUG(std::format("Stored {} search results for client {}",
|
||||
Void::Log::debug("MusicManager", "{}", std::format("Stored {} search results for client {}",
|
||||
results.size(), clientId));
|
||||
}
|
||||
|
||||
@@ -1162,7 +1162,7 @@ namespace Echoion::Core
|
||||
rebuildShuffledIndices();
|
||||
}
|
||||
|
||||
ECHOION_LOG_INFO(
|
||||
Void::Log::info("MusicManager", "{}",
|
||||
std::format("restoreFromHotReload: shouldPreservePlayback={}, "
|
||||
"hasStreamUrl={}, isPlaying={}, hasCurrentTrack={}",
|
||||
state.shouldPreservePlayback(),
|
||||
@@ -1171,7 +1171,7 @@ namespace Echoion::Core
|
||||
state.playback.currentTrack.has_value()));
|
||||
|
||||
if (state.shouldPreservePlayback() && state.currentStreamUrl) {
|
||||
ECHOION_LOG_INFO(
|
||||
Void::Log::info("MusicManager", "{}",
|
||||
std::format("Restoring playback from position {}ms",
|
||||
state.playbackPosition.count()));
|
||||
auto openResult =
|
||||
@@ -1202,19 +1202,19 @@ namespace Echoion::Core
|
||||
}
|
||||
|
||||
cv_.notify_one();
|
||||
ECHOION_LOG_INFO("Playback restored successfully");
|
||||
Void::Log::info("MusicManager", "{}", "Playback restored successfully");
|
||||
} else {
|
||||
ECHOION_LOG_ERROR(
|
||||
Void::Log::error("MusicManager", "{}",
|
||||
std::format("Failed to seek to position {}ms: {}",
|
||||
state.playbackPosition.count(),
|
||||
seekResult.error().message));
|
||||
}
|
||||
} else {
|
||||
ECHOION_LOG_ERROR(std::format("Failed to open stream URL: {}",
|
||||
Void::Log::error("MusicManager", "{}", std::format("Failed to open stream URL: {}",
|
||||
openResult.error().message));
|
||||
}
|
||||
} else {
|
||||
ECHOION_LOG_INFO(
|
||||
Void::Log::info("MusicManager", "{}",
|
||||
std::format("Playback not restored: conditions not met "
|
||||
"(isPlaying={}, hasTrack={}, hasUrl={})",
|
||||
state.playback.isPlaying,
|
||||
@@ -1223,7 +1223,7 @@ namespace Echoion::Core
|
||||
}
|
||||
if (!currentTrack_.has_value() && !queue_.empty() &&
|
||||
hasOnlineSubscribers()) {
|
||||
ECHOION_LOG_INFO(
|
||||
Void::Log::info("MusicManager", "{}",
|
||||
"Playback not restored but queue has items, starting "
|
||||
"thread for auto-start");
|
||||
if (playbackThread_.joinable()) {
|
||||
@@ -1255,7 +1255,7 @@ namespace Echoion::Core
|
||||
currentTrack_.reset();
|
||||
}
|
||||
|
||||
ECHOION_LOG_INFO("State restored from hot reload");
|
||||
Void::Log::info("MusicManager", "{}", "State restored from hot reload");
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -1294,7 +1294,7 @@ namespace Echoion::Core
|
||||
|
||||
void MusicManager::playbackThread()
|
||||
{
|
||||
ECHOION_LOG_DEBUG("Playback thread started");
|
||||
Void::Log::debug("MusicManager", "{}", "Playback thread started");
|
||||
playbackThreadRunning_ = true;
|
||||
|
||||
// Constants for 192kHz 20ms chunks (like reference)
|
||||
@@ -1357,7 +1357,7 @@ namespace Echoion::Core
|
||||
|
||||
auto openResult = audioDecoder_->openSource(*streamUrl);
|
||||
if (!openResult) {
|
||||
ECHOION_LOG_ERROR(
|
||||
Void::Log::error("MusicManager", "{}",
|
||||
std::format("Failed to open first track: {}",
|
||||
openResult.error().message));
|
||||
lock.lock();
|
||||
@@ -1367,7 +1367,7 @@ namespace Echoion::Core
|
||||
}
|
||||
lock.lock();
|
||||
|
||||
ECHOION_LOG_INFO(std::format(
|
||||
Void::Log::info("MusicManager", "{}", std::format(
|
||||
"Auto-started playback: {} - {}",
|
||||
firstTrack.track.title, firstTrack.track.artist));
|
||||
}
|
||||
@@ -1390,7 +1390,7 @@ namespace Echoion::Core
|
||||
incomingChunk.begin(),
|
||||
incomingChunk.end());
|
||||
if (chunksSent == 0) {
|
||||
ECHOION_LOG_DEBUG(
|
||||
Void::Log::debug("MusicManager", "{}",
|
||||
std::format("First chunk received: {} samples",
|
||||
incomingChunk.size()));
|
||||
}
|
||||
@@ -1460,7 +1460,7 @@ namespace Echoion::Core
|
||||
maxSample,
|
||||
std::abs(static_cast<int>(localAudioBuffer[i])));
|
||||
}
|
||||
ECHOION_LOG_DEBUG(std::format(
|
||||
Void::Log::debug("MusicManager", "{}", std::format(
|
||||
"Audio debug: volume={:.3f}, volMult={:.3f}, "
|
||||
"nonZero={}/100, maxSample={}",
|
||||
volume_.load(), volMult, nonZeroCount, maxSample));
|
||||
@@ -1485,13 +1485,13 @@ namespace Echoion::Core
|
||||
|
||||
chunksSent++;
|
||||
if (chunksSent == 1 || chunksSent % 100 == 0) {
|
||||
ECHOION_LOG_DEBUG(
|
||||
Void::Log::debug("MusicManager", "{}",
|
||||
std::format("Sent {} chunks, buffer: {}",
|
||||
chunksSent,
|
||||
localAudioBuffer.size()));
|
||||
}
|
||||
} else if (chunksSent == 0) {
|
||||
ECHOION_LOG_WARNING("No audio callback set!");
|
||||
Void::Log::warn("MusicManager", "{}", "No audio callback set!");
|
||||
}
|
||||
|
||||
// Precision timing (like reference)
|
||||
@@ -1500,7 +1500,7 @@ namespace Echoion::Core
|
||||
} else {
|
||||
// Buffer underrun - wait for more data
|
||||
if (chunksSent == 0) {
|
||||
ECHOION_LOG_DEBUG(std::format("Waiting for data: {} < {}",
|
||||
Void::Log::debug("MusicManager", "{}", std::format("Waiting for data: {} < {}",
|
||||
localAudioBuffer.size(),
|
||||
SHORTS_PER_CHUNK));
|
||||
}
|
||||
@@ -1556,12 +1556,12 @@ namespace Echoion::Core
|
||||
}
|
||||
|
||||
if (totalFlushed > 0) {
|
||||
ECHOION_LOG_INFO(
|
||||
Void::Log::info("MusicManager", "{}",
|
||||
std::format("Playback finished with last flush, "
|
||||
"sent {} chunks, flushed {} samples",
|
||||
chunksSent, totalFlushed));
|
||||
} else {
|
||||
ECHOION_LOG_INFO(std::format(
|
||||
Void::Log::info("MusicManager", "{}", std::format(
|
||||
"Playback finished, sent {} chunks", chunksSent));
|
||||
}
|
||||
|
||||
@@ -1569,7 +1569,7 @@ namespace Echoion::Core
|
||||
|
||||
// Send low-level white noise during track transition to
|
||||
// prevent audio glitch and keep microphone active
|
||||
ECHOION_LOG_DEBUG(
|
||||
Void::Log::debug("MusicManager", "{}",
|
||||
"Sending transition noise during track transition...");
|
||||
auto transitionStart = std::chrono::steady_clock::now();
|
||||
constexpr auto MAX_TRANSITION_TIME =
|
||||
@@ -1590,7 +1590,7 @@ namespace Echoion::Core
|
||||
localAudioBuffer.insert(localAudioBuffer.end(),
|
||||
incoming.begin(),
|
||||
incoming.end());
|
||||
ECHOION_LOG_DEBUG(
|
||||
Void::Log::debug("MusicManager", "{}",
|
||||
"Next track ready, resuming playback");
|
||||
break;
|
||||
}
|
||||
@@ -1615,7 +1615,7 @@ namespace Echoion::Core
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(mutex_);
|
||||
if (!isPlaying_) {
|
||||
ECHOION_LOG_INFO(
|
||||
Void::Log::info("MusicManager", "{}",
|
||||
"Playback stopped during transition");
|
||||
break;
|
||||
}
|
||||
@@ -1625,13 +1625,13 @@ namespace Echoion::Core
|
||||
// Check if playback should continue (more tracks available)
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(mutex_);
|
||||
ECHOION_LOG_DEBUG(std::format(
|
||||
Void::Log::debug("MusicManager", "{}", std::format(
|
||||
"Playback thread: isPlaying_={}, queue_size={}, "
|
||||
"currentTrack.has_value={}",
|
||||
isPlaying_.load(), queue_.size(),
|
||||
currentTrack_.has_value()));
|
||||
if (!isPlaying_) {
|
||||
ECHOION_LOG_INFO(
|
||||
Void::Log::info("MusicManager", "{}",
|
||||
"Playback thread exiting: isPlaying_ is false");
|
||||
break; // Exit thread if no more tracks
|
||||
}
|
||||
@@ -1640,13 +1640,13 @@ namespace Echoion::Core
|
||||
// Reset for next track
|
||||
chunksSent = 0;
|
||||
next = std::chrono::steady_clock::now();
|
||||
ECHOION_LOG_DEBUG("Continuing to next track...");
|
||||
Void::Log::debug("MusicManager", "{}", "Continuing to next track...");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ECHOION_LOG_DEBUG("Playback thread exiting");
|
||||
Void::Log::debug("MusicManager", "{}", "Playback thread exiting");
|
||||
playbackThreadRunning_ = false;
|
||||
}
|
||||
|
||||
@@ -1654,20 +1654,20 @@ namespace Echoion::Core
|
||||
MusicManager::resolveQuery(const std::string& query)
|
||||
{
|
||||
if (YouTubeClient::isYouTubeUrl(query)) {
|
||||
ECHOION_LOG_DEBUG(
|
||||
Void::Log::debug("MusicManager", "{}",
|
||||
std::format("Extracting video ID from URL: {}", query));
|
||||
auto videoId = youTubeClient_->extractVideoId(query);
|
||||
if (videoId) {
|
||||
ECHOION_LOG_DEBUG(
|
||||
Void::Log::debug("MusicManager", "{}",
|
||||
std::format("Extracted video ID: '{}'", *videoId));
|
||||
return youTubeClient_->getVideoInfo(*videoId);
|
||||
} else {
|
||||
ECHOION_LOG_WARNING("Failed to extract video ID from URL");
|
||||
Void::Log::warn("MusicManager", "{}", "Failed to extract video ID from URL");
|
||||
}
|
||||
|
||||
auto playlistId = youTubeClient_->extractPlaylistId(query);
|
||||
if (playlistId) {
|
||||
ECHOION_LOG_DEBUG(
|
||||
Void::Log::debug("MusicManager", "{}",
|
||||
std::format("Extracted playlist ID: '{}'", *playlistId));
|
||||
auto playlist = youTubeClient_->getPlaylist(*playlistId);
|
||||
if (playlist && !playlist->tracks.empty()) {
|
||||
@@ -1692,26 +1692,26 @@ namespace Echoion::Core
|
||||
MusicManager::getStreamUrl(const Api::TrackInfo& track)
|
||||
{
|
||||
if (track.streamUrl) {
|
||||
ECHOION_LOG_DEBUG("Using pre-resolved stream URL");
|
||||
Void::Log::debug("MusicManager", "{}", "Using pre-resolved stream URL");
|
||||
return *track.streamUrl;
|
||||
}
|
||||
|
||||
if (track.source == Api::TrackSource::YouTube) {
|
||||
auto videoId = youTubeClient_->extractVideoId(track.originalUrl);
|
||||
if (videoId) {
|
||||
ECHOION_LOG_DEBUG(std::format(
|
||||
Void::Log::debug("MusicManager", "{}", std::format(
|
||||
"Extracting stream URL for YouTube video: {}", *videoId));
|
||||
auto url = youTubeClient_->getStreamUrl(*videoId);
|
||||
if (url) {
|
||||
ECHOION_LOG_DEBUG(
|
||||
Void::Log::debug("MusicManager", "{}",
|
||||
std::format("Got stream URL: {}", url->c_str()));
|
||||
} else {
|
||||
ECHOION_LOG_ERROR(std::format(
|
||||
Void::Log::error("MusicManager", "{}", std::format(
|
||||
"Failed to get stream URL: {}", url.error().message));
|
||||
}
|
||||
return url;
|
||||
}
|
||||
ECHOION_LOG_WARNING("Could not extract video ID from URL");
|
||||
Void::Log::warn("MusicManager", "{}", "Could not extract video ID from URL");
|
||||
}
|
||||
|
||||
return Api::fail(Api::ErrorCode::NotFound, "Could not get stream URL");
|
||||
@@ -1747,13 +1747,13 @@ namespace Echoion::Core
|
||||
isPlaying_ = false;
|
||||
currentTrack_.reset();
|
||||
audioDecoder_->closeSource();
|
||||
ECHOION_LOG_INFO("Queue empty, playback stopped");
|
||||
Void::Log::info("MusicManager", "{}", "Queue empty, playback stopped");
|
||||
return;
|
||||
}
|
||||
|
||||
// Play next track from queue
|
||||
auto nextTrack = getNextTrack();
|
||||
ECHOION_LOG_INFO(std::format("Playing next track: {} - {}",
|
||||
Void::Log::info("MusicManager", "{}", std::format("Playing next track: {} - {}",
|
||||
nextTrack.title, nextTrack.artist));
|
||||
|
||||
currentTrack_ =
|
||||
@@ -1777,7 +1777,7 @@ namespace Echoion::Core
|
||||
if (status == std::future_status::ready) {
|
||||
auto result = prefetchState_.streamUrlFuture.get();
|
||||
if (result) {
|
||||
ECHOION_LOG_INFO(
|
||||
Void::Log::info("MusicManager", "{}",
|
||||
"Using prefetched stream URL for seamless transition");
|
||||
streamUrl = *result;
|
||||
}
|
||||
@@ -1787,7 +1787,7 @@ namespace Echoion::Core
|
||||
// If prefetch not ready or failed, fetch synchronously
|
||||
if (!streamUrl) {
|
||||
if (prefetchState_.isPrefetching) {
|
||||
ECHOION_LOG_INFO("Waiting for prefetch to complete...");
|
||||
Void::Log::info("MusicManager", "{}", "Waiting for prefetch to complete...");
|
||||
auto result = prefetchState_.streamUrlFuture.get();
|
||||
if (result) {
|
||||
streamUrl = *result;
|
||||
@@ -1795,7 +1795,7 @@ namespace Echoion::Core
|
||||
}
|
||||
|
||||
if (!streamUrl) {
|
||||
ECHOION_LOG_DEBUG(
|
||||
Void::Log::debug("MusicManager", "{}",
|
||||
"No prefetched URL available, fetching synchronously");
|
||||
auto result = getStreamUrl(nextTrack);
|
||||
if (result) {
|
||||
@@ -1808,14 +1808,14 @@ namespace Echoion::Core
|
||||
audioDecoder_->closeSource();
|
||||
auto result = audioDecoder_->openSource(*streamUrl);
|
||||
if (!result) {
|
||||
ECHOION_LOG_ERROR(std::format("Failed to open next track: {}",
|
||||
Void::Log::error("MusicManager", "{}", std::format("Failed to open next track: {}",
|
||||
result.error().message));
|
||||
// Remove the failed track and try next
|
||||
queue_.erase(queue_.begin());
|
||||
onTrackFinished();
|
||||
}
|
||||
} else {
|
||||
ECHOION_LOG_ERROR("Failed to get stream URL for next track");
|
||||
Void::Log::error("MusicManager", "{}", "Failed to get stream URL for next track");
|
||||
queue_.erase(queue_.begin());
|
||||
onTrackFinished();
|
||||
}
|
||||
@@ -1906,7 +1906,7 @@ Subscriptions are persistent across server reconnects.)";
|
||||
const auto& [uid, nickname] = *clientInfo;
|
||||
bool added = subscriptionManager_->subscribe(uid, nickname);
|
||||
|
||||
ECHOION_LOG_INFO(std::format("Subscribe: client {} ({}), added={}",
|
||||
Void::Log::info("MusicManager", "{}", std::format("Subscribe: client {} ({}), added={}",
|
||||
clientId, nickname, added));
|
||||
|
||||
// If we have subscribers now and were paused due to no subscribers,
|
||||
@@ -1922,7 +1922,7 @@ Subscriptions are persistent across server reconnects.)";
|
||||
// update whisper list This ensures offline->online transitions update
|
||||
// the whisper list
|
||||
if (subscriptionChangeCallback_) {
|
||||
ECHOION_LOG_INFO(
|
||||
Void::Log::info("MusicManager", "{}",
|
||||
"Subscribe: triggering subscriptionChangeCallback");
|
||||
subscriptionChangeCallback_();
|
||||
}
|
||||
@@ -1962,7 +1962,7 @@ Subscriptions are persistent across server reconnects.)";
|
||||
|
||||
// If no online subscribers left and we're playing, pause
|
||||
if (removed && !hasOnlineSubscribers() && isPlaying_ && !isPaused_) {
|
||||
ECHOION_LOG_INFO("No online subscribers left, pausing playback");
|
||||
Void::Log::info("MusicManager", "{}", "No online subscribers left, pausing playback");
|
||||
auto result = pause();
|
||||
if (result) {
|
||||
wasPausedForNoSubscribers_ = true;
|
||||
@@ -1997,7 +1997,7 @@ Subscriptions are persistent across server reconnects.)";
|
||||
|
||||
// If no online subscribers left and we're playing, pause
|
||||
if (removed && !hasOnlineSubscribers() && isPlaying_ && !isPaused_) {
|
||||
ECHOION_LOG_INFO("No online subscribers left, pausing playback");
|
||||
Void::Log::info("MusicManager", "{}", "No online subscribers left, pausing playback");
|
||||
auto result = pause();
|
||||
if (result) {
|
||||
wasPausedForNoSubscribers_ = true;
|
||||
@@ -2027,7 +2027,7 @@ Subscriptions are persistent across server reconnects.)";
|
||||
|
||||
// Pause playback if no subscribers
|
||||
if (cleared && isPlaying_ && !isPaused_) {
|
||||
ECHOION_LOG_INFO("All subscriptions cleared, pausing playback");
|
||||
Void::Log::info("MusicManager", "{}", "All subscriptions cleared, pausing playback");
|
||||
auto result = pause();
|
||||
if (result) {
|
||||
wasPausedForNoSubscribers_ = true;
|
||||
@@ -2131,10 +2131,10 @@ Subscriptions are persistent across server reconnects.)";
|
||||
|
||||
void MusicManager::onClientConnected(uint64_t clientId)
|
||||
{
|
||||
ECHOION_LOG_INFO(std::format("onClientConnected: client {}", clientId));
|
||||
Void::Log::info("MusicManager", "{}", std::format("onClientConnected: client {}", clientId));
|
||||
|
||||
if (!subscriptionManager_ || !clientInfoCallback_) {
|
||||
ECHOION_LOG_WARNING("onClientConnected: subscriptionManager or "
|
||||
Void::Log::warn("MusicManager", "{}", "onClientConnected: subscriptionManager or "
|
||||
"clientInfoCallback not set");
|
||||
return;
|
||||
}
|
||||
@@ -2142,7 +2142,7 @@ Subscriptions are persistent across server reconnects.)";
|
||||
// Get the client's UID
|
||||
auto clientInfo = clientInfoCallback_(clientId);
|
||||
if (!clientInfo) {
|
||||
ECHOION_LOG_WARNING(std::format(
|
||||
Void::Log::warn("MusicManager", "{}", std::format(
|
||||
"onClientConnected: could not get client info for {}",
|
||||
clientId));
|
||||
return;
|
||||
@@ -2150,13 +2150,13 @@ Subscriptions are persistent across server reconnects.)";
|
||||
|
||||
const auto& [uid, nickname] = *clientInfo;
|
||||
|
||||
ECHOION_LOG_INFO(std::format(
|
||||
Void::Log::info("MusicManager", "{}", std::format(
|
||||
"onClientConnected: client {} ({}), uid={}, isSubscribed={}",
|
||||
clientId, nickname, uid, subscriptionManager_->isSubscribed(uid)));
|
||||
|
||||
// Check if this user is subscribed (in offline subscribers)
|
||||
if (subscriptionManager_->isSubscribed(uid)) {
|
||||
ECHOION_LOG_INFO(std::format(
|
||||
Void::Log::info("MusicManager", "{}", std::format(
|
||||
"Subscribed user {} ({}) connected, moving to online", nickname,
|
||||
uid));
|
||||
|
||||
@@ -2165,14 +2165,14 @@ Subscriptions are persistent across server reconnects.)";
|
||||
|
||||
// Update whisper list to include them
|
||||
if (subscriptionChangeCallback_) {
|
||||
ECHOION_LOG_INFO(
|
||||
Void::Log::info("MusicManager", "{}",
|
||||
"onClientConnected: triggering subscriptionChangeCallback");
|
||||
subscriptionChangeCallback_();
|
||||
}
|
||||
|
||||
// If we were paused due to no online subscribers, resume playback
|
||||
if (wasPausedForNoSubscribers_ && isPlaying_ && isPaused_) {
|
||||
ECHOION_LOG_INFO(
|
||||
Void::Log::info("MusicManager", "{}",
|
||||
"Online subscriber returned, resuming playback");
|
||||
auto result = resume();
|
||||
if (result) {
|
||||
@@ -2182,7 +2182,7 @@ Subscriptions are persistent across server reconnects.)";
|
||||
// If we're not playing but have tracks in queue, auto-start
|
||||
else if (!isPlaying_ && !currentTrack_.has_value() &&
|
||||
!queue_.empty()) {
|
||||
ECHOION_LOG_INFO("Online subscriber connected with tracks in "
|
||||
Void::Log::info("MusicManager", "{}", "Online subscriber connected with tracks in "
|
||||
"queue, auto-starting");
|
||||
// Notify playback thread to start
|
||||
cv_.notify_one();
|
||||
@@ -2213,7 +2213,7 @@ Subscriptions are persistent across server reconnects.)";
|
||||
|
||||
// If this was a subscribed user, update whisper list
|
||||
if (subscriptionManager_->isSubscribed(uid)) {
|
||||
ECHOION_LOG_INFO(std::format(
|
||||
Void::Log::info("MusicManager", "{}", std::format(
|
||||
"Subscribed user {} ({}) disconnected, moving to offline",
|
||||
nickname, uid));
|
||||
|
||||
@@ -2224,7 +2224,7 @@ Subscriptions are persistent across server reconnects.)";
|
||||
|
||||
// If no more online subscribers and we're playing, pause
|
||||
if (!hasOnlineSubscribers() && isPlaying_ && !isPaused_) {
|
||||
ECHOION_LOG_INFO(
|
||||
Void::Log::info("MusicManager", "{}",
|
||||
"No online subscribers left, pausing playback");
|
||||
auto result = pause();
|
||||
if (result) {
|
||||
@@ -2253,7 +2253,7 @@ Subscriptions are persistent across server reconnects.)";
|
||||
auto tempPath = cacheDir / std::format("audio_{}.tmp", timestamp);
|
||||
|
||||
// Download the file
|
||||
ECHOION_LOG_INFO(
|
||||
Void::Log::info("MusicManager", "{}",
|
||||
std::format("Downloading audio from: {}...", url.substr(0, 60)));
|
||||
|
||||
auto response = networkClient_->get(url);
|
||||
@@ -2280,7 +2280,7 @@ Subscriptions are persistent across server reconnects.)";
|
||||
file.write(response->body.data(), response->body.size());
|
||||
file.close();
|
||||
|
||||
ECHOION_LOG_INFO(std::format("Downloaded {} bytes to {}",
|
||||
Void::Log::info("MusicManager", "{}", std::format("Downloaded {} bytes to {}",
|
||||
response->body.size(), tempPath.string()));
|
||||
|
||||
return tempPath.string();
|
||||
@@ -2294,10 +2294,10 @@ Subscriptions are persistent across server reconnects.)";
|
||||
std::error_code ec;
|
||||
std::filesystem::remove(filepath, ec);
|
||||
if (ec) {
|
||||
ECHOION_LOG_WARNING(std::format("Failed to remove temp file {}: {}",
|
||||
Void::Log::warn("MusicManager", "{}", std::format("Failed to remove temp file {}: {}",
|
||||
filepath, ec.message()));
|
||||
} else {
|
||||
ECHOION_LOG_DEBUG(
|
||||
Void::Log::debug("MusicManager", "{}",
|
||||
std::format("Cleaned up temp file: {}", filepath));
|
||||
}
|
||||
}
|
||||
@@ -2322,7 +2322,7 @@ Subscriptions are persistent across server reconnects.)";
|
||||
auto streamInfo = audioDecoder_->getStreamInfo();
|
||||
|
||||
if (!streamInfo) {
|
||||
ECHOION_LOG_DEBUG("Prefetch: No stream info available");
|
||||
Void::Log::debug("MusicManager", "{}", "Prefetch: No stream info available");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2332,7 +2332,7 @@ Subscriptions are persistent across server reconnects.)";
|
||||
if (streamInfo->duration <= PREFETCH_THRESHOLD) {
|
||||
bool shouldPrefetch = position >= std::chrono::seconds(2);
|
||||
if (shouldPrefetch) {
|
||||
ECHOION_LOG_DEBUG(std::format("Prefetch: Short track ({}s), "
|
||||
Void::Log::debug("MusicManager", "{}", std::format("Prefetch: Short track ({}s), "
|
||||
"position {}s - should prefetch",
|
||||
streamInfo->duration.count(),
|
||||
position.count()));
|
||||
@@ -2348,7 +2348,7 @@ Subscriptions are persistent across server reconnects.)";
|
||||
// Log when we're getting close to prefetch threshold
|
||||
if (timeRemaining <= std::chrono::seconds(20) &&
|
||||
timeRemaining > std::chrono::seconds(0)) {
|
||||
ECHOION_LOG_DEBUG(std::format(
|
||||
Void::Log::debug("MusicManager", "{}", std::format(
|
||||
"Prefetch: Time remaining {}s, threshold {}s - {}",
|
||||
std::chrono::duration_cast<std::chrono::seconds>(timeRemaining)
|
||||
.count(),
|
||||
@@ -2368,7 +2368,7 @@ Subscriptions are persistent across server reconnects.)";
|
||||
return; // Already prefetching
|
||||
}
|
||||
|
||||
ECHOION_LOG_INFO("Starting prefetch of next track stream URL");
|
||||
Void::Log::info("MusicManager", "{}", "Starting prefetch of next track stream URL");
|
||||
|
||||
// Get next track info (copy to avoid holding lock during async
|
||||
// operation)
|
||||
@@ -2394,9 +2394,9 @@ Subscriptions are persistent across server reconnects.)";
|
||||
[this, nextTrack]() -> Api::Result<std::string> {
|
||||
auto result = getStreamUrl(nextTrack);
|
||||
if (result) {
|
||||
ECHOION_LOG_INFO("Prefetch completed successfully");
|
||||
Void::Log::info("MusicManager", "{}", "Prefetch completed successfully");
|
||||
} else {
|
||||
ECHOION_LOG_WARNING(std::format("Prefetch failed: {}",
|
||||
Void::Log::warn("MusicManager", "{}", std::format("Prefetch failed: {}",
|
||||
result.error().message));
|
||||
}
|
||||
return result;
|
||||
@@ -2421,7 +2421,7 @@ Subscriptions are persistent across server reconnects.)";
|
||||
auto chunksNeeded = duration.count() / CHUNK_MS;
|
||||
std::vector<short> silenceChunk(SHORTS_PER_CHUNK, 0);
|
||||
|
||||
ECHOION_LOG_DEBUG(
|
||||
Void::Log::debug("MusicManager", "{}",
|
||||
std::format("Generating {}ms of transition silence ({} chunks)",
|
||||
duration.count(), chunksNeeded));
|
||||
|
||||
|
||||
Reference in new issue
Block a user