mirror of
https://github.com/clangen/musikcube.git
synced 2025-02-22 06:40:54 +00:00
Fixed Player::Detach() logic for CrossfadeTransport. Also simplified a bit of Player instance reset checks in GaplessTransport.
This commit is contained in:
parent
ad390fb6f1
commit
698227cff1
@ -40,7 +40,7 @@
|
||||
#include <core/audio/Outputs.h>
|
||||
#include <algorithm>
|
||||
|
||||
#define CROSSFADE_DURATION_MS 3000
|
||||
#define CROSSFADE_DURATION_MS 1500
|
||||
#define END_OF_TRACK_MIXPOINT 1001
|
||||
|
||||
using namespace musik::core::audio;
|
||||
@ -54,13 +54,12 @@ CrossfadeTransport::CrossfadeTransport()
|
||||
, nextCanStart(false)
|
||||
, muted(false)
|
||||
, crossfader(*this)
|
||||
, active(crossfader)
|
||||
, next(crossfader) {
|
||||
, active(*this, crossfader)
|
||||
, next(*this, crossfader) {
|
||||
|
||||
}
|
||||
|
||||
CrossfadeTransport::~CrossfadeTransport() {
|
||||
this->disconnect_all();
|
||||
this->Stop();
|
||||
}
|
||||
|
||||
@ -322,8 +321,11 @@ void CrossfadeTransport::RaiseStreamEvent(int type, Player* player) {
|
||||
this->StreamEvent(type, player->GetUrl());
|
||||
}
|
||||
|
||||
CrossfadeTransport::PlayerContext::PlayerContext(Crossfader& crossfader)
|
||||
: crossfader(crossfader)
|
||||
CrossfadeTransport::PlayerContext::PlayerContext(
|
||||
CrossfadeTransport& transport,
|
||||
Crossfader& crossfader)
|
||||
: transport(transport)
|
||||
, crossfader(crossfader)
|
||||
, player(nullptr)
|
||||
, canFade(false) {
|
||||
}
|
||||
@ -337,6 +339,8 @@ void CrossfadeTransport::PlayerContext::Reset(
|
||||
Player::PlayerEventListener* listener)
|
||||
{
|
||||
if (this->player && this->output) {
|
||||
this->player->Detach(&this->transport);
|
||||
|
||||
if (this->started && this->canFade) {
|
||||
crossfader.Cancel(
|
||||
this->player,
|
||||
@ -391,6 +395,7 @@ void CrossfadeTransport::PlayerContext::Start(double transportVolume) {
|
||||
void CrossfadeTransport::PlayerContext::Stop() {
|
||||
if (this->output && this->player) {
|
||||
this->output->Stop();
|
||||
this->player->Detach(&this->transport);
|
||||
this->player->Destroy();
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,9 @@ namespace musik { namespace core { namespace audio {
|
||||
using MessageQueue = musik::core::runtime::MessageQueue;
|
||||
|
||||
struct PlayerContext {
|
||||
PlayerContext(Crossfader& crossfader);
|
||||
PlayerContext(
|
||||
CrossfadeTransport& transport,
|
||||
Crossfader& crossfader);
|
||||
|
||||
void Reset();
|
||||
|
||||
@ -109,6 +111,7 @@ namespace musik { namespace core { namespace audio {
|
||||
bool canFade;
|
||||
Output output;
|
||||
Player *player;
|
||||
CrossfadeTransport& transport;
|
||||
Crossfader& crossfader;
|
||||
};
|
||||
|
||||
|
@ -71,10 +71,7 @@ GaplessTransport::GaplessTransport()
|
||||
}
|
||||
|
||||
GaplessTransport::~GaplessTransport() {
|
||||
this->disconnect_all();
|
||||
|
||||
LockT lock(this->stateMutex);
|
||||
|
||||
RESET_NEXT_PLAYER(this);
|
||||
RESET_ACTIVE_PLAYER(this);
|
||||
}
|
||||
@ -115,7 +112,7 @@ void GaplessTransport::StartWithPlayer(Player* newPlayer) {
|
||||
LockT lock(this->stateMutex);
|
||||
|
||||
playingNext = (newPlayer == nextPlayer);
|
||||
if (nextPlayer != nullptr && newPlayer != nextPlayer) {
|
||||
if (newPlayer != nextPlayer) {
|
||||
RESET_NEXT_PLAYER(this);
|
||||
}
|
||||
|
||||
@ -167,7 +164,7 @@ void GaplessTransport::StopInternal(
|
||||
|
||||
RESET_NEXT_PLAYER(this);
|
||||
|
||||
if (this->activePlayer && this->activePlayer != exclude) {
|
||||
if (this->activePlayer != exclude) {
|
||||
RESET_ACTIVE_PLAYER(this);
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ namespace musik { namespace core { namespace audio {
|
||||
|
||||
virtual void OnBufferProcessed(musik::core::sdk::IBuffer *buffer);
|
||||
|
||||
void Detach(PlayerEventListener *listner);
|
||||
void Detach(PlayerEventListener *listener);
|
||||
void Play();
|
||||
void Destroy();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user