Skip to content

Commit b3144e9

Browse files
committed
Don’t download DeviceSQL DBs for SQLite hardware
1 parent 76e951e commit b3144e9

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

src/main/java/org/deepsymmetry/beatlink/DeviceAnnouncement.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public DeviceAnnouncement(DatagramPacket packet) {
5858
name = new String(packetBytes, 0x0c, 20).trim();
5959
isOpusQuad = name.equals(OpusProvider.OPUS_NAME);
6060
isXdjAz = name.equals(OpusProvider.XDJ_AZ_NAME);
61+
isUsingDeviceLibraryPlus = isOpusQuad || isXdjAz;
6162
number = Util.unsign(packetBytes[0x24]);
6263
}
6364

@@ -80,6 +81,7 @@ public DeviceAnnouncement(DatagramPacket packet, int deviceNumber) {
8081
name = new String(packetBytes, 0x0c, 20).trim();
8182
isOpusQuad = name.equals(OpusProvider.OPUS_NAME);
8283
isXdjAz = name.equals(OpusProvider.XDJ_AZ_NAME);
84+
isUsingDeviceLibraryPlus = isOpusQuad || isXdjAz;
8385
number = deviceNumber;
8486
}
8587

@@ -184,17 +186,23 @@ public byte[] getPacketBytes() {
184186
}
185187

186188
/**
187-
* Check whether a device update came from an Opus Quad, which behaves very differently from true Pro DJ Link hardware.
189+
* Indicates whether a device update came from an Opus Quad, which behaves very differently from true Pro DJ Link hardware.
188190
*/
189191
@API(status = API.Status.EXPERIMENTAL)
190192
public final boolean isOpusQuad;
191193

192194
/**
193-
* Check whether a device update came from an XDJ-AZ, which can also be in a weird, non-Pro DJ Link mode.
195+
* Indicates whether a device update came from an XDJ-AZ, which can also be in a weird, non-Pro DJ Link mode.
194196
*/
195197
@API(status = API.Status.EXPERIMENTAL)
196198
public final boolean isXdjAz;
197199

200+
/**
201+
* Indicates whether the device that sent this update uses Device Library Plus (SQLite) track IDs rather than DeviceSQL IDs.
202+
*/
203+
@API(status = API.Status.EXPERIMENTAL)
204+
public final boolean isUsingDeviceLibraryPlus;
205+
198206
@Override
199207
public String toString() {
200208
return "DeviceAnnouncement[device:" + number + ", name:" + name + ", address:" + address.getHostAddress() +

src/main/java/org/deepsymmetry/beatlink/data/CrateDigger.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,21 @@ public static String humanReadableByteCount(long bytes, boolean si) {
225225
return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre);
226226
}
227227

228+
/**
229+
* Check whether we would be able to use a database read from the specified slot. Makes sure the device that
230+
* owns the slot uses DeviceSQL track IDs, or that we know how to access SQLite databases if it doesn’t.
231+
*
232+
* @param slot the slot from which a track was loaded
233+
*
234+
* @return {@code true} if we will be able to read track metadata from a database downloaded from that slot
235+
*/
236+
@API(status = API.Status.EXPERIMENTAL)
237+
public boolean canUseDatabase(SlotReference slot) {
238+
final DeviceAnnouncement owner = DeviceFinder.getInstance().getLatestAnnouncementFrom(slot.player);
239+
// TODO: Implement reading SQLite, and check if we have the key.
240+
return !owner.isUsingDeviceLibraryPlus;
241+
}
242+
228243
/**
229244
* Whenever we learn media details about a newly-mounted media slot, if it is rekordbox media, start the process
230245
* of fetching and parsing the database, so we can offer metadata for that slot.
@@ -235,7 +250,8 @@ public void detailsAvailable(final MediaDetails details) {
235250
if (isRunning() && details.mediaType == CdjStatus.TrackType.REKORDBOX &&
236251
!VirtualCdj.getInstance().inOpusQuadCompatibilityMode() && // If we are dealing with an Opus Quad, we can’t download files.
237252
details.slotReference.slot != CdjStatus.TrackSourceSlot.COLLECTION && // We always use dbserver to talk to rekordbox.
238-
!databases.containsKey(details.slotReference) &&
253+
!databases.containsKey(details.slotReference) && // We haven’t already downloaded it.
254+
canUseDatabase(details.slotReference) && // The player uses a database format we can read.
239255
activeRequests.add(details.slotReference)) {
240256
new Thread(() -> {
241257
File file = null;

0 commit comments

Comments
 (0)