feat: enqueue streams in running player

This commit is contained in:
2026-10-22 16:03:56 +02:00
parent ac8e284d80
commit 6a4afc9f0e
17 changed files with 416 additions and 61 deletions
+9 -10
View File
@@ -197,7 +197,7 @@ struct Player {
PlayerStatus status = PLAYER_EMPTY;
bool previewShown = false;
std::array<char, 512> error{};
std::unique_ptr<playback::ProgressReports> reporter;
const std::unique_ptr<playback::ProgressReports> reporter = std::make_unique<playback::ProgressReports>();
bool remoteReporting = false;
std::thread worker;
@@ -1429,10 +1429,10 @@ bool player_set_progress_file(Player *player, const char *path, char *error) {
try {
if (!player || !path || !*path) throw std::runtime_error("A progress file path is required");
std::lock_guard<std::mutex> lock(player->mutex);
if (player->reporter || player->stopping.load(std::memory_order_relaxed) ||
if (player->stopping.load(std::memory_order_relaxed) ||
player->state.status != PLAYER_EMPTY || !player->commands.empty())
throw std::runtime_error("Progress reporting must be initialized once, before opening media");
player->reporter = std::make_unique<playback::ProgressReports>(path);
player->reporter->setSingleFile(path);
return true;
} catch (const std::exception &failure) {
if (error) copyError(error, failure.what());
@@ -1441,16 +1441,15 @@ bool player_set_progress_file(Player *player, const char *path, char *error) {
}
return false;
}
bool player_register_progress_file(Player *player, const char *identity, const char *path, char *error) {
bool player_register_progress_files(Player *player, const char *const *identities,
const char *const *paths, int count, char *error) {
if (error) error[0] = '\0';
try {
if (!player || !identity || !path) throw std::runtime_error("Queue progress identity and path are required");
if (!player) throw std::runtime_error("A player is required for queue progress registration");
std::lock_guard<std::mutex> lock(player->mutex);
if (player->stopping.load(std::memory_order_relaxed) ||
player->state.status != PLAYER_EMPTY || !player->commands.empty())
throw std::runtime_error("Queue reports must be registered before opening media");
if (!player->reporter) player->reporter = std::make_unique<playback::ProgressReports>();
player->reporter->registerFile(identity, path);
if (player->stopping.load(std::memory_order_relaxed))
throw std::runtime_error("Cannot register queue reports while the player is stopping");
player->reporter->registerFiles(identities, paths, count);
return true;
} catch (const std::exception &failure) {
if (error) copyError(error, failure.what());