Skip to content

Commit

Permalink
Master controls position when stopped + some style fix
Browse files Browse the repository at this point in the history
  • Loading branch information
firewall1110 committed Jul 30, 2024
1 parent b31c5d5 commit 77435b4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
2 changes: 0 additions & 2 deletions include/AudioJack.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ private slots:
f_cnt_t m_framesDoneInCurBuf;
f_cnt_t m_framesToDoInCurBuf;


#ifdef AUDIO_PORT_SUPPORT
struct StereoPort
{
Expand All @@ -131,7 +130,6 @@ private slots:
void zombified();
};


} // namespace lmms

#endif // LMMS_HAVE_JACK
Expand Down
1 change: 1 addition & 0 deletions include/ExSync.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ struct ExSyncHandler * exSyncGetHandler();

void exSyncStopped();
void exSyncSendPosition();
void exSyncSendPositioniIfMaster();

const char * exSyncToggleMode();
const char * exSyncGetModeString();
Expand Down
22 changes: 15 additions & 7 deletions src/core/ExSync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,12 @@ static struct ExSyncCallbacks cs_exSyncCallbacks = {
&exSyncSampleRate
};

enum {
ESM_MASTER = 0, ESM_SLAVE, ESM_DUPLEX, ESM_LAST
};


#define EXSYNC_MAX_MODES (3)
static const char * cs_exSyncModeStrings[EXSYNC_MAX_MODES] = {
static const char * cs_exSyncModeStrings[ESM_LAST] = {
"Master", "Slave", "Duplex"
};

Expand Down Expand Up @@ -299,11 +302,16 @@ void exSyncSendPosition()

ExSyncHandler * sync = exSyncGetHandler();
sync->sendPosition(&pos);

}
}


void exSyncSendPositioniIfMaster()
{
if( ESM_MASTER == cs_exSyncMode) { exSyncSendPosition(); }
}


const char * exSyncToggleMode()
{
ExSyncHandler * sync = exSyncGetHandler();
Expand All @@ -314,22 +322,22 @@ const char * exSyncToggleMode()
}
//! Make state change (Master -> Slave -> Duplex -> Master -> ...)
cs_exSyncMode += 1;
if (cs_exSyncMode >= EXSYNC_MAX_MODES) { cs_exSyncMode = 0; }
if (cs_exSyncMode >= ESM_LAST) { cs_exSyncMode = ESM_MASTER; }
switch(cs_exSyncMode)
{
case 0: // Master
case ESM_MASTER: // Master
cs_exSyncSlaveOn = false;
cs_exSyncMasterOn = true;
sync->setSlave(false); // ExSync more calls after ExSync.h
cs_slaveCallBacks = nullptr;
break;
case 1: // Slave
case ESM_SLAVE: // Slave
cs_exSyncSlaveOn = true;
cs_exSyncMasterOn = false;
sync->setSlave(true); // ExSync more calls after ExSync.h
cs_slaveCallBacks = &cs_exSyncCallbacks; // in future = getSlaveCallbacks();
break;
case 2: // Duplex
case ESM_DUPLEX: // Duplex
cs_exSyncMasterOn = true;
}
return cs_exSyncModeStrings[cs_exSyncMode];
Expand Down
1 change: 1 addition & 0 deletions src/core/Song.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1434,6 +1434,7 @@ void Song::onPlaybackStateChanged()
{
ExSyncHandler * sync = exSyncGetHandler();
sync->sendPlay(m_playing);
exSyncSendPositioniIfMaster();
}
}
}
Expand Down

0 comments on commit 77435b4

Please sign in to comment.