mirror of
https://github.com/clangen/musikcube.git
synced 2024-10-02 04:52:32 +00:00
Added IPlaybackService::ReloadOutput(). Playback is no longer reset when
the selected output device changes -- it now picks up where it left off.
This commit is contained in:
parent
c451c6a5be
commit
b0cfc893ff
@ -580,6 +580,25 @@ void PlaybackService::Play(const musik::core::sdk::ITrackList* source, size_t in
|
||||
}
|
||||
}
|
||||
|
||||
void PlaybackService::ReloadOutput() {
|
||||
auto state = this->GetPlaybackState();
|
||||
auto index = this->GetIndex();
|
||||
double time = this->GetPosition();
|
||||
this->Stop();
|
||||
this->transport.ReloadOutput();
|
||||
|
||||
if (index != NO_POSITION) {
|
||||
this->Play(index);
|
||||
if (time > 0.0f) {
|
||||
this->transport.SetPosition(time);
|
||||
}
|
||||
|
||||
if (state == PlaybackPaused) {
|
||||
this->transport.Pause();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PlaybackService::CopyTo(TrackList& target) {
|
||||
std::unique_lock<std::recursive_mutex> lock(this->playlistMutex);
|
||||
target.CopyFrom(this->playlist);
|
||||
|
@ -105,6 +105,7 @@ namespace musik { namespace core { namespace audio {
|
||||
virtual musik::core::sdk::ITrackListEditor* EditPlaylist() override;
|
||||
virtual musik::core::sdk::TimeChangeMode GetTimeChangeMode() override;
|
||||
virtual void SetTimeChangeMode(musik::core::sdk::TimeChangeMode) override;
|
||||
virtual void ReloadOutput() override;
|
||||
|
||||
/* TODO: include in SDK? */
|
||||
virtual bool HotSwap(const TrackList& source, size_t index = 0);
|
||||
|
@ -232,7 +232,10 @@ void Player::SetPosition(double seconds) {
|
||||
std::unique_lock<std::mutex> queueLock(this->queueMutex);
|
||||
|
||||
if (this->stream) {
|
||||
seconds = std::min(this->stream->GetDuration(), seconds);
|
||||
auto duration = this->stream->GetDuration();
|
||||
if (duration > 0.0f) {
|
||||
seconds = std::min(duration, seconds);
|
||||
}
|
||||
}
|
||||
|
||||
this->seekToPosition.store(std::max(0.0, seconds));
|
||||
|
@ -85,6 +85,9 @@ namespace musik { namespace core { namespace sdk {
|
||||
/* sdk v5 */
|
||||
virtual musik::core::sdk::TimeChangeMode GetTimeChangeMode() = 0;
|
||||
virtual void SetTimeChangeMode(musik::core::sdk::TimeChangeMode) = 0;
|
||||
|
||||
/* sdk v13 */
|
||||
virtual void ReloadOutput() = 0;
|
||||
};
|
||||
|
||||
} } }
|
||||
|
@ -134,5 +134,5 @@ namespace musik {
|
||||
static const char* ExternalId = "external_id";
|
||||
}
|
||||
|
||||
static const int SdkVersion = 12;
|
||||
static const int SdkVersion = 13;
|
||||
} } }
|
||||
|
@ -207,7 +207,7 @@ void SettingsLayout::OnOutputDriverDropdownActivated(cursespp::TextLabel* label)
|
||||
|
||||
if (currentName != newName) {
|
||||
this->LoadPreferences();
|
||||
this->transport.ReloadOutput();
|
||||
this->playback.ReloadOutput();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -218,7 +218,7 @@ void SettingsLayout::OnOutputDeviceDropdownActivated(cursespp::TextLabel* label)
|
||||
std::string newName = getOutputDeviceName();
|
||||
if (currentName != newName) {
|
||||
this->LoadPreferences();
|
||||
this->transport.ReloadOutput();
|
||||
this->playback.ReloadOutput();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user