fix cmd stream corruption when cmd stream playing

This commit is contained in:
tildearrow 2025-04-08 03:30:56 -05:00
parent a2c745cb10
commit b946f08122
2 changed files with 7 additions and 0 deletions

View file

@ -644,6 +644,12 @@ bool DivCSPlayer::init() {
bool DivEngine::playStream(unsigned char* f, size_t length) { bool DivEngine::playStream(unsigned char* f, size_t length) {
BUSY_BEGIN; BUSY_BEGIN;
// kill the previous player
if (cmdStreamInt) {
cmdStreamInt->cleanup();
delete cmdStreamInt;
cmdStreamInt=NULL;
}
cmdStreamInt=new DivCSPlayer(this,f,length); cmdStreamInt=new DivCSPlayer(this,f,length);
if (!cmdStreamInt->init()) { if (!cmdStreamInt->init()) {
logE("not a command stream!"); logE("not a command stream!");

View file

@ -206,6 +206,7 @@ void FurnaceGUI::drawCSPlayer() {
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button(_("Burn Current Song"))) { if (ImGui::Button(_("Burn Current Song"))) {
e->killStream();
SafeWriter* w=e->saveCommand(NULL,csExportDisablePass); SafeWriter* w=e->saveCommand(NULL,csExportDisablePass);
if (w!=NULL) { if (w!=NULL) {
if (!e->playStream(w->getFinalBuf(),w->size())) { if (!e->playStream(w->getFinalBuf(),w->size())) {