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