Commit Graph

389 Commits

Author SHA1 Message Date
Lukas Prediger cefe81d0c1 Removing Ripper dependence on cdio
and therefore no longer exposing cdio through CddaDevice
2022-01-10 16:39:58 +00:00
Lukas Prediger fd585e8aa4 RipCDDialog: no longer forces Cdda* to emit signals
- CddaDevice: Removed LoadSongs() method (then renamed ForceLoadSongs to LoadSongs)
- CddaDevice: added songs() method to get currently song list
- CddaSongLoader: cached_tracks is now thread-safe
2021-09-21 10:53:43 +01:00
Lukas Prediger 2936578fa4 CddaDevice: Preventing double read on disc change. 2021-09-21 10:53:43 +01:00
Lukas Prediger 62b5a0e77b CddaDevice now does not re-read song list if disc is not changed 2021-09-21 10:53:43 +01:00
Lukas Prediger 50404a967b RipCDDialog now only depends on CddaDevice, no longer on CddaSongLoader 2021-09-21 10:53:43 +01:00
Lukas Prediger 6b03b8f5d1 CddaSongLoader now emits a Finished signal if no further updates will follow for the same disc read. 2021-09-21 10:53:43 +01:00
Lukas Prediger 90ec6f6a24 CddaSongLoader now reads CD-Text for metadata
currently this gets overwritten by musicbrainz response almost immediately, though
2021-09-21 10:53:43 +01:00
Ismael Luceno 8682d4de48 Fix sentinels in variadic function calls
Replace sentinel NULL with nullptr, guaranteed to be correctly expanded.

NULL may be defined as plain 0 in C++; which may lead to undefined upper
bits passed in variadic function arguments, causing crashes.

See: https://ewontfix.com/11/
2021-08-23 21:33:46 +01:00
Jonas Kvinge f379ad84d4 Fix use of emit
Adds missing emits.

QTreeView::collapse and QTreeView::expand are slots, not signals. So
remove emit.
2021-07-14 10:18:47 +01:00
kentsangkm f35a640ce3 clang-format 2021-06-30 22:05:18 +01:00
kentsangkm cbe384d142 Add override 2021-06-30 22:05:18 +01:00
Lukas Prediger 57b5911f13 Fixes from code review for PR #7037 2021-06-21 12:51:44 +01:00
Lukas Prediger 6fa9cbcc65 Removing watch_for_disc_changes in CddaDevice constructor 2021-06-21 12:51:44 +01:00
Lukas Prediger 83b6bf28f3 No exceptions for error handling! ConnectedDevice::Init now returns bool, indicating success or failure.
As decreed by @hatstand.
2021-06-21 12:51:44 +01:00
Lukas Prediger a4ad507704 Removed some unused includes. 2021-06-21 12:51:44 +01:00
Lukas Prediger d2240ec0ae Device change watchdog timer no longer freezes main thread while CddaSongLoader is active. 2021-06-21 12:51:44 +01:00
Lukas Prediger 2dd566653f Dealing with cdio_open failures in CddaDevice constructor 2021-06-21 12:51:44 +01:00
Lukas Prediger 6ea20336c2 CddaSongLoader: Only run one song loading thread at once.
- CddaSongLoader destructor waits for thread to end.
- Added flag to interrupt LoadSongsFromCdda
- Only start song loading if not already running
- Removed (now obsolete) mutex
2021-06-21 12:51:44 +01:00
Lukas Prediger 95799a911d Removing ConnectedDevice::Refresh altogether 2021-06-21 12:51:44 +01:00
Lukas Prediger 639b918557 Removing CddaDevice::Refresh 2021-06-21 12:51:44 +01:00
Lukas Prediger 3c06b92b24 Ripper now works with a cdio instance passed into constructor
which comes from a CddaDevice corresponding to the device
2021-06-21 12:51:44 +01:00
Lukas Prediger ae3037984c RipCDDialog now uses CddaSongLoader from passed in CddaDevice 2021-06-21 12:51:44 +01:00
Lukas Prediger 14d5c25d37 Integrated cddevice back into cddadevice 2021-06-21 12:51:44 +01:00
Lukas Prediger 9ca75ae357 RipCDDialog now relies on CddaDevice to be notified about disc changes 2021-06-21 12:51:44 +01:00
Lukas Prediger d2c636ab46 Introducing CdDevice, simple wrapper for cdio that watches disc changes.
CddaDevice now relies on this to update song list. CddaDevice::Refresh is now a no-op.
2021-06-21 12:51:44 +01:00
Lukas Prediger e756f2d686 CddaSongLoader: explicitly reading discid as UTF8 2021-05-18 12:12:01 +01:00
Lukas Prediger 8d69da28f3 Fixing freeing of memory in cddasongloader 2021-05-18 12:12:01 +01:00
Lukas Prediger 8668699977 CddaSongLoader: handle potential multiple tag messages correctly 2021-05-18 12:12:01 +01:00
Lukas Prediger e9945bcbc6 do NOT free toc entries in CddaSongLoader (reverting previous change) 2021-05-18 12:12:01 +01:00
Lukas Prediger 86bbd2ace6 Formatting/linting fixes. 2021-05-18 12:12:01 +01:00
Lukas Prediger 436c53870a Correctly freeing memory in CddaSongLoader::LoadSongsFromCdda 2021-05-18 12:12:01 +01:00
Lukas Prediger 97800e613a Fix for #7019: CddaSongLoader obtaining metadata on first try. 2021-05-18 12:12:01 +01:00
Jim Broadus d798c76e06 devices: Remove obsolete DeviceKit.
DeviceKit-disks, renamed udisks, was superseded by udisks2 in 2012.
2021-05-06 20:52:33 +01:00
Jim Broadus 708385c71f devices: Fix guessed icons in DeviceIcons
In the initial implementation, DeviceLister::DeviceIcons returned a
string list and some listers would concatenate other lists to form that
list. When DeviceIcons was changed to return a variant list, that
logic wasn't changed in many places, so instead of appending, string
list variants are being added icon list.
2021-05-01 20:37:01 +01:00
Jim Broadus 01f0727649 giolister: Don't include invalid mountpoint url
If the gvfs mountpoint property for a volume is empty, we add an empty URL to
the devices URL list. This causes errors in duplicate entry detection.
2020-12-06 12:59:50 +00:00
Jim Broadus cca48b1ebf giolister: Ignore mountpoints
Read the G_FILE_ATTRIBUTE_UNIX_IS_MOUNTPOINT attribute (unix::is-mountpoint) to
determine if a volume is a mount that udisks2 has detected. Ignoring these
prevents network mounts from showing up as devices.
2020-12-05 13:24:54 +00:00
Jim Broadus 1a0b288a8f giolister: Remove extra g_object_unref
GioLister::UnmountDevice calls g_object_unref on the GVolume object held by a
DeviceInfo. This appears to be left over from a time before DeviceInfo held
onto the volume.
2020-12-04 22:07:01 +00:00
Jim Broadus abc70554f3 giolister: Append _ to some DeviceInfo class members
Rename drive, mount, and volume to drive_, mount_, and volume_ to
avoid confusion with method arguments.
2020-12-04 22:07:01 +00:00
John Maguire 341dc7326f Reformat all C++ 2020-09-22 14:56:06 +01:00
Gerion Entrup 6821f6d7bd udisks2lister: enable ipod recognition
The extends two functions:
- Recognize iPods as iPods, check for them in MakeDeviceUrls
- Give them a nice Icon in DeviceIcons (code taken from devicekitlister)
2020-08-28 16:48:13 +01:00
Jim Broadus 0d25a1b39c Properly delete ignored DeviceInfo object
Since the SimpleTreeItem constructor variant used from LoadAllDevices adds the
object to the parent's children list, use the parent's Delete method to destroy
it.
2020-06-19 00:10:54 +01:00
Jim Broadus cf8d2004bd Use deleteLater to destroy device backends 2020-06-07 14:46:13 +01:00
Jim Broadus 7e3cd84b5d Fix cdda playback
QUrl interprets a single number as an ip address, so the track URL cdda://1
would become cdda://0.0.0.1. A previous fix addresses this issue by adding an
extra character "a" to the affected URLs then removing the last instance of the
character upon usage. However, this didn't apply when a path was present
(cdda:///dev/sr0/1), but would still attempt to reverse the change later
(cdd:///dev/sr0/1).

This change applies the fix-up to all cdda urls and moves the conversion
utilities to a single location.

See: 335bc89c9 ("Workaround for broken CD playback in Qt5 (#6021)")
2020-06-01 22:09:46 +01:00
Jim Broadus 18a08e87c2 Add a directory_model accessor to Application class. 2020-02-11 08:09:22 +00:00
Jim Broadus 1c6e43509c Cancel scan when directory is removed.
When a directory is removed from the library during a scan, the scan continues
until complete. This change cancels the scan immediately, unblocking the watcher
thread, then signals the watcher to remove the directory.

A second issue occurs when a previously scanned device is removed during a
scan. All remaining files will be marked as deleted. This change mitigates
this issue, but a timing hole still remains here.
2020-01-24 10:28:51 -08:00
Jim Broadus 83d756356c Delete DeviceLister worker thread.
This isn't a serious leak since the lister is only destroyed when Clementine
exits.
2020-01-21 21:26:59 -08:00
Jim Broadus 34a2e86b4b Handle FileSystemWatcherInterface::AddPath errors.
On Linux systems, failure to watch a path may be caused by the limit set in
/proc/sys/fs/inotify/max_user_watches. This can be demonstrated by creating
a directory with a large number of empty subdirectories and adding that test
directory as a library.

Check that a file is readable before adding a watch. If adding the watch fails,
report the error to the user only once. Only add the path to subdir_mapping_
if watch succeeds.
2020-01-17 16:26:09 -08:00
Jim Broadus 4bb7d41ec9 Fix mtp and gphoto2 device mounts from gvfs.
Using libmtp or libgphoto2 to access a device that gvfs has mounted causes the
connection to fail. libmtp is calling libusb_claim_interface which, according to
libusb documentation, will return LIBUSB_ERROR_BUSY if claimed by a different
program. For mtp and gphoto2 devices discovered by the GioLister, use the file
scheme and access the device through the gvfs mount.
2020-01-16 13:11:49 -08:00
Jim Broadus 5efba58f02 Decode gvfs uris.
The uri returned from g_file_get_uri is percent encoded. This causes the regex
in GioLister::MakeDeviceUrls to fail and causes the URL to be invalid. In this
case, it falls back to the file scheme. Newer versions of gvfs obtain the serial
id from udev instead of using the bus and device IDs.

Note that this bug covers a different issue where mtp is failing to connect. The
result is actually desired behavior. The follow-up change will address this.
2020-01-16 13:11:44 -08:00
Jim Broadus 6a9276ec0a Fix LibraryModel async query crash.
A LibraryBackend may be deleted while an associated LibraryModel object is using
it. An example is an async query running while a connected device is removed.
To prevent this, use a share pointer for the LibraryBackend.

This fixes one case where LibraryBackend is used after deletion. However, the
raw pointer is still passed around in several other places. These should be
evaluated on a case-by-case basis to insure that circular depencencies aren't
introduced.
2020-01-14 21:47:31 -08:00