Skip to content

Commit

Permalink
Merge pull request #72 from cprepos/cprepos-virtual-rekordbox
Browse files Browse the repository at this point in the history
simplify virtualrekordbox, fix mr comment
  • Loading branch information
brunchboy authored May 2, 2024
2 parents 5cdef76 + 543f00f commit 6efd50d
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1,670 deletions.
9 changes: 1 addition & 8 deletions src/main/java/org/deepsymmetry/beatlink/DeviceUpdate.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,7 @@ public byte[] getPacketBytes() {
* @return the proper value
*/
int translateOpusPlayerNumbers(int reportedPlayerNumber) {
switch (reportedPlayerNumber){
case 9: return 1;
case 10: return 2;
case 11: return 3;
case 12: return 4;
}

return reportedPlayerNumber;
return reportedPlayerNumber & 7;
}

@Override
Expand Down
46 changes: 9 additions & 37 deletions src/main/java/org/deepsymmetry/beatlink/VirtualCdj.java
Original file line number Diff line number Diff line change
Expand Up @@ -272,31 +272,6 @@ public DeviceUpdateListener getUpdateListener() {
return updateListener;
}


/**
* Reacts to player status updates to reflect the current playback state.
*/
private final MasterListener masterListener = new MasterListener() {
@Override
public void masterChanged(DeviceUpdate update) {
deliverMasterChangedAnnouncement(update);
}

@Override
public void tempoChanged(double tempo) {
deliverTempoChangedAnnouncement(tempo);
}

@Override
public void newBeat(Beat beat) {
deliverBeatAnnouncement(beat);
}
};

public MasterListener getMasterListener() {
return masterListener;
}

/**
* The initial packet sent three times when coming online.
*/
Expand Down Expand Up @@ -688,6 +663,10 @@ private boolean selfAssignDeviceNumber() {
* @throws IllegalStateException if we are not running
*/
public List<NetworkInterface> getMatchingInterfaces() {
if (proxyingForVirtualRekordbox.get()) {
return VirtualRekordbox.getInstance().getMatchingInterfaces();
}

ensureRunning();
return Collections.unmodifiableList(matchingInterfaces);
}
Expand Down Expand Up @@ -1119,6 +1098,11 @@ public synchronized boolean start() throws SocketException {
VirtualRekordbox.getInstance().addLifecycleListener(virtualRekordboxLifecycleListener);
if (VirtualRekordbox.getInstance().isRunning()) {
proxyingForVirtualRekordbox.set(true);

// Set values that other callers might ask VirtualCdj for.
matchedAddress = VirtualRekordbox.getInstance().getMatchedAddress();
matchingInterfaces = VirtualRekordbox.getInstance().getMatchingInterfaces();

return true;
}

Expand Down Expand Up @@ -1456,18 +1440,6 @@ private void deliverDeviceUpdate(final DeviceUpdate update) {
}
}

// This is a way to get mediaDetails from Rekordbox and pass to all MediaDetailsListeners
private final MediaDetailsListener mediaDetailsListener = new MediaDetailsListener(){
@Override
public void detailsAvailable(MediaDetails details) {
deliverMediaDetailsUpdate(details);
}
};

public MediaDetailsListener getMediaDetailsListener() {
return mediaDetailsListener;
}

/**
* Keeps track of the registered media details listeners.
*/
Expand Down
Loading

0 comments on commit 6efd50d

Please sign in to comment.