Added configurable track query timeout for use by PlaybackService.

This commit is contained in:
casey langen 2020-10-30 22:35:28 -07:00
parent a12134c610
commit a498ef93ad
4 changed files with 11 additions and 8 deletions

View File

@ -60,12 +60,6 @@ using musik::core::ILibraryPtr;
using musik::core::audio::ITransport;
using Editor = PlaybackService::Editor;
/* internally PlaybackService leverages a message queue for synchronization;
tracks are a special in that they are heavy-weight so aggressively exjected
from caches... sometimes we may have to query for them. if they take more than
the specified timeout we consider it a failure and stop playback. */
static const size_t kTrackTimeoutMs = 3000;
#define NO_POSITION (size_t) -1
#define START_OVER (size_t) -2
@ -140,6 +134,12 @@ static inline void savePreferences(
prefs->SetInt(keys::TimeChangeMode, playback.GetTimeChangeMode());
}
/* internally PlaybackService leverages a message queue for synchronization;
tracks are a special in that they are heavy-weight so aggressively exjected
from caches... sometimes we may have to query for them. if they take more than
the specified timeout we consider it a failure and stop playback. */
#define TRACK_TIMEOUT_MS() (size_t) this->appPrefs->GetInt(keys::PlaybackTrackQueryTimeoutMs, 5000)
PlaybackService::PlaybackService(
IMessageQueue& messageQueue,
ILibraryPtr library,
@ -853,7 +853,7 @@ ITrack* PlaybackService::GetTrack(size_t index) {
const size_t count = this->playlist.Count();
if (count && index < this->playlist.Count()) {
auto track = this->playlist.GetWithTimeout(index, kTrackTimeoutMs * 10);
auto track = this->playlist.GetWithTimeout(index, TRACK_TIMEOUT_MS() * 10);
if (track) {
return track->GetSdkValue();
}
@ -888,7 +888,7 @@ TrackPtr PlaybackService::TrackAtIndexWithTimeout(size_t index) {
return TrackPtr();
}
return this->playlist.GetWithTimeout(index, kTrackTimeoutMs);
return this->playlist.GetWithTimeout(index, TRACK_TIMEOUT_MS());
}
Editor PlaybackService::Edit() {

View File

@ -66,6 +66,7 @@ namespace musik { namespace core { namespace prefs {
const std::string keys::DisableAlbumArtistFallback = "DisableAlbumArtistFallback";
const std::string keys::AuddioApiToken = "AuddioApiToken";
const std::string keys::LibraryType = "LibraryType";
const std::string keys::PlaybackTrackQueryTimeoutMs = "PlaybackTrackQueryTimeoutMs";
const std::string keys::RemoteLibraryHostname = "RemoteLibraryHostname";
const std::string keys::RemoteLibraryWssPort = "RemoteLibraryWssPort";
const std::string keys::RemoteLibraryHttpPort = "RemoteLibraryHttpPort";

View File

@ -70,6 +70,7 @@ namespace musik { namespace core { namespace prefs {
extern const std::string DisableAlbumArtistFallback;
extern const std::string AuddioApiToken;
extern const std::string LibraryType;
extern const std::string PlaybackTrackQueryTimeoutMs;
extern const std::string RemoteLibraryHostname;
extern const std::string RemoteLibraryWssPort;
extern const std::string RemoteLibraryHttpPort;

View File

@ -119,6 +119,7 @@ static inline std::shared_ptr<ISchema> AdvancedSettingsSchema() {
#endif
schema->AddBool(cube::prefs::keys::AutoHideCommandBar, false);
schema->AddInt(core::prefs::keys::RemoteLibraryLatencyTimeoutMs, 5000);
schema->AddInt(core::prefs::keys::PlaybackTrackQueryTimeoutMs, 5000);
schema->AddBool(core::prefs::keys::AsyncTrackListQueries, true);
schema->AddBool(cube::prefs::keys::DisableRatingColumn, false);
schema->AddBool(cube::prefs::keys::DisableWindowTitleUpdates, false);