mirror of
https://github.com/clangen/musikcube.git
synced 2025-03-29 19:20:28 +00:00
Merge remote-tracking branch 'origin/clangen/enum-cleanup' into master
This commit is contained in:
commit
8737abc0ec
@ -50,7 +50,7 @@ static std::string TAG = "CrossfadeTransport";
|
||||
|
||||
CrossfadeTransport::CrossfadeTransport()
|
||||
: volume(1.0)
|
||||
, playbackState(PlaybackStopped)
|
||||
, playbackState(PlaybackState::Stopped)
|
||||
, muted(false)
|
||||
, crossfader(*this)
|
||||
, active(*this, crossfader)
|
||||
@ -109,7 +109,7 @@ void CrossfadeTransport::Start(const std::string& uri, Gain gain, StartMode mode
|
||||
}
|
||||
}
|
||||
|
||||
this->RaiseStreamEvent(StreamBuffering, this->active.player);
|
||||
this->RaiseStreamEvent(StreamState::Buffering, this->active.player);
|
||||
}
|
||||
|
||||
std::string CrossfadeTransport::Uri() {
|
||||
@ -129,7 +129,7 @@ void CrossfadeTransport::StopImmediately() {
|
||||
this->next.Stop();
|
||||
}
|
||||
|
||||
this->SetPlaybackState(PlaybackStopped);
|
||||
this->SetPlaybackState(PlaybackState::Stopped);
|
||||
}
|
||||
|
||||
void CrossfadeTransport::Stop() {
|
||||
@ -139,7 +139,7 @@ void CrossfadeTransport::Stop() {
|
||||
this->next.Reset();
|
||||
}
|
||||
|
||||
this->SetPlaybackState(PlaybackStopped);
|
||||
this->SetPlaybackState(PlaybackState::Stopped);
|
||||
}
|
||||
|
||||
bool CrossfadeTransport::Pause() {
|
||||
@ -150,7 +150,7 @@ bool CrossfadeTransport::Pause() {
|
||||
}
|
||||
|
||||
if (this->active.player) {
|
||||
this->SetPlaybackState(PlaybackPaused);
|
||||
this->SetPlaybackState(PlaybackState::Paused);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -165,7 +165,7 @@ bool CrossfadeTransport::Resume() {
|
||||
}
|
||||
|
||||
if (this->active.player) {
|
||||
this->SetPlaybackState(PlaybackPlaying);
|
||||
this->SetPlaybackState(PlaybackState::Playing);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -187,8 +187,8 @@ void CrossfadeTransport::SetPosition(double seconds) {
|
||||
Lock lock(this->stateMutex);
|
||||
|
||||
if (this->active.player) {
|
||||
if (this->playbackState != PlaybackPlaying) {
|
||||
this->SetPlaybackState(PlaybackPlaying);
|
||||
if (this->playbackState != PlaybackState::Playing) {
|
||||
this->SetPlaybackState(PlaybackState::Playing);
|
||||
}
|
||||
this->active.player->SetPosition(seconds);
|
||||
}
|
||||
@ -291,18 +291,18 @@ void CrossfadeTransport::OnPlayerBuffered(Player* player) {
|
||||
}
|
||||
|
||||
if (player == this->active.player) {
|
||||
this->RaiseStreamEvent(StreamBuffered, player);
|
||||
this->SetPlaybackState(PlaybackPrepared);
|
||||
this->RaiseStreamEvent(StreamState::Buffered, player);
|
||||
this->SetPlaybackState(PlaybackState::Prepared);
|
||||
}
|
||||
}
|
||||
|
||||
void CrossfadeTransport::OnPlayerStarted(Player* player) {
|
||||
this->RaiseStreamEvent(StreamPlaying, player);
|
||||
this->SetPlaybackState(PlaybackPlaying);
|
||||
this->RaiseStreamEvent(StreamState::Playing, player);
|
||||
this->SetPlaybackState(PlaybackState::Playing);
|
||||
}
|
||||
|
||||
void CrossfadeTransport::OnPlayerFinished(Player* player) {
|
||||
this->RaiseStreamEvent(StreamFinished, player);
|
||||
this->RaiseStreamEvent(StreamState::Finished, player);
|
||||
|
||||
Lock lock(this->stateMutex);
|
||||
|
||||
@ -334,12 +334,12 @@ void CrossfadeTransport::OnPlayerOpenFailed(Player* player) {
|
||||
next.Reset();
|
||||
}
|
||||
}
|
||||
this->RaiseStreamEvent(StreamOpenFailed, player);
|
||||
this->RaiseStreamEvent(StreamState::OpenFailed, player);
|
||||
this->Stop();
|
||||
}
|
||||
|
||||
void CrossfadeTransport::OnPlayerDestroying(Player* player) {
|
||||
this->RaiseStreamEvent(StreamDestroyed, player);
|
||||
this->RaiseStreamEvent(StreamState::Destroyed, player);
|
||||
}
|
||||
|
||||
void CrossfadeTransport::OnPlayerMixPoint(Player* player, int id, double time) {
|
||||
@ -364,7 +364,7 @@ void CrossfadeTransport::OnPlayerMixPoint(Player* player, int id, double time) {
|
||||
}
|
||||
|
||||
if (stopped) {
|
||||
this->SetPlaybackState(PlaybackStopped);
|
||||
this->SetPlaybackState(PlaybackState::Stopped);
|
||||
}
|
||||
}
|
||||
|
||||
@ -383,7 +383,7 @@ void CrossfadeTransport::OnCrossfaderEmptied() {
|
||||
}
|
||||
}
|
||||
|
||||
void CrossfadeTransport::SetPlaybackState(int state) {
|
||||
void CrossfadeTransport::SetPlaybackState(PlaybackState state) {
|
||||
bool changed = false;
|
||||
|
||||
{
|
||||
@ -397,7 +397,7 @@ void CrossfadeTransport::SetPlaybackState(int state) {
|
||||
}
|
||||
}
|
||||
|
||||
void CrossfadeTransport::RaiseStreamEvent(int type, Player* player) {
|
||||
void CrossfadeTransport::RaiseStreamEvent(musik::core::sdk::StreamState type, Player* player) {
|
||||
bool eventIsFromActivePlayer = false;
|
||||
{
|
||||
Lock lock(this->stateMutex);
|
||||
@ -441,7 +441,7 @@ void CrossfadeTransport::PlayerContext::Reset(
|
||||
this->startImmediate = false;
|
||||
|
||||
if (this->player && this->output) {
|
||||
this->transport.RaiseStreamEvent(StreamDestroyed, this->player);
|
||||
this->transport.RaiseStreamEvent(StreamState::Destroyed, this->player);
|
||||
this->player->Detach(&this->transport);
|
||||
if (this->started && this->canFade) {
|
||||
crossfader.Cancel(
|
||||
@ -502,7 +502,7 @@ void CrossfadeTransport::PlayerContext::Start(double transportVolume) {
|
||||
void CrossfadeTransport::PlayerContext::Stop() {
|
||||
if (this->output && this->player) {
|
||||
this->output->Stop();
|
||||
this->transport.RaiseStreamEvent(StreamDestroyed, this->player);
|
||||
this->transport.RaiseStreamEvent(StreamState::Destroyed, this->player);
|
||||
this->player->Detach(&this->transport);
|
||||
this->player->Destroy();
|
||||
}
|
||||
|
@ -125,8 +125,8 @@ namespace musik { namespace core { namespace audio {
|
||||
Crossfader& crossfader;
|
||||
};
|
||||
|
||||
void RaiseStreamEvent(int type, Player* player);
|
||||
void SetPlaybackState(int state);
|
||||
void RaiseStreamEvent(musik::core::sdk::StreamState type, Player* player);
|
||||
void SetPlaybackState(musik::core::sdk::PlaybackState state);
|
||||
|
||||
void OnCrossfaderEmptied();
|
||||
|
||||
|
@ -47,7 +47,7 @@ static std::string TAG = "GaplessTransport";
|
||||
|
||||
GaplessTransport::GaplessTransport()
|
||||
: volume(1.0)
|
||||
, playbackState(PlaybackStopped)
|
||||
, playbackState(PlaybackState::Stopped)
|
||||
, activePlayer(nullptr)
|
||||
, nextPlayer(nullptr)
|
||||
, nextCanStart(false)
|
||||
@ -177,7 +177,7 @@ void GaplessTransport::StopInternal(
|
||||
/* if we know we're starting another track immediately, suppress
|
||||
the stop event. this functionality is not available to the public
|
||||
interface, it's an internal optimization */
|
||||
this->SetPlaybackState(PlaybackStopped);
|
||||
this->SetPlaybackState(PlaybackState::Stopped);
|
||||
}
|
||||
}
|
||||
|
||||
@ -187,7 +187,7 @@ bool GaplessTransport::Pause() {
|
||||
this->output->Pause();
|
||||
|
||||
if (this->activePlayer) {
|
||||
this->SetPlaybackState(PlaybackPaused);
|
||||
this->SetPlaybackState(PlaybackState::Paused);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -208,7 +208,7 @@ bool GaplessTransport::Resume() {
|
||||
}
|
||||
|
||||
if (this->activePlayer) {
|
||||
this->SetPlaybackState(PlaybackPlaying);
|
||||
this->SetPlaybackState(PlaybackState::Playing);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -230,8 +230,8 @@ void GaplessTransport::SetPosition(double seconds) {
|
||||
LockT lock(this->stateMutex);
|
||||
|
||||
if (this->activePlayer) {
|
||||
if (this->playbackState != PlaybackPlaying) {
|
||||
this->SetPlaybackState(PlaybackPlaying);
|
||||
if (this->playbackState != PlaybackState::Playing) {
|
||||
this->SetPlaybackState(PlaybackState::Playing);
|
||||
}
|
||||
this->activePlayer->SetPosition(seconds);
|
||||
}
|
||||
@ -284,14 +284,14 @@ void GaplessTransport::SetNextCanStart(bool nextCanStart) {
|
||||
|
||||
void GaplessTransport::OnPlayerBuffered(Player* player) {
|
||||
if (player == this->activePlayer) {
|
||||
this->RaiseStreamEvent(StreamBuffered, player);
|
||||
this->SetPlaybackState(PlaybackPrepared);
|
||||
this->RaiseStreamEvent(StreamState::Buffered, player);
|
||||
this->SetPlaybackState(PlaybackState::Prepared);
|
||||
}
|
||||
}
|
||||
|
||||
void GaplessTransport::OnPlayerStarted(Player* player) {
|
||||
this->RaiseStreamEvent(StreamPlaying, player);
|
||||
this->SetPlaybackState(PlaybackPlaying);
|
||||
this->RaiseStreamEvent(StreamState::Playing, player);
|
||||
this->SetPlaybackState(PlaybackState::Playing);
|
||||
}
|
||||
|
||||
void GaplessTransport::OnPlayerAlmostEnded(Player* player) {
|
||||
@ -307,11 +307,11 @@ void GaplessTransport::OnPlayerAlmostEnded(Player* player) {
|
||||
}
|
||||
}
|
||||
|
||||
this->RaiseStreamEvent(StreamAlmostDone, player);
|
||||
this->RaiseStreamEvent(StreamState::AlmostDone, player);
|
||||
}
|
||||
|
||||
void GaplessTransport::OnPlayerFinished(Player* player) {
|
||||
this->RaiseStreamEvent(StreamFinished, player);
|
||||
this->RaiseStreamEvent(StreamState::Finished, player);
|
||||
|
||||
bool stopped = false;
|
||||
|
||||
@ -355,8 +355,8 @@ void GaplessTransport::OnPlayerOpenFailed(Player* player) {
|
||||
}
|
||||
}
|
||||
if (raiseEvents) {
|
||||
this->RaiseStreamEvent(StreamOpenFailed, player);
|
||||
this->SetPlaybackState(PlaybackStopped);
|
||||
this->RaiseStreamEvent(StreamState::OpenFailed, player);
|
||||
this->SetPlaybackState(PlaybackState::Stopped);
|
||||
}
|
||||
}
|
||||
|
||||
@ -369,7 +369,7 @@ void GaplessTransport::OnPlayerDestroying(Player *player) {
|
||||
}
|
||||
}
|
||||
|
||||
void GaplessTransport::SetPlaybackState(int state) {
|
||||
void GaplessTransport::SetPlaybackState(PlaybackState state) {
|
||||
bool changed = false;
|
||||
|
||||
{
|
||||
@ -383,7 +383,7 @@ void GaplessTransport::SetPlaybackState(int state) {
|
||||
}
|
||||
}
|
||||
|
||||
void GaplessTransport::RaiseStreamEvent(int type, Player* player) {
|
||||
void GaplessTransport::RaiseStreamEvent(StreamState type, Player* player) {
|
||||
bool eventIsFromActivePlayer = false;
|
||||
{
|
||||
LockT lock(this->stateMutex);
|
||||
@ -402,7 +402,7 @@ void GaplessTransport::ResetNextPlayer() {
|
||||
if (this->nextPlayer) {
|
||||
this->nextPlayer->Detach(this);
|
||||
this->nextPlayer->Destroy();
|
||||
this->RaiseStreamEvent(StreamDestroyed, this->nextPlayer);
|
||||
this->RaiseStreamEvent(StreamState::Destroyed, this->nextPlayer);
|
||||
this->nextPlayer = nullptr;
|
||||
}
|
||||
}
|
||||
@ -411,7 +411,7 @@ void GaplessTransport::ResetActivePlayer() {
|
||||
if (this->activePlayer) {
|
||||
this->activePlayer->Detach(this);
|
||||
this->activePlayer->Destroy();
|
||||
this->RaiseStreamEvent(StreamDestroyed, this->activePlayer);
|
||||
this->RaiseStreamEvent(StreamState::Destroyed, this->activePlayer);
|
||||
this->activePlayer = nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -90,8 +90,8 @@ namespace musik { namespace core { namespace audio {
|
||||
|
||||
void SetNextCanStart(bool nextCanStart);
|
||||
|
||||
void RaiseStreamEvent(int type, Player* player);
|
||||
void SetPlaybackState(int state);
|
||||
void RaiseStreamEvent(musik::core::sdk::StreamState type, Player* player);
|
||||
void SetPlaybackState(musik::core::sdk::PlaybackState state);
|
||||
|
||||
virtual void OnPlayerStarted(Player* player);
|
||||
virtual void OnPlayerBuffered(Player* player);
|
||||
|
@ -49,8 +49,8 @@ namespace musik { namespace core { namespace audio {
|
||||
Immediate = 0, Wait = 1
|
||||
};
|
||||
|
||||
sigslot::signal2<int, std::string> StreamEvent;
|
||||
sigslot::signal1<int> PlaybackEvent;
|
||||
sigslot::signal2<musik::core::sdk::StreamState, std::string> StreamEvent;
|
||||
sigslot::signal1<musik::core::sdk::PlaybackState> PlaybackEvent;
|
||||
sigslot::signal0<> VolumeChanged;
|
||||
sigslot::signal1<double> TimeChanged;
|
||||
|
||||
|
@ -167,11 +167,11 @@ StreamState MasterTransport::GetStreamState() {
|
||||
return this->transport->GetStreamState();
|
||||
}
|
||||
|
||||
void MasterTransport::OnStreamEvent(int type, std::string url) {
|
||||
void MasterTransport::OnStreamEvent(musik::core::sdk::StreamState type, std::string url) {
|
||||
this->StreamEvent(type, url);
|
||||
}
|
||||
|
||||
void MasterTransport::OnPlaybackEvent(int type) {
|
||||
void MasterTransport::OnPlaybackEvent(musik::core::sdk::PlaybackState type) {
|
||||
this->PlaybackEvent(type);
|
||||
}
|
||||
|
||||
|
@ -78,8 +78,8 @@ namespace musik { namespace core { namespace audio {
|
||||
Type GetType();
|
||||
|
||||
private:
|
||||
void OnStreamEvent(int type, std::string url);
|
||||
void OnPlaybackEvent(int type);
|
||||
void OnStreamEvent(musik::core::sdk::StreamState type, std::string url);
|
||||
void OnPlaybackEvent(musik::core::sdk::PlaybackState type);
|
||||
void OnVolumeChanged();
|
||||
void OnTimeChanged(double time);
|
||||
|
||||
|
@ -69,7 +69,7 @@ class NoOutput: public IOutput {
|
||||
virtual void SetVolume(double volume) { this->volume = volume; }
|
||||
virtual double GetVolume() { return this->volume; }
|
||||
virtual void Stop() { }
|
||||
virtual int Play(IBuffer *buffer, IBufferProvider *provider) { return OutputInvalidState; }
|
||||
virtual OutputState Play(IBuffer *buffer, IBufferProvider *provider) { return OutputState::InvalidState; }
|
||||
virtual void Drain() { }
|
||||
virtual double Latency() { return 0.0; }
|
||||
virtual const char* Name() { return "NoOutput"; }
|
||||
|
@ -117,12 +117,12 @@ static inline void loadPreferences(
|
||||
volume = std::max(0.0f, std::min(1.0f, (float)volume));
|
||||
transport->SetVolume(volume);
|
||||
|
||||
int repeatMode = prefs->GetInt(keys::RepeatMode, RepeatNone);
|
||||
repeatMode = (repeatMode > RepeatList || repeatMode < RepeatNone) ? RepeatNone : repeatMode;
|
||||
playback.SetRepeatMode((RepeatMode) repeatMode);
|
||||
auto repeatMode = (RepeatMode) prefs->GetInt(keys::RepeatMode, (int) RepeatMode::None);
|
||||
repeatMode = (repeatMode > RepeatMode::List || repeatMode < RepeatMode::None) ? RepeatMode::None : repeatMode;
|
||||
playback.SetRepeatMode(repeatMode);
|
||||
|
||||
int timeChangeMode = prefs->GetInt(keys::TimeChangeMode, TimeChangeScrub);
|
||||
playback.SetTimeChangeMode((TimeChangeMode) timeChangeMode);
|
||||
auto timeChangeMode = (TimeChangeMode) prefs->GetInt(keys::TimeChangeMode, (int) TimeChangeMode::Scrub);
|
||||
playback.SetTimeChangeMode(timeChangeMode);
|
||||
}
|
||||
|
||||
static inline void savePreferences(
|
||||
@ -130,8 +130,8 @@ static inline void savePreferences(
|
||||
std::shared_ptr<Preferences> prefs)
|
||||
{
|
||||
prefs->SetDouble(keys::Volume, playback.GetVolume());
|
||||
prefs->SetInt(keys::RepeatMode, playback.GetRepeatMode());
|
||||
prefs->SetInt(keys::TimeChangeMode, playback.GetTimeChangeMode());
|
||||
prefs->SetInt(keys::RepeatMode, (int) playback.GetRepeatMode());
|
||||
prefs->SetInt(keys::TimeChangeMode, (int) playback.GetTimeChangeMode());
|
||||
}
|
||||
|
||||
/* internally PlaybackService leverages a message queue for synchronization;
|
||||
@ -148,9 +148,9 @@ PlaybackService::PlaybackService(
|
||||
, transport(transport)
|
||||
, playlist(library)
|
||||
, unshuffled(library)
|
||||
, repeatMode(RepeatNone)
|
||||
, repeatMode(RepeatMode::None)
|
||||
, messageQueue(messageQueue)
|
||||
, timeChangeMode(TimeChangeSeek)
|
||||
, timeChangeMode(TimeChangeMode::Seek)
|
||||
, seekPosition(-1.0f)
|
||||
, index(NO_POSITION)
|
||||
, nextIndex(NO_POSITION)
|
||||
@ -202,7 +202,7 @@ void PlaybackService::PrepareNextTrack() {
|
||||
|
||||
if (this->Count() > 0) {
|
||||
/* repeat track, just keep playing the same thing over and over */
|
||||
if (this->repeatMode == RepeatTrack) {
|
||||
if (this->repeatMode == RepeatMode::Track) {
|
||||
this->nextIndex = this->index;
|
||||
this->transport->PrepareNextTrack(
|
||||
this->UriAtIndex(this->index),
|
||||
@ -231,7 +231,7 @@ void PlaybackService::PrepareNextTrack() {
|
||||
}
|
||||
}
|
||||
/* repeat list case, wrap around to the beginning if necessary */
|
||||
else if (this->repeatMode == RepeatList) {
|
||||
else if (this->repeatMode == RepeatMode::List) {
|
||||
if (this->nextIndex != 0) {
|
||||
this->nextIndex = 0;
|
||||
this->transport->PrepareNextTrack(
|
||||
@ -314,7 +314,7 @@ void PlaybackService::ProcessMessage(IMessage &message) {
|
||||
StreamMessage* streamMessage = static_cast<StreamMessage*>(&message);
|
||||
StreamState eventType = (StreamState) streamMessage->GetEventType();
|
||||
|
||||
if (eventType == StreamBuffering || eventType == StreamBuffered || eventType == StreamPlaying) {
|
||||
if (eventType == StreamState::Buffering || eventType == StreamState::Buffered || eventType == StreamState::Playing) {
|
||||
TrackPtr track;
|
||||
|
||||
{
|
||||
@ -350,7 +350,7 @@ void PlaybackService::ProcessMessage(IMessage &message) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (eventType == StreamPlaying) {
|
||||
if (eventType == StreamState::Playing) {
|
||||
this->PrepareNextTrack();
|
||||
}
|
||||
}
|
||||
@ -366,12 +366,12 @@ void PlaybackService::ProcessMessage(IMessage &message) {
|
||||
}
|
||||
}
|
||||
else if (type == MESSAGE_PLAYBACK_EVENT) {
|
||||
int64_t eventType = message.UserData1();
|
||||
PlaybackState eventType = (PlaybackState) message.UserData1();
|
||||
|
||||
if (eventType == PlaybackStopped) {
|
||||
if (eventType == PlaybackState::Stopped) {
|
||||
this->OnTrackChanged(NO_POSITION, TrackPtr());
|
||||
}
|
||||
else if (eventType == PlaybackPrepared) {
|
||||
else if (eventType == PlaybackState::Prepared) {
|
||||
/* notify track change as soon as we're prepared. if we wait until
|
||||
we start playing, it may be a while until the UI knows to redraw! */
|
||||
if (this->UriAtIndex(this->index) == transport->Uri()) {
|
||||
@ -392,7 +392,7 @@ void PlaybackService::ProcessMessage(IMessage &message) {
|
||||
this->PlaybackStateChanged((PlaybackState) eventType);
|
||||
}
|
||||
else if (type == MESSAGE_PREPARE_NEXT_TRACK) {
|
||||
if (transport->GetPlaybackState() != PlaybackStopped) {
|
||||
if (transport->GetPlaybackState() != PlaybackState::Stopped) {
|
||||
size_t updatedIndex = (size_t)message.UserData1();
|
||||
|
||||
if (updatedIndex != NO_POSITION) {
|
||||
@ -461,12 +461,12 @@ void PlaybackService::ProcessMessage(IMessage &message) {
|
||||
}
|
||||
}
|
||||
|
||||
if (state != PlaybackStopped) {
|
||||
if (state != PlaybackState::Stopped) {
|
||||
this->Stop();
|
||||
this->transport->ReloadOutput();
|
||||
|
||||
if (index != NO_POSITION) {
|
||||
auto startMode = (state != PlaybackPaused && state != PlaybackPrepared)
|
||||
auto startMode = (state != PlaybackState::Paused && state != PlaybackState::Prepared)
|
||||
? ITransport::StartMode::Immediate : ITransport::StartMode::Wait;
|
||||
|
||||
this->PlayAt(index, startMode);
|
||||
@ -498,7 +498,7 @@ void PlaybackService::OnTrackChanged(size_t pos, TrackPtr track) {
|
||||
this->TrackChanged(this->index, track);
|
||||
this->messageQueue.Remove(this, MESSAGE_MARK_TRACK_PLAYED);
|
||||
|
||||
if (track && this->GetPlaybackState() == PlaybackPlaying) {
|
||||
if (track && this->GetPlaybackState() == PlaybackState::Playing) {
|
||||
/* TODO: maybe consider folding Scrobble() the `MarkTrackAsPlayed` logic?
|
||||
needs a bit more thought */
|
||||
lastfm::Scrobble(track);
|
||||
@ -525,7 +525,7 @@ void PlaybackService::MarkTrackAsPlayed(int64_t trackId) {
|
||||
}
|
||||
|
||||
bool PlaybackService::Next() {
|
||||
if (transport->GetPlaybackState() == PlaybackStopped) {
|
||||
if (transport->GetPlaybackState() == PlaybackState::Stopped) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -535,7 +535,7 @@ bool PlaybackService::Next() {
|
||||
this->Play(index + 1);
|
||||
return true;
|
||||
}
|
||||
else if (this->repeatMode == RepeatList) {
|
||||
else if (this->repeatMode == RepeatMode::List) {
|
||||
this->Play(0); /* wrap around */
|
||||
return true;
|
||||
}
|
||||
@ -544,7 +544,7 @@ bool PlaybackService::Next() {
|
||||
}
|
||||
|
||||
bool PlaybackService::Previous() {
|
||||
if (transport->GetPlaybackState() == PlaybackStopped) {
|
||||
if (transport->GetPlaybackState() == PlaybackState::Stopped) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -559,7 +559,7 @@ bool PlaybackService::Previous() {
|
||||
this->Play(index - 1);
|
||||
return true;
|
||||
}
|
||||
else if (this->repeatMode == RepeatList) {
|
||||
else if (this->repeatMode == RepeatMode::List) {
|
||||
this->Play(this->Count() - 1); /* wrap around */
|
||||
return true;
|
||||
}
|
||||
@ -580,9 +580,9 @@ size_t PlaybackService::Count() {
|
||||
void PlaybackService::ToggleRepeatMode() {
|
||||
RepeatMode mode = GetRepeatMode();
|
||||
switch (mode) {
|
||||
case RepeatNone: SetRepeatMode(RepeatList); break;
|
||||
case RepeatList: SetRepeatMode(RepeatTrack); break;
|
||||
default: SetRepeatMode(RepeatNone); break;
|
||||
case RepeatMode::None: SetRepeatMode(RepeatMode::List); break;
|
||||
case RepeatMode::List: SetRepeatMode(RepeatMode::Track); break;
|
||||
default: SetRepeatMode(RepeatMode::None); break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -773,16 +773,16 @@ double PlaybackService::GetVolume() {
|
||||
}
|
||||
|
||||
void PlaybackService::PauseOrResume() {
|
||||
int state = transport->GetPlaybackState();
|
||||
if (state == PlaybackStopped) {
|
||||
const auto state = transport->GetPlaybackState();
|
||||
if (state == PlaybackState::Stopped) {
|
||||
if (this->Count()) {
|
||||
this->Play(0);
|
||||
}
|
||||
}
|
||||
else if (state == PlaybackPaused || state == PlaybackPrepared) {
|
||||
else if (state == PlaybackState::Paused || state == PlaybackState::Prepared) {
|
||||
transport->Resume();
|
||||
}
|
||||
else if (state == PlaybackPlaying) {
|
||||
else if (state == PlaybackState::Playing) {
|
||||
transport->Pause();
|
||||
}
|
||||
}
|
||||
@ -800,7 +800,7 @@ void PlaybackService::SetVolume(double vol) {
|
||||
}
|
||||
|
||||
double PlaybackService::GetPosition() {
|
||||
if (this->timeChangeMode == TimeChangeSeek && this->seekPosition != -1.0f) {
|
||||
if (this->timeChangeMode == TimeChangeMode::Seek && this->seekPosition != -1.0f) {
|
||||
return this->seekPosition;
|
||||
}
|
||||
|
||||
@ -808,13 +808,13 @@ double PlaybackService::GetPosition() {
|
||||
}
|
||||
|
||||
void PlaybackService::SetPosition(double seconds) {
|
||||
if (this->timeChangeMode == TimeChangeSeek) {
|
||||
if (this->timeChangeMode == TimeChangeMode::Seek) {
|
||||
seconds = std::max(seconds, (double) 0.0);
|
||||
this->seekPosition = seconds;
|
||||
this->TimeChanged(seconds);
|
||||
messageQueue.Debounce(Message::Create(this, MESSAGE_SEEK), 500);
|
||||
}
|
||||
else { /* TimeChangeScrub */
|
||||
else { /* TimeChangeMode::Scrub */
|
||||
transport->SetPosition(seconds);
|
||||
}
|
||||
}
|
||||
@ -928,12 +928,12 @@ ITrackListEditor* PlaybackService::EditPlaylist() {
|
||||
this->playlistMutex);
|
||||
}
|
||||
|
||||
void PlaybackService::OnStreamEvent(int eventType, std::string uri) {
|
||||
POST_STREAM_MESSAGE(this, eventType, uri);
|
||||
void PlaybackService::OnStreamEvent(StreamState eventType, std::string uri) {
|
||||
POST_STREAM_MESSAGE(this, (int64_t) eventType, uri);
|
||||
}
|
||||
|
||||
void PlaybackService::OnPlaybackEvent(int eventType) {
|
||||
POST(this, MESSAGE_PLAYBACK_EVENT, eventType, 0);
|
||||
void PlaybackService::OnPlaybackEvent(PlaybackState eventType) {
|
||||
POST(this, MESSAGE_PLAYBACK_EVENT, (int64_t) eventType, 0);
|
||||
}
|
||||
|
||||
void PlaybackService::OnVolumeChanged() {
|
||||
|
@ -174,8 +174,8 @@ namespace musik { namespace core { namespace audio {
|
||||
Editor Edit();
|
||||
|
||||
private:
|
||||
void OnStreamEvent(int eventType, std::string uri);
|
||||
void OnPlaybackEvent(int eventType);
|
||||
void OnStreamEvent(musik::core::sdk::StreamState eventType, std::string uri);
|
||||
void OnPlaybackEvent(musik::core::sdk::PlaybackState eventType);
|
||||
void OnTrackChanged(size_t pos, musik::core::TrackPtr track);
|
||||
void OnVolumeChanged();
|
||||
void OnTimeChanged(double time);
|
||||
|
@ -124,7 +124,7 @@ Player::Player(
|
||||
EventListener *listener,
|
||||
Gain gain)
|
||||
: internalState(Player::Idle)
|
||||
, streamState(StreamBuffering)
|
||||
, streamState(StreamState::Buffering)
|
||||
, stream(Stream::Create())
|
||||
, url(url)
|
||||
, currentPosition(0)
|
||||
@ -298,7 +298,7 @@ void musik::core::audio::playerThreadLoop(Player* player) {
|
||||
|
||||
if (player->stream->OpenStream(player->url)) {
|
||||
for (Listener* l : player->Listeners()) {
|
||||
player->streamState = StreamBuffered;
|
||||
player->streamState = StreamState::Buffered;
|
||||
l->OnPlayerBuffered(player);
|
||||
}
|
||||
|
||||
@ -370,9 +370,9 @@ void musik::core::audio::playerThreadLoop(Player* player) {
|
||||
/* if this result is negative it's an error code defined by the sdk's
|
||||
OutputPlay enum. if it's a positive number it's the number of milliseconds
|
||||
we should wait until automatically trying to play the buffer again. */
|
||||
int playResult = player->output->Play(buffer, player);
|
||||
OutputState playResult = player->output->Play(buffer, player);
|
||||
|
||||
if (playResult == OutputBufferWritten) {
|
||||
if (playResult == OutputState::BufferWritten) {
|
||||
buffer = nullptr; /* reset so we pick up a new one next iteration */
|
||||
}
|
||||
else {
|
||||
@ -382,17 +382,17 @@ void musik::core::audio::playerThreadLoop(Player* player) {
|
||||
|
||||
/* if the playResult value >= 0, that means the output requested a
|
||||
specific callback time because its internal buffer is full. */
|
||||
if (playResult >= 0) {
|
||||
if ((int) playResult >= 0) {
|
||||
/* if there is no visualizer active, we can introduce an
|
||||
artifical delay of 25% of the buffer size to ease CPU load */
|
||||
auto visualizer = vis::SelectedVisualizer();
|
||||
if (!visualizer || !visualizer->Visible()) {
|
||||
sleepMs = std::max(
|
||||
(int)(player->output->Latency() * 250.0),
|
||||
playResult);
|
||||
(int) playResult);
|
||||
}
|
||||
else {
|
||||
sleepMs = playResult;
|
||||
sleepMs = (int) playResult;
|
||||
}
|
||||
}
|
||||
|
||||
@ -421,7 +421,7 @@ void musik::core::audio::playerThreadLoop(Player* player) {
|
||||
it wasn't stopped by the user. raise the "almost ended" flag. */
|
||||
if (!player->Exited()) {
|
||||
for (Listener* l : player->Listeners()) {
|
||||
player->streamState = StreamAlmostDone;
|
||||
player->streamState = StreamState::AlmostDone;
|
||||
l->OnPlayerAlmostEnded(player);
|
||||
}
|
||||
}
|
||||
@ -431,7 +431,7 @@ void musik::core::audio::playerThreadLoop(Player* player) {
|
||||
else {
|
||||
if (!player->Exited()) {
|
||||
for (Listener* l : player->Listeners()) {
|
||||
player->streamState = StreamOpenFailed;
|
||||
player->streamState = StreamState::OpenFailed;
|
||||
l->OnPlayerOpenFailed(player);
|
||||
}
|
||||
}
|
||||
@ -458,7 +458,7 @@ void musik::core::audio::playerThreadLoop(Player* player) {
|
||||
|
||||
if (!player->Exited()) {
|
||||
for (Listener* l : player->Listeners()) {
|
||||
player->streamState = StreamFinished;
|
||||
player->streamState = StreamState::Finished;
|
||||
l->OnPlayerFinished(player);
|
||||
}
|
||||
}
|
||||
@ -466,7 +466,7 @@ void musik::core::audio::playerThreadLoop(Player* player) {
|
||||
player->internalState = Player::Quit;
|
||||
|
||||
for (Listener* l : player->Listeners()) {
|
||||
player->streamState = StreamStopped;
|
||||
player->streamState = StreamState::Stopped;
|
||||
l->OnPlayerDestroying(player);
|
||||
}
|
||||
|
||||
@ -593,7 +593,7 @@ void Player::OnBufferProcessed(IBuffer *buffer) {
|
||||
}
|
||||
|
||||
if (!this->notifiedStarted) {
|
||||
this->streamState = StreamPlaying;
|
||||
this->streamState = StreamState::Playing;
|
||||
this->notifiedStarted = true;
|
||||
started = true;
|
||||
}
|
||||
|
@ -733,8 +733,8 @@ mcsdk_export void mcsdk_audio_output_stop(mcsdk_audio_output o) {
|
||||
OUTPUT(o)->Stop();
|
||||
}
|
||||
|
||||
mcsdk_export int mcsdk_audio_output_play(mcsdk_audio_output o, mcsdk_audio_buffer ab, mcsdk_audio_buffer_provider abp) {
|
||||
return OUTPUT(o)->Play(BUFFER(ab), BUFFERPROVIDER(abp));
|
||||
mcsdk_export mcsdk_audio_output_code mcsdk_audio_output_play(mcsdk_audio_output o, mcsdk_audio_buffer ab, mcsdk_audio_buffer_provider abp) {
|
||||
return (mcsdk_audio_output_code) OUTPUT(o)->Play(BUFFER(ab), BUFFERPROVIDER(abp));
|
||||
}
|
||||
|
||||
mcsdk_export void mcsdk_audio_output_drain(mcsdk_audio_output o) {
|
||||
|
@ -533,7 +533,7 @@ mcsdk_export void mcsdk_audio_output_resume(mcsdk_audio_output o);
|
||||
mcsdk_export void mcsdk_audio_output_set_volume(mcsdk_audio_output o, double volume);
|
||||
mcsdk_export double mcsdk_audio_output_get_volume(mcsdk_audio_output o);
|
||||
mcsdk_export void mcsdk_audio_output_stop(mcsdk_audio_output o);
|
||||
mcsdk_export int mcsdk_audio_output_play(mcsdk_audio_output o, mcsdk_audio_buffer ab, mcsdk_audio_buffer_provider abp);
|
||||
mcsdk_export mcsdk_audio_output_code mcsdk_audio_output_play(mcsdk_audio_output o, mcsdk_audio_buffer ab, mcsdk_audio_buffer_provider abp);
|
||||
mcsdk_export void mcsdk_audio_output_drain(mcsdk_audio_output o);
|
||||
mcsdk_export double mcsdk_audio_output_get_latency(mcsdk_audio_output o);
|
||||
mcsdk_export const char* mcsdk_audio_output_get_name(mcsdk_audio_output o);
|
||||
|
@ -127,11 +127,11 @@ static class Environment: public IEnvironment {
|
||||
virtual size_t GetPath(PathType type, char* dst, int size) override {
|
||||
std::string path;
|
||||
switch (type) {
|
||||
case PathUserHome: path = GetHomeDirectory(); break;
|
||||
case PathData: path = GetDataDirectory(); break;
|
||||
case PathApplication: path = GetApplicationDirectory(); break;
|
||||
case PathPlugins: path = GetPluginDirectory(); break;
|
||||
case PathLibrary: {
|
||||
case PathType::UserHome: path = GetHomeDirectory(); break;
|
||||
case PathType::Data: path = GetDataDirectory(); break;
|
||||
case PathType::Application: path = GetApplicationDirectory(); break;
|
||||
case PathType::Plugins: path = GetPluginDirectory(); break;
|
||||
case PathType::Library: {
|
||||
if (defaultLibrary) {
|
||||
path = GetDataDirectory() + std::to_string(defaultLibrary->Id()) + "/";
|
||||
}
|
||||
|
@ -34,6 +34,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "constants.h"
|
||||
#include "IPlugin.h"
|
||||
#include "IDataStream.h"
|
||||
#include "IBuffer.h"
|
||||
@ -50,7 +51,7 @@ namespace musik { namespace core { namespace sdk {
|
||||
virtual void SetVolume(double volume) = 0;
|
||||
virtual double GetVolume() = 0;
|
||||
virtual void Stop() = 0;
|
||||
virtual int Play(IBuffer *buffer, IBufferProvider *provider) = 0;
|
||||
virtual OutputState Play(IBuffer *buffer, IBufferProvider *provider) = 0;
|
||||
virtual void Drain() = 0;
|
||||
virtual double Latency() = 0;
|
||||
virtual const char* Name() = 0;
|
||||
|
@ -40,48 +40,48 @@
|
||||
namespace musik {
|
||||
namespace core {
|
||||
namespace sdk {
|
||||
enum PlaybackState {
|
||||
PlaybackStopped = 1,
|
||||
PlaybackPaused = 2,
|
||||
PlaybackPrepared = 3,
|
||||
PlaybackPlaying = 4,
|
||||
enum class PlaybackState: int {
|
||||
Stopped = 1,
|
||||
Paused = 2,
|
||||
Prepared = 3,
|
||||
Playing = 4,
|
||||
};
|
||||
|
||||
enum StreamState {
|
||||
StreamBuffering = 1,
|
||||
StreamBuffered = 2,
|
||||
StreamPlaying = 3,
|
||||
StreamAlmostDone = 4,
|
||||
StreamFinished = 5,
|
||||
StreamStopped = 6,
|
||||
StreamDestroyed = 7,
|
||||
StreamOpenFailed = -1
|
||||
enum class StreamState: int {
|
||||
Buffering = 1,
|
||||
Buffered = 2,
|
||||
Playing = 3,
|
||||
AlmostDone = 4,
|
||||
Finished = 5,
|
||||
Stopped = 6,
|
||||
Destroyed = 7,
|
||||
OpenFailed = -1
|
||||
};
|
||||
|
||||
enum RepeatMode {
|
||||
RepeatNone = 0,
|
||||
RepeatTrack = 1,
|
||||
RepeatList = 2
|
||||
enum class RepeatMode: int {
|
||||
None = 0,
|
||||
Track = 1,
|
||||
List = 2
|
||||
};
|
||||
|
||||
enum OutputPlay {
|
||||
OutputFormatError = -4,
|
||||
OutputInvalidState = -3,
|
||||
OutputBufferFull = -2,
|
||||
OutputBufferWritten = -1
|
||||
enum class OutputState: int {
|
||||
FormatError = -4,
|
||||
InvalidState = -3,
|
||||
BufferFull = -2,
|
||||
BufferWritten = -1
|
||||
};
|
||||
|
||||
enum TimeChangeMode {
|
||||
TimeChangeSeek = 0,
|
||||
TimeChangeScrub = 1
|
||||
enum class TimeChangeMode: int {
|
||||
Seek = 0,
|
||||
Scrub = 1
|
||||
};
|
||||
|
||||
enum PathType {
|
||||
PathUserHome = 0,
|
||||
PathData = 1,
|
||||
PathApplication = 2,
|
||||
PathPlugins = 3,
|
||||
PathLibrary = 4
|
||||
enum class PathType: int {
|
||||
UserHome = 0,
|
||||
Data = 1,
|
||||
Application = 2,
|
||||
Plugins = 3,
|
||||
Library = 4
|
||||
};
|
||||
|
||||
enum class Capability: int {
|
||||
|
@ -59,11 +59,11 @@ namespace musik {
|
||||
namespace core {
|
||||
namespace playback {
|
||||
void PauseOrResume(ITransport& transport) {
|
||||
int state = transport.GetPlaybackState();
|
||||
if (state == PlaybackPaused || state == PlaybackPrepared) {
|
||||
auto state = transport.GetPlaybackState();
|
||||
if (state == PlaybackState::Paused || state == PlaybackState::Prepared) {
|
||||
transport.Resume();
|
||||
}
|
||||
else if (state == PlaybackPlaying) {
|
||||
else if (state == PlaybackState::Playing) {
|
||||
transport.Pause();
|
||||
}
|
||||
}
|
||||
@ -115,7 +115,7 @@ namespace musik {
|
||||
void SavePlaybackContext(ILibraryPtr library, PlaybackService& playback) {
|
||||
if (Settings()->GetBool(keys::SaveSessionOnExit, true)) {
|
||||
auto prefs = Session();
|
||||
if (playback.GetPlaybackState() != sdk::PlaybackStopped) {
|
||||
if (playback.GetPlaybackState() != sdk::PlaybackState::Stopped) {
|
||||
prefs->SetInt(keys::LastPlayQueueIndex, (int)playback.GetIndex());
|
||||
|
||||
/* streams with a negative duration are of indeterminate length,
|
||||
|
@ -450,7 +450,7 @@ bool TransportWindow::MouseEvent(const IMouseHandler::Event& event) {
|
||||
return true;
|
||||
}
|
||||
else if (this->timePos.Contains(event)) {
|
||||
if (playback.GetPlaybackState() != PlaybackStopped) {
|
||||
if (playback.GetPlaybackState() != PlaybackState::Stopped) {
|
||||
double duration = playback.GetDuration();
|
||||
double percent = this->timePos.Percent(event.x);
|
||||
playback.SetPosition(duration * percent);
|
||||
@ -503,7 +503,7 @@ void TransportWindow::ProcessMessage(IMessage &message) {
|
||||
if (type == message::RefreshTransport) {
|
||||
this->Update((TimeMode) message.UserData1());
|
||||
|
||||
if (transport.GetPlaybackState() != PlaybackStopped) {
|
||||
if (transport.GetPlaybackState() != PlaybackState::Stopped) {
|
||||
DEBOUNCE_REFRESH(TimeSmooth, REFRESH_INTERVAL_MS)
|
||||
}
|
||||
}
|
||||
@ -520,13 +520,13 @@ void TransportWindow::ProcessMessage(IMessage &message) {
|
||||
void TransportWindow::OnPlaybackServiceTrackChanged(size_t index, TrackPtr track) {
|
||||
this->currentTrack = track;
|
||||
this->lastTime = DEFAULT_TIME;
|
||||
this->buffering = playback.GetTransport().GetStreamState() == StreamBuffering;
|
||||
this->buffering = playback.GetTransport().GetStreamState() == StreamState::Buffering;
|
||||
this->UpdateReplayGainState();
|
||||
DEBOUNCE_REFRESH(TimeSync, 0);
|
||||
}
|
||||
|
||||
void TransportWindow::OnPlaybackStreamStateChanged(StreamState state) {
|
||||
if (state == StreamBuffering) {
|
||||
if (state == StreamState::Buffering) {
|
||||
this->Debounce(message::TransportBuffering, 0, 0, 250);
|
||||
}
|
||||
else {
|
||||
@ -592,16 +592,15 @@ void TransportWindow::Update(TimeMode timeMode) {
|
||||
}
|
||||
|
||||
auto const state = transport.GetPlaybackState();
|
||||
bool const paused = state == PlaybackPaused;
|
||||
bool const prepared = state == PlaybackPrepared;
|
||||
bool const stopped = state == PlaybackStopped;
|
||||
bool const paused = (state == PlaybackState::Paused);
|
||||
bool const prepared = (state == PlaybackState::Prepared);
|
||||
bool const stopped = (state == PlaybackState::Stopped);
|
||||
bool const muted = transport.IsMuted();
|
||||
bool const replayGainEnabled = (this->replayGainMode != ReplayGainMode::Disabled);
|
||||
|
||||
Color const gb = Color::TextActive;
|
||||
Color const disabled = Color::TextDisabled;
|
||||
Color const bright = Color::TextDefault;
|
||||
|
||||
Color volumeAttrs = Color::Default;
|
||||
|
||||
if (this->focus == FocusVolume) {
|
||||
@ -611,13 +610,13 @@ void TransportWindow::Update(TimeMode timeMode) {
|
||||
volumeAttrs = gb;
|
||||
}
|
||||
|
||||
Color timerAttrs = (this->focus == FocusTime)
|
||||
Color const timerAttrs = (this->focus == FocusTime)
|
||||
? Color::TextFocused : Color::Default;
|
||||
|
||||
/* prepare the "shuffle" label */
|
||||
|
||||
std::string shuffleLabel = Strings.SHUFFLE;
|
||||
size_t shuffleWidth = displayCache->Columns(shuffleLabel);
|
||||
size_t const shuffleWidth = displayCache->Columns(shuffleLabel);
|
||||
|
||||
/* playing SONG TITLE from ALBUM NAME */
|
||||
|
||||
@ -635,7 +634,7 @@ void TransportWindow::Update(TimeMode timeMode) {
|
||||
/* draw the "shuffle" label */
|
||||
const int shuffleOffset = (int) (cx - shuffleWidth);
|
||||
wmove(c, 0, shuffleOffset);
|
||||
Color shuffleAttrs = this->playback.IsShuffled() ? gb : disabled;
|
||||
Color const shuffleAttrs = this->playback.IsShuffled() ? gb : disabled;
|
||||
ON(c, shuffleAttrs);
|
||||
checked_wprintw(c, shuffleLabel.c_str());
|
||||
OFF(c, shuffleAttrs);
|
||||
@ -643,7 +642,7 @@ void TransportWindow::Update(TimeMode timeMode) {
|
||||
|
||||
/* volume slider */
|
||||
|
||||
int volumePercent = (int) round(this->transport.Volume() * 100.0f);
|
||||
int const volumePercent = (int) round(this->transport.Volume() * 100.0f);
|
||||
int thumbOffset = std::min(10, (volumePercent * 10) / 100);
|
||||
|
||||
std::string volume;
|
||||
@ -666,15 +665,15 @@ void TransportWindow::Update(TimeMode timeMode) {
|
||||
|
||||
/* repeat mode setup */
|
||||
|
||||
RepeatMode mode = this->playback.GetRepeatMode();
|
||||
RepeatMode const mode = this->playback.GetRepeatMode();
|
||||
std::string repeatModeLabel;
|
||||
Color repeatAttrs = Color::Default;
|
||||
switch (mode) {
|
||||
case RepeatList:
|
||||
case RepeatMode::List:
|
||||
repeatModeLabel += Strings.REPEAT_LIST;
|
||||
repeatAttrs = gb;
|
||||
break;
|
||||
case RepeatTrack:
|
||||
case RepeatMode::Track:
|
||||
repeatModeLabel += Strings.REPEAT_TRACK;
|
||||
repeatAttrs = gb;
|
||||
break;
|
||||
@ -706,7 +705,7 @@ void TransportWindow::Update(TimeMode timeMode) {
|
||||
|
||||
if (!this->buffering && timeMode == TimeSmooth) {
|
||||
double smoothedTime = this->lastTime += 1.0f; /* 1000 millis */
|
||||
double actualTime = playback.GetPosition();
|
||||
double const actualTime = playback.GetPosition();
|
||||
|
||||
if (prepared || paused || stopped || fabs(smoothedTime - actualTime) > TIME_SLOP) {
|
||||
smoothedTime = actualTime;
|
||||
@ -727,7 +726,7 @@ void TransportWindow::Update(TimeMode timeMode) {
|
||||
|
||||
const std::string replayGain = replayGainEnabled ? "rg" : "";
|
||||
|
||||
int bottomRowControlsWidth =
|
||||
int const bottomRowControlsWidth =
|
||||
displayCache->Columns(volume) - (muted ? 0 : 1) + /* -1 for escaped percent sign when not muted */
|
||||
(replayGainEnabled ? (u8cols(replayGain) + 4) : 0) + /* [] brackets */
|
||||
u8cols(currentTime) + 1 + /* +1 for space padding */
|
||||
@ -735,14 +734,14 @@ void TransportWindow::Update(TimeMode timeMode) {
|
||||
1 + displayCache->totalTimeCols + /* +1 for space padding */
|
||||
displayCache->Columns(repeatModeLabel);
|
||||
|
||||
int timerTrackWidth =
|
||||
int const timerTrackWidth =
|
||||
this->GetContentWidth() -
|
||||
bottomRowControlsWidth;
|
||||
|
||||
thumbOffset = 0;
|
||||
|
||||
if (displayCache->secondsTotal) {
|
||||
int progress = (secondsCurrent * 100) / displayCache->secondsTotal;
|
||||
int const progress = (secondsCurrent * 100) / displayCache->secondsTotal;
|
||||
thumbOffset = std::min(timerTrackWidth - 1, (progress * timerTrackWidth) / 100);
|
||||
}
|
||||
|
||||
@ -760,7 +759,7 @@ void TransportWindow::Update(TimeMode timeMode) {
|
||||
OFF(c, volumeAttrs);
|
||||
|
||||
if (replayGainEnabled) {
|
||||
auto rgStyle = this->hasReplayGain ? gb : disabled;
|
||||
auto const rgStyle = this->hasReplayGain ? gb : disabled;
|
||||
checked_wprintw(c, "[");
|
||||
ON(c, rgStyle); checked_wprintw(c, "%s", replayGain.c_str()); OFF(c, rgStyle);
|
||||
checked_wprintw(c, "] ");
|
||||
|
@ -444,18 +444,18 @@ void AlsaOut::WriteLoop() {
|
||||
std::cerr << "AlsaOut: thread finished\n";
|
||||
}
|
||||
|
||||
int AlsaOut::Play(IBuffer *buffer, IBufferProvider* provider) {
|
||||
OutputState AlsaOut::Play(IBuffer *buffer, IBufferProvider* provider) {
|
||||
this->SetFormat(buffer);
|
||||
|
||||
{
|
||||
LOCK("play");
|
||||
|
||||
if (this->paused) {
|
||||
return OutputInvalidState;
|
||||
return OutputState::InvalidState;
|
||||
}
|
||||
|
||||
if (this->CountBuffersWithProvider(provider) >= BUFFER_COUNT) {
|
||||
return OutputBufferFull;
|
||||
return OutputState::BufferFull;
|
||||
}
|
||||
|
||||
std::shared_ptr<BufferContext> context(new BufferContext());
|
||||
@ -472,7 +472,7 @@ int AlsaOut::Play(IBuffer *buffer, IBufferProvider* provider) {
|
||||
}
|
||||
}
|
||||
|
||||
return OutputBufferWritten;
|
||||
return OutputState::BufferWritten;
|
||||
}
|
||||
|
||||
void AlsaOut::Drain() {
|
||||
|
@ -63,7 +63,7 @@ class AlsaOut : public musik::core::sdk::IOutput {
|
||||
virtual double Latency() override;
|
||||
virtual void Drain() override;
|
||||
|
||||
virtual int Play(
|
||||
virtual musik::core::sdk::OutputState Play(
|
||||
musik::core::sdk::IBuffer *buffer,
|
||||
musik::core::sdk::IBufferProvider *provider) override;
|
||||
|
||||
|
@ -133,17 +133,17 @@ CoreAudioOut::CoreAudioOut() {
|
||||
this->bufferCount = 0;
|
||||
}
|
||||
|
||||
int CoreAudioOut::Play(IBuffer *buffer, IBufferProvider *provider) {
|
||||
OutputState CoreAudioOut::Play(IBuffer *buffer, IBufferProvider *provider) {
|
||||
std::unique_lock<std::recursive_mutex> lock(this->mutex);
|
||||
|
||||
if (this->state != StatePlaying) {
|
||||
return OutputInvalidState;
|
||||
return OutputState::InvalidState;
|
||||
}
|
||||
|
||||
if (this->bufferCount >= BUFFER_COUNT) {
|
||||
/* enough buffers are already in the queue. bail, we'll notify the
|
||||
caller when there's more data available */
|
||||
return OutputBufferFull;
|
||||
return OutputState::BufferFull;
|
||||
}
|
||||
|
||||
OSStatus result;
|
||||
@ -173,7 +173,7 @@ int CoreAudioOut::Play(IBuffer *buffer, IBufferProvider *provider) {
|
||||
|
||||
if (result != 0) {
|
||||
std::cerr << "AudioQueueNewOutput failed: " << result << "\n";
|
||||
return OutputInvalidState;
|
||||
return OutputState::InvalidState;
|
||||
}
|
||||
|
||||
/* after the queue is created, but before it's started, let's make
|
||||
@ -207,7 +207,7 @@ int CoreAudioOut::Play(IBuffer *buffer, IBufferProvider *provider) {
|
||||
|
||||
if (result != 0) {
|
||||
std::cerr << "AudioQueueStart failed: " << result << "\n";
|
||||
return OutputInvalidState;
|
||||
return OutputState::InvalidState;
|
||||
}
|
||||
|
||||
this->Resume();
|
||||
@ -225,7 +225,7 @@ int CoreAudioOut::Play(IBuffer *buffer, IBufferProvider *provider) {
|
||||
|
||||
if (result != 0) {
|
||||
std::cerr << "AudioQueueAllocateBuffer failed: " << result << "\n";
|
||||
return OutputInvalidState;
|
||||
return OutputState::InvalidState;
|
||||
}
|
||||
|
||||
audioQueueBuffer->mUserData = (void *) context;
|
||||
@ -242,12 +242,12 @@ int CoreAudioOut::Play(IBuffer *buffer, IBufferProvider *provider) {
|
||||
if (result != 0) {
|
||||
std::cerr << "AudioQueueEnqueueBuffer failed: " << result << "\n";
|
||||
delete context;
|
||||
return OutputInvalidState;
|
||||
return OutputState::InvalidState;
|
||||
}
|
||||
|
||||
++bufferCount;
|
||||
|
||||
return OutputBufferWritten;
|
||||
return OutputState::BufferWritten;
|
||||
}
|
||||
|
||||
CoreAudioOut::~CoreAudioOut() {
|
||||
|
@ -67,7 +67,7 @@ class CoreAudioOut : public musik::core::sdk::IOutput {
|
||||
virtual double Latency() override { return 0.0; }
|
||||
virtual void Drain() override;
|
||||
|
||||
virtual int Play(
|
||||
virtual musik::core::sdk::OutputState Play(
|
||||
musik::core::sdk::IBuffer *buffer,
|
||||
musik::core::sdk::IBufferProvider *provider) override;
|
||||
|
||||
|
@ -283,16 +283,16 @@ static BOOL CALLBACK DSEnumCallback(LPGUID lpGuid, LPCWSTR description, LPCWSTR
|
||||
return 1;
|
||||
}
|
||||
|
||||
int DirectSoundOut::Play(IBuffer *buffer, IBufferProvider *provider) {
|
||||
OutputState DirectSoundOut::Play(IBuffer *buffer, IBufferProvider *provider) {
|
||||
Lock lock(this->stateMutex);
|
||||
|
||||
if (this->state != StatePlaying) {
|
||||
return OutputInvalidState;
|
||||
return OutputState::InvalidState;
|
||||
}
|
||||
|
||||
if (!this->Configure(buffer)) {
|
||||
this->Reset();
|
||||
return OutputFormatError;
|
||||
return OutputState::FormatError;
|
||||
}
|
||||
|
||||
unsigned char *dst1 = nullptr, *dst2 = nullptr;
|
||||
@ -314,7 +314,7 @@ int DirectSoundOut::Play(IBuffer *buffer, IBufferProvider *provider) {
|
||||
|
||||
if (bufferBytes > availableBytes && this->state == StatePlaying) {
|
||||
int samples = (bufferBytes - availableBytes) / sizeof(float) / channels;
|
||||
return ((long long)(samples * 1000) / rate) + 1;
|
||||
return (OutputState) (((long long)(samples * 1000) / rate) + 1);
|
||||
}
|
||||
|
||||
assert(availableBytes >= bufferBytes);
|
||||
@ -354,10 +354,10 @@ int DirectSoundOut::Play(IBuffer *buffer, IBufferProvider *provider) {
|
||||
this->firstBufferWritten = true;
|
||||
|
||||
provider->OnBufferProcessed(buffer);
|
||||
return OutputBufferWritten;
|
||||
return OutputState::BufferWritten;
|
||||
}
|
||||
|
||||
return OutputBufferFull;
|
||||
return OutputState::BufferFull;
|
||||
}
|
||||
|
||||
void DirectSoundOut::Drain() {
|
||||
@ -384,7 +384,7 @@ void DirectSoundOut::Drain() {
|
||||
real samples get played! */
|
||||
int count = drainCount + 1;
|
||||
while (count > 0 && this->state != StateStopped) {
|
||||
if (!this->Play(&buffer, &buffer)) {
|
||||
if ((int) this->Play(&buffer, &buffer) == 0) { /* ??? */
|
||||
Sleep(bufferResendDelayMs); /* eh */
|
||||
}
|
||||
else {
|
||||
|
@ -67,7 +67,7 @@ class DirectSoundOut : public IOutput {
|
||||
virtual void SetVolume(double volume) override;
|
||||
virtual double GetVolume() override;
|
||||
virtual void Stop() override;
|
||||
virtual int Play(IBuffer *buffer, IBufferProvider *provider) override;
|
||||
virtual OutputState Play(IBuffer *buffer, IBufferProvider *provider) override;
|
||||
virtual double Latency() override;
|
||||
virtual void Drain() override;
|
||||
virtual IDeviceList* GetDeviceList() override;
|
||||
|
@ -98,7 +98,7 @@ extern "C" DLLEXPORT void SetEnvironment(IEnvironment* environment) {
|
||||
|
||||
if (environment) {
|
||||
static char buffer[2046];
|
||||
environment->GetPath(PathData, buffer, sizeof(buffer));
|
||||
environment->GetPath(PathType::Data, buffer, sizeof(buffer));
|
||||
cachePath = std::string(buffer) + "/cache/httpclient/";
|
||||
}
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ class PlaybackRemote: public IPlaybackRemote, IKeyProcessor {
|
||||
switch (keyCode) {
|
||||
case NX_KEYTYPE_PLAY: {
|
||||
auto state = this->playback->GetPlaybackState();
|
||||
if (state == PlaybackStopped) {
|
||||
if (state == PlaybackState::Stopped) {
|
||||
if (this->playback->Count()) {
|
||||
this->playback->Play(0);
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ static class MPRISPlugin : public IPlugin {
|
||||
|
||||
extern "C" void SetEnvironment(IEnvironment* environment) {
|
||||
if (environment) {
|
||||
environment->GetPath(PathLibrary, localBuffer, sizeof(localBuffer));
|
||||
environment->GetPath(PathType::Library, localBuffer, sizeof(localBuffer));
|
||||
thumbnailPath = std::string(localBuffer) + "/thumbs/";
|
||||
}
|
||||
}
|
||||
@ -233,7 +233,7 @@ void MPRISRemote::MPRISPrev() {
|
||||
void MPRISRemote::MPRISPause() {
|
||||
if (playback) {
|
||||
auto state = playback->GetPlaybackState();
|
||||
if (state == PlaybackState::PlaybackPlaying) {
|
||||
if (state == PlaybackState::Playing) {
|
||||
playback->PauseOrResume();
|
||||
}
|
||||
}
|
||||
@ -254,7 +254,7 @@ void MPRISRemote::MPRISStop() {
|
||||
void MPRISRemote::MPRISPlay() {
|
||||
if (playback) {
|
||||
auto state = playback->GetPlaybackState();
|
||||
if (state != PlaybackState::PlaybackPlaying) {
|
||||
if (state != PlaybackState::Playing) {
|
||||
playback->PauseOrResume();
|
||||
}
|
||||
}
|
||||
@ -277,12 +277,12 @@ const char* MPRISRemote::MPRISGetPlaybackStatus() {
|
||||
if (playback) {
|
||||
auto state = playback->GetPlaybackState();
|
||||
switch (state) {
|
||||
case PlaybackState::PlaybackPlaying:
|
||||
case PlaybackState::Playing:
|
||||
return "Playing";
|
||||
case PlaybackState::PlaybackPaused:
|
||||
case PlaybackState::Paused:
|
||||
return "Paused";
|
||||
case PlaybackState::PlaybackPrepared:
|
||||
case PlaybackState::PlaybackStopped:
|
||||
case PlaybackState::Prepared:
|
||||
case PlaybackState::Stopped:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -294,11 +294,11 @@ const char* MPRISRemote::MPRISGetLoopStatus() {
|
||||
if (playback) {
|
||||
auto state = playback->GetRepeatMode();
|
||||
switch (state) {
|
||||
case RepeatMode::RepeatTrack:
|
||||
case RepeatMode::Track:
|
||||
return "Track";
|
||||
case RepeatMode::RepeatList:
|
||||
case RepeatMode::List:
|
||||
return "Playlist";
|
||||
case RepeatMode::RepeatNone:
|
||||
case RepeatMode::None:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -309,13 +309,13 @@ const char* MPRISRemote::MPRISGetLoopStatus() {
|
||||
void MPRISRemote::MPRISSetLoopStatus(const char* state) {
|
||||
if (playback) {
|
||||
if (!strcmp(state, "None")) {
|
||||
playback->SetRepeatMode(RepeatMode::RepeatNone);
|
||||
playback->SetRepeatMode(RepeatMode::None);
|
||||
}
|
||||
else if (!strcmp(state, "Playlist")) {
|
||||
playback->SetRepeatMode(RepeatMode::RepeatList);
|
||||
playback->SetRepeatMode(RepeatMode::List);
|
||||
}
|
||||
else if (!strcmp(state, "Track")) {
|
||||
playback->SetRepeatMode(RepeatMode::RepeatTrack);
|
||||
playback->SetRepeatMode(RepeatMode::Track);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -119,16 +119,16 @@ IDevice* NullOut::GetDefaultDevice() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int NullOut::Play(IBuffer *buffer, IBufferProvider *provider) {
|
||||
OutputState NullOut::Play(IBuffer *buffer, IBufferProvider *provider) {
|
||||
if (this->state == StatePaused) {
|
||||
return OutputInvalidState;
|
||||
return OutputState::InvalidState;
|
||||
}
|
||||
|
||||
/* order of operations matters, otherwise overflow. */
|
||||
int micros = ((buffer->Samples() * 1000) / buffer->SampleRate() * 1000) / buffer->Channels();
|
||||
usleep((long)((float) micros / speedMultiplier));
|
||||
provider->OnBufferProcessed(buffer);
|
||||
return OutputBufferWritten;
|
||||
return OutputState::BufferWritten;
|
||||
}
|
||||
|
||||
double NullOut::Latency() {
|
||||
|
@ -54,7 +54,7 @@ class NullOut : public IOutput {
|
||||
virtual void SetVolume(double volume) override;
|
||||
virtual double GetVolume() override;
|
||||
virtual void Stop() override;
|
||||
virtual int Play(IBuffer *buffer, IBufferProvider *provider) override;
|
||||
virtual OutputState Play(IBuffer *buffer, IBufferProvider *provider) override;
|
||||
virtual double Latency() override;
|
||||
virtual void Drain() override;
|
||||
virtual IDeviceList* GetDeviceList() override;
|
||||
|
@ -348,20 +348,20 @@ double PulseOut::GetVolume() {
|
||||
return this->volume;
|
||||
}
|
||||
|
||||
int PulseOut::Play(IBuffer *buffer, IBufferProvider* provider) {
|
||||
OutputState PulseOut::Play(IBuffer *buffer, IBufferProvider* provider) {
|
||||
int error = 0;
|
||||
|
||||
{
|
||||
Lock lock(this->stateMutex);
|
||||
|
||||
if (this->state == StatePaused) {
|
||||
return OutputInvalidState;
|
||||
return OutputState::InvalidState;
|
||||
}
|
||||
|
||||
this->OpenDevice(buffer);
|
||||
|
||||
if (!this->audioConnection || this->state != StatePlaying) {
|
||||
return OutputInvalidState;
|
||||
return OutputState::InvalidState;
|
||||
}
|
||||
|
||||
if (!this->volumeUpdated) {
|
||||
@ -376,12 +376,12 @@ int PulseOut::Play(IBuffer *buffer, IBufferProvider* provider) {
|
||||
|
||||
if (error > 0) {
|
||||
this->CloseDevice();
|
||||
return 1000; /* try again in a second */
|
||||
return (OutputState) 1000; /* try again in a second */
|
||||
}
|
||||
}
|
||||
|
||||
provider->OnBufferProcessed(buffer);
|
||||
return OutputBufferWritten;
|
||||
return OutputState::BufferWritten;
|
||||
}
|
||||
|
||||
double PulseOut::Latency() {
|
||||
|
@ -59,7 +59,7 @@ class PulseOut : public musik::core::sdk::IOutput {
|
||||
virtual double Latency() override;
|
||||
virtual void Drain() override;
|
||||
|
||||
virtual int Play(
|
||||
virtual musik::core::sdk::OutputState Play(
|
||||
musik::core::sdk::IBuffer *buffer,
|
||||
musik::core::sdk::IBufferProvider *provider) override;
|
||||
|
||||
|
@ -223,16 +223,16 @@ namespace broadcast {
|
||||
}
|
||||
|
||||
static auto PLAYBACK_STATE_TO_STRING = makeBimap<musik::core::sdk::PlaybackState, std::string>({
|
||||
{ musik::core::sdk::PlaybackStopped, "stopped" },
|
||||
{ musik::core::sdk::PlaybackPlaying, "playing" },
|
||||
{ musik::core::sdk::PlaybackPrepared, "prepared" },
|
||||
{ musik::core::sdk::PlaybackPaused, "paused" }
|
||||
{ musik::core::sdk::PlaybackState::Stopped, "stopped" },
|
||||
{ musik::core::sdk::PlaybackState::Playing, "playing" },
|
||||
{ musik::core::sdk::PlaybackState::Prepared, "prepared" },
|
||||
{ musik::core::sdk::PlaybackState::Paused, "paused" }
|
||||
});
|
||||
|
||||
static auto REPEAT_MODE_TO_STRING = makeBimap<musik::core::sdk::RepeatMode, std::string>({
|
||||
{ musik::core::sdk::RepeatNone, "none" },
|
||||
{ musik::core::sdk::RepeatTrack, "track" },
|
||||
{ musik::core::sdk::RepeatList, "list" }
|
||||
{ musik::core::sdk::RepeatMode::None, "none" },
|
||||
{ musik::core::sdk::RepeatMode::Track, "track" },
|
||||
{ musik::core::sdk::RepeatMode::List, "list" }
|
||||
});
|
||||
|
||||
static auto REPLAYGAIN_MODE_TO_STRING = makeBimap<musik::core::sdk::ReplayGainMode, std::string>({
|
||||
|
@ -636,8 +636,7 @@ int HttpServer::HandleThumbnailRequest(
|
||||
int status = MHD_HTTP_NOT_FOUND;
|
||||
|
||||
char pathBuffer[4096];
|
||||
server->context.environment->GetPath(
|
||||
PathType::PathLibrary, pathBuffer, sizeof(pathBuffer));
|
||||
server->context.environment->GetPath(PathType::Library, pathBuffer, sizeof(pathBuffer));
|
||||
|
||||
if (strlen(pathBuffer)) {
|
||||
std::string path = std::string(pathBuffer) + "thumbs/" + pathParts.at(1) + ".jpg";
|
||||
|
@ -69,7 +69,7 @@ static T* getTypedEncoder(Context& context, const std::string& format) {
|
||||
|
||||
static std::string cachePath(Context& context) {
|
||||
char buf[4096];
|
||||
context.environment->GetPath(PathType::PathData, buf, sizeof(buf));
|
||||
context.environment->GetPath(PathType::Data, buf, sizeof(buf));
|
||||
std::string path = std::string(buf) + "/cache/transcoder/";
|
||||
boost::filesystem::path boostPath(path);
|
||||
if (!exists(boostPath)) {
|
||||
|
@ -165,23 +165,23 @@ IDevice* SndioOut::GetDefaultDevice() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int SndioOut::Play(IBuffer *buffer, IBufferProvider *provider) {
|
||||
OutputState SndioOut::Play(IBuffer *buffer, IBufferProvider *provider) {
|
||||
std::this_thread::yield();
|
||||
|
||||
if (this->state != StatePlaying) {
|
||||
return OutputInvalidState;
|
||||
return OutputState::InvalidState;
|
||||
}
|
||||
|
||||
{
|
||||
LOCK()
|
||||
if (this->CountBuffersWithProvider(provider) >= BUFFER_COUNT) {
|
||||
return OutputBufferFull;
|
||||
return OutputState::BufferFull;
|
||||
}
|
||||
this->buffers.push_back(BufferContext{provider, buffer});
|
||||
}
|
||||
|
||||
NOTIFY()
|
||||
return OutputBufferWritten;
|
||||
return OutputState::BufferWritten;
|
||||
}
|
||||
|
||||
void SndioOut::WriteLoop() {
|
||||
|
@ -31,8 +31,10 @@
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <musikcore/sdk/constants.h>
|
||||
#include <musikcore/sdk/IOutput.h>
|
||||
#include <sndio.h>
|
||||
#include <mutex>
|
||||
@ -57,7 +59,7 @@ class SndioOut : public IOutput {
|
||||
virtual void SetVolume(double volume) override;
|
||||
virtual double GetVolume() override;
|
||||
virtual void Stop() override;
|
||||
virtual int Play(IBuffer *buffer, IBufferProvider *provider) override;
|
||||
virtual musik::core::sdk::OutputState Play(IBuffer *buffer, IBufferProvider *provider) override;
|
||||
virtual double Latency() override;
|
||||
virtual void Drain() override;
|
||||
virtual IDeviceList* GetDeviceList() override;
|
||||
|
@ -311,22 +311,22 @@ void WasapiOut::Drain() {
|
||||
}
|
||||
}
|
||||
|
||||
int WasapiOut::Play(IBuffer *buffer, IBufferProvider *provider) {
|
||||
OutputState WasapiOut::Play(IBuffer *buffer, IBufferProvider *provider) {
|
||||
Lock lock(this->stateMutex);
|
||||
|
||||
if (this->state == StatePaused) {
|
||||
return OutputInvalidState;
|
||||
return OutputState::InvalidState;
|
||||
}
|
||||
|
||||
if (this->deviceChanged) {
|
||||
this->Reset();
|
||||
this->deviceChanged = false;
|
||||
return OutputFormatError;
|
||||
return OutputState::FormatError;
|
||||
}
|
||||
|
||||
if (!this->Configure(buffer)) {
|
||||
this->Reset();
|
||||
return OutputFormatError;
|
||||
return OutputState::FormatError;
|
||||
}
|
||||
|
||||
HRESULT result;
|
||||
@ -341,7 +341,7 @@ int WasapiOut::Play(IBuffer *buffer, IBufferProvider *provider) {
|
||||
|
||||
if (availableFrames < framesToWrite) {
|
||||
UINT32 delta = framesToWrite - availableFrames;
|
||||
return (delta * 1000) / buffer->SampleRate();
|
||||
return (OutputState) ((delta * 1000) / buffer->SampleRate());
|
||||
}
|
||||
|
||||
if (availableFrames >= framesToWrite) {
|
||||
@ -351,11 +351,11 @@ int WasapiOut::Play(IBuffer *buffer, IBufferProvider *provider) {
|
||||
memcpy(data, buffer->BufferPointer(), sizeof(float) * samples);
|
||||
this->renderClient->ReleaseBuffer(framesToWrite, 0);
|
||||
provider->OnBufferProcessed(buffer);
|
||||
return OutputBufferWritten;
|
||||
return OutputState::BufferWritten;
|
||||
}
|
||||
}
|
||||
|
||||
return OutputBufferFull;
|
||||
return OutputState::BufferFull;
|
||||
}
|
||||
|
||||
void WasapiOut::Reset() {
|
||||
|
@ -65,7 +65,7 @@ class WasapiOut : public IOutput {
|
||||
virtual void SetVolume(double volume) override;
|
||||
virtual double GetVolume() override;
|
||||
virtual void Stop() override;
|
||||
virtual int Play(IBuffer *buffer, IBufferProvider *provider) override;
|
||||
virtual OutputState Play(IBuffer *buffer, IBufferProvider *provider) override;
|
||||
virtual double Latency() override;
|
||||
virtual void Drain() override;
|
||||
virtual IDeviceList* GetDeviceList() override;
|
||||
|
@ -269,7 +269,7 @@ WaveOut::WaveOutBufferPtr WaveOut::GetEmptyBuffer() {
|
||||
}
|
||||
}
|
||||
|
||||
int WaveOut::Play(IBuffer *buffer, IBufferProvider *provider) {
|
||||
OutputState WaveOut::Play(IBuffer *buffer, IBufferProvider *provider) {
|
||||
LockT lock(this->bufferQueueMutex);
|
||||
|
||||
/* if we have a different format, return false and wait for the pending
|
||||
@ -280,7 +280,7 @@ int WaveOut::Play(IBuffer *buffer, IBufferProvider *provider) {
|
||||
this->currentSampleRate != buffer->SampleRate();
|
||||
|
||||
if (formatChanged) {
|
||||
return OutputFormatError;
|
||||
return OutputState::FormatError;
|
||||
}
|
||||
}
|
||||
|
||||
@ -298,7 +298,7 @@ int WaveOut::Play(IBuffer *buffer, IBufferProvider *provider) {
|
||||
LockT lock2(this->outputDeviceMutex);
|
||||
|
||||
if (!this->playing) {
|
||||
return OutputInvalidState;
|
||||
return OutputState::InvalidState;
|
||||
}
|
||||
}
|
||||
|
||||
@ -313,11 +313,11 @@ int WaveOut::Play(IBuffer *buffer, IBufferProvider *provider) {
|
||||
|
||||
if (waveBuffer->WriteToOutput()) {
|
||||
this->queuedBuffers.push_back(waveBuffer);
|
||||
return OutputBufferWritten;
|
||||
return OutputState::BufferWritten;
|
||||
}
|
||||
}
|
||||
|
||||
return OutputBufferFull;
|
||||
return OutputState::BufferFull;
|
||||
}
|
||||
|
||||
bool WaveOut::SetDefaultDevice(const char* deviceId) {
|
||||
|
@ -60,7 +60,7 @@ class WaveOut : public IOutput {
|
||||
virtual void SetVolume(double volume) override;
|
||||
virtual double GetVolume() override;
|
||||
virtual void Stop() override;
|
||||
virtual int Play(IBuffer *buffer, IBufferProvider *provider) override;
|
||||
virtual OutputState Play(IBuffer *buffer, IBufferProvider *provider) override;
|
||||
virtual double Latency() override { return 0.0; }
|
||||
virtual void Drain() override { }
|
||||
virtual IDeviceList* GetDeviceList() override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user