making WEB

Signed-off-by: faumaray <faumaray@gmail.com>
This commit is contained in:
faumaray committed 2026-07-11 00:45:17 +03:00
1 parent d146f11f02
commit 5c036d91fb
72 files changed
+5875 -1243

No files matched your search

@@ -63,9 +63,9 @@ namespace Echoion::Core
virtual void onLocalFileDone(const std::string& path) = 0;
// A track failed to resolve or open (before the engine advanced
// past it). Called on the engine thread.
virtual void
onPlaybackError(const Api::Error& error,
const std::optional<Api::QueueEntry>& entry) = 0;
virtual void onPlaybackError(
const Api::Error& error,
const std::optional<Api::QueueEntry>& entry) = 0;
};
// Real-time playback engine with gapless track transitions.
@@ -86,9 +86,13 @@ namespace Echoion::Core
static constexpr int CHUNK_MS = 20;
static constexpr size_t SHORTS_PER_CHUNK =
(SAMPLE_RATE * CHANNELS * CHUNK_MS) / 1000;
static constexpr auto PREFETCH_THRESHOLD =
std::chrono::seconds(15);
static constexpr auto PREFETCH_THRESHOLD = std::chrono::seconds(15);
static constexpr int MAX_CONSECUTIVE_FAILURES = 5;
// Grace while a download-to-file retry is in flight. Must cover
// YouTubeClient::downloadAudioToFile's 180s wait — the normal
// resolve grace (bot.trackTimeout, ~10s) would skip the track
// long before the download lands.
static constexpr int64_t DOWNLOAD_GRACE_MS = 200'000;
// How long the engine emits silence waiting for a late resolve
// before it gives up on the track and advances. Configurable via
@@ -119,8 +123,8 @@ namespace Echoion::Core
explicit PlaybackEngine(IPlaybackHost& host);
~PlaybackEngine();
Api::Result<void> initialize(
const std::optional<Void::Net::ProxyConfig>& proxy);
Api::Result<void>
initialize(const std::optional<Void::Net::ProxyConfig>& proxy);
void shutdown();
void setProxyConfig(
@@ -171,10 +175,14 @@ namespace Echoion::Core
std::string url;
bool isLocalFile = false;
};
struct CmdStart {};
struct CmdPause {};
struct CmdResume {};
struct CmdStop {};
struct CmdStart {
};
struct CmdPause {
};
struct CmdResume {
};
struct CmdStop {
};
struct CmdSkip {
uint32_t count = 1;
};
@@ -188,8 +196,8 @@ namespace Echoion::Core
bool paused = false;
};
using Command =
std::variant<CmdPlayNow, CmdStart, CmdPause, CmdResume,
CmdStop, CmdSkip, CmdSeek, CmdRestore>;
std::variant<CmdPlayNow, CmdStart, CmdPause, CmdResume, CmdStop,
CmdSkip, CmdSeek, CmdRestore>;
void post(Command cmd);
@@ -202,10 +210,10 @@ namespace Echoion::Core
struct DecoderSlot {
enum class State {
Idle, // nothing assigned
Idle, // nothing assigned
Resolving, // resolveFuture in flight
Warming, // decoder open, pre-filling its queue
Active, // currently feeding the ring buffer
Active, // currently feeding the ring buffer
};
State state = State::Idle;
@@ -268,7 +276,9 @@ namespace Echoion::Core
void clearFade()
{
fadeTail_.clear();
fadePos_ = 0;
fadeTailPos_ = 0;
fadeEnvPos_ = 0;
fadeIncomingStarved_ = false;
}
// AGC gain for one chunk (updates the internal RMS/gain state).
[[nodiscard]] float agcGainFor(std::size_t samples);
@@ -302,8 +312,15 @@ namespace Echoion::Core
// Crossfade state (engine thread only): the outgoing track's
// remaining PCM, mixed into the incoming track equal-power.
// The tail cursor and the envelope advance independently: the
// tail plays continuously, while the envelope only progresses as
// incoming audio is actually delivered — so a network-starved
// incoming stream stretches the fade instead of being chopped
// against a racing envelope.
std::vector<short> fadeTail_;
std::size_t fadePos_ = 0;
std::size_t fadeTailPos_ = 0;
std::size_t fadeEnvPos_ = 0;
bool fadeIncomingStarved_ = false;
// AGC state (engine thread only): EMA of mean-square level and
// the current smoothed gain in dB.