Commit Graph

1936 Commits

Author SHA1 Message Date
Alexandre Janniaux 2f2a478740 control: dbus: check EINTR for read
The definition of read() mandates from its prototype that the return
value and errno must be checked since the syscall can be interrupted
without being processed by a signal:

    ../../modules/control/dbus/dbus.c: In function ‘Run’:
    ../../modules/control/dbus/dbus.c:958:19: warning: ignoring return value of ‘read’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
      958 |             (void)read( fds[0].fd, &buf, 1 );
          |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~

In practice, the read is not done on a slow device, but a UNIX pipe
instead, and only when poll() notify that a read operation will be
non-blocking, and we're not supposed to have a signal handler here in
the normal execution (not using tools making use of SIGPROF for
instance), so read() being interrupted is nearly impossible, as opposed
to poll() being interrupted.

The read() call is also changed to use an anonymous compound litteral
which doesn't need to be marked as used manually, since we didn't use
the buffer variable at all.

In the future, using eventfd() to generate a semaphore compatible with
poll() and making the event handling lock-free might be a better
alternative, since read() will return the number of new events, and the
lock would become redundant.
2023-08-10 15:46:34 +00:00
Pierre Lamot 3a3214a133 hotkey: ensure we have a media before requesting OSD 2023-07-27 11:08:43 +00:00
Alexandre Janniaux a168eb015b dbus: dbus: refactor release of events
Tracklist events were aggregated by the processing code into it's own
linked-list which was then used to drpo the events.

The code was different from how events are released when closing the
application with events that were not sent to the dbus thread. This
commit unify the way they are released by duplicating the existing
release code matching the signal type and dropping them from the
ProcessEvents function instead.
2023-07-11 09:05:08 +00:00
Alexandre Janniaux 3db58145f1 dbus: dbus: delete event on error
When a second tracklist (append or remove) event was queued to the dbus
thread, it detected that an existing event was already there and
discarded the event without destroying it, despite the ownership being
transferred.

By checking whether the event was transferred or not and release it if
not, we don't risk leaking the event structures and the underlying items
hold by them.

No functional changes since those events were not discarded anymore.
2023-07-11 09:05:08 +00:00
Alexandre Janniaux f9b56da32c dbus: dbus: allow duplicated playlist event
This commit fixes a memory leak on playlist event.

After MR !3189 [^1], the leak was fixed when closing the interface
before the events are processed, but not when the events were being
processed and the ownership moved to the dbus thread.

When a second tracklist (append or remove) event was queued to the dbus
thread, it detected that an existing event was already there and
discarded the event without destroying it, despite the ownership being
transferred.

It is necessary to check whether the event was transferred or not and
release it if not, which will be done in a following commit, but the
tracklist events are gathered by the event processing code and event
type duplicates don't have the same information and shouldn't be
discarded first, which solves the following root leak:

    ==81939==ERROR: LeakSanitizer: detected memory leaks
    Direct leak of 40 byte(s) in 1 object(s) allocated from:
        #0 0x7fd01ced85cf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
        #1 0x7fd00d6a3129 in tracklist_append_event_create ../../modules/control/dbus/dbus_tracklist.c:41
        #2 0x7fd00d6b1f98 in playlist_on_items_added ../../modules/control/dbus/dbus.c:1063
        #3 0x7fd01c03e071 in vlc_playlist_ItemsInserted ../../src/playlist/content.c:76
        #4 0x7fd01c045b3e in vlc_playlist_Expand ../../src/playlist/content.c:382
        #5 0x7fd01c0537e8 in vlc_playlist_ExpandItem ../../src/playlist/preparse.c:59
        #6 0x7fd01c053942 in vlc_playlist_ExpandItemFromNode ../../src/playlist/preparse.c:76
        #7 0x7fd01c05397f in on_subtree_added ../../src/playlist/preparse.c:87
        #8 0x7fd01c070088 in OnParserSubtreeAdded ../../src/preparser/preparser.c:171
        #9 0x7fd01c08848b in input_item_parser_InputEvent ../../src/input/item.c:1402

[^1]: https://code.videolan.org/videolan/vlc/-/merge_requests/3189

Refs #27780
Fixes #28307
2023-07-11 09:05:08 +00:00
Alexandre Janniaux 8ce9af051b dbus: dbus_tracklist: add missing inline qualifier
Those functions are defined in a header file which will not use them
directly. `static` only will imply that the function will be used in the
file including it or the header itself. `static inline` is much more
suitable and will remove the unused function warning.
2023-07-11 09:05:08 +00:00
Steve Lhomme 6f992b755a modules: explicitly include windows.h when needed 2023-07-05 13:47:59 +00:00
Steve Lhomme e847a77fbb cli: use WINAPI_FAMILY to disable non-quiet mode
It's using freopen("CONOUT$") which is not supported in UWP.
2023-05-22 07:14:29 +00:00
Steve Lhomme 427484380c cli: allow using the console width in UWP 10.0.16299 2023-05-22 07:14:29 +00:00
Steve Lhomme cf06cc15b4 control/dummy: make dummy-quiet obsolete on all Windows
It doesn't matter if it's in UWP builds or not.
That option is not even used in 3.0.
2023-05-22 07:14:29 +00:00
Steve Lhomme cfe74be120 modules: include vlc_configuration.h when using config_Put/GetXXX 2023-05-06 06:56:32 +00:00
Steve Lhomme 8707c5939a modules: include vlc_arrays.h when using vlc_dictionary_t 2023-05-04 10:00:11 +00:00
Steve Lhomme 5d0620f3e2 modules: include vlc_arrays.h when using vlc_array_t 2023-05-04 10:00:11 +00:00
Steve Lhomme 55eba1ae2e modules: include vlc_threads.h when using vlc_savecancel() 2023-04-27 19:44:35 +00:00
Steve Lhomme 63e8a1a15a modules: include vlc_threads.h when vlc_thread_t is used 2023-04-27 19:44:35 +00:00
Johannes Kauffmann 35209fff7c Remove double trailing semicolons
Only matching ";;\n", replaced with:

  grep -lIR --include=*.{c,h,cpp,hpp} ";;\$" | xargs sed -i 's/;;\{1,\}$/;/'
2023-04-27 06:24:26 +00:00
Steve Lhomme 1ccffc330f control: remove unimotion motion handling
This code is very old and seems to require the installation of another module.
There's no trace online of this extra code.
2023-03-15 09:00:38 +00:00
Jorge Bellon-Castro fe7f7949c4 Dbus control module: release linked-list elements
Fixes a memory leak where elements in the linked list of events where
never released, due to the release function being always called at the
end of the traversal instead of every iteration.
2023-02-02 05:44:24 +00:00
Jorge Bellon-Castro 1832179c7b DBus control module: destroy events at exit 2023-02-02 05:44:24 +00:00
Steve Lhomme 17f4c6a3e0 modules: don't return an expression in void functions
It's not allowed in C11 (but OK in C++).
2023-01-19 04:49:52 +00:00
Johannes Kauffmann f242e3c7eb meson: fix named argument style
As per the style guide.
2023-01-15 09:26:33 +00:00
Jorge Bellon c752a43a75 DBus control module: return DBus error message instead of entering an infinite loop 2023-01-06 23:29:41 +00:00
Jorge Bellon-Castro c839ffd9a6 DBus control: add more TrackList signals
Implements the following signals for the
org.mpris.MediaPlayer2.TrackList interface:

- TrackAdded: a track was inserted to the list
- TrackRemoved: a track was removed from the list
2023-01-05 22:44:44 +00:00
Jorge Bellon-Castro b2a5d6cc75 DBus control: do not query index of item if known
The track index is sometimes known when serialising a track's metadata.
This moves the index query outside the metadata serialisation function
when necessary.
2023-01-05 22:44:44 +00:00
Jorge Bellon-Castro b9eb7cc643 DBus control: Extract method ProcessPlaylistChanged
Extract switch body for track append and track remove events.
This simplifies adding independent logic to both cases.
2023-01-05 22:44:44 +00:00
Marvin Scholz d5f07af209 meson: add initial meson build system
Co-authored-by: Tanguy Dubroca <tanguy.dubroca@lse.epita.fr>
Co-authored-by: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
Co-authored-by: Alexandre Janniaux <ajanni@videolabs.io>
2023-01-04 14:48:39 +00:00
Alexandre Janniaux 076641dceb control: cli: copy va_list before usage
The va_list will be used multiple times, so it needs to be copied before
each usage. Without this, it crashes when doing stop / play.
2022-12-09 14:16:39 +00:00
Romain Vimont b3ccc7b027 hotkeys: do not take snapshots from the UI thread
Snapshots are performed via a call to:

    var_TriggerCallback("video-snapshot")

causing its callback (SnapshotCallback) to be called synchronously,
executing the following steps:
 - wait for the vout thread to actually capture the (next) frame;
 - encode the picture to PNG;
 - write the result to disk (I/O).

Since var_TriggerCallback("video-snapshot") is called from the UI
thread, all these blocking actions are also performed on the UI thread.

Move the call to a separate thread.
2022-10-04 15:28:11 +00:00
Thomas Guillem 1c5d29d1f7 player: add a dir_path to vlc_player_SetRecordingEnabled 2022-08-13 08:45:38 +00:00
Johannes Kauffmann 67bcd48102 cli: fix unused parameter warning on Windows
/home/videolan/vlc/extras/package/win32/../../../modules/control/cli/cli.c:212:38: warning: unused parameter 'cl' [-Wunused-parameter]
static int LogOut(struct cli_client *cl, const char *const *args, size_t count,
                                     ^
2022-08-12 04:26:56 +00:00
Thomas Guillem c0de748a3b player: use double for the position 2022-08-06 14:39:45 +00:00
Rémi Denis-Courmont 0bb7fff7d4 hotkeys: don't assume "deinterlace-mode" exists
Fixes #27179.
2022-08-02 17:41:55 +00:00
Rémi Denis-Courmont 2390f360d6 cli: print item extra meta data (fixes #24986) 2022-05-19 18:33:26 +00:00
Rémi Denis-Courmont f2b463f98d cli: print item meta data (refs #24986)
Note that item->p_meta cannot be NULL.
2022-05-19 18:33:26 +00:00
Rémi Denis-Courmont 0b74dc4fa3 cli: factor strings 2022-05-19 18:33:26 +00:00
Rémi Denis-Courmont 85772a0e65 cli: print infos of playlist items (refs #24986)
This matches the Lua RC info semantics. If there is an argument print
the infos of the item with that index, rather than the playing item.
2022-05-19 18:33:26 +00:00
Rémi Denis-Courmont fd0cc5d3bb cli: make info a playlist command 2022-05-19 18:33:26 +00:00
Rémi Denis-Courmont 82e0b9704e cli: factor out item printing 2022-05-19 18:33:26 +00:00
Steve Lhomme 36017f9c3a modules: add a fancy name to internal threads 2022-05-18 07:52:09 +02:00
Rémi Denis-Courmont 64f98d32c9 cli: disable tracks whence toggling ID -1
This matches the pre-4.0 behaviour expected of the track commands.

Fixes #26938.
2022-05-16 16:32:52 +00:00
Romain Vimont 9c4f4942ed dbus: notify previous/next state changes
Changes of state indicating if "previous" and "next" actions are enabled
must be signaled to D-Bus.

Fixes #23603
2022-05-03 16:36:38 +00:00
Romain Vimont 9a47f147ec dbus: simplify previous/next detection
Use the existing playlist API to detect if there is a previous or next
item in the playlist.
2022-05-03 16:36:38 +00:00
Rémi Denis-Courmont dbf82a4d8c hotkeys: keep track of video outputs
...and properly deregister callbacks from them at exit.

Fixes #26898.
2022-05-03 14:16:20 +00:00
Rémi Denis-Courmont 85ff09aa49 hotkeys: factor out vout ES events 2022-05-03 14:16:20 +00:00
Steve Lhomme b469857dec vlc_threads: remove the thread priority when creating a thread
It is not used in POSIX systems. On other system it probably don't make a
difference anymore, only Windows has actual useful values for
VLC_THREAD_PRIORITY_XXX. The synchronization is more important than having some
threads called more often than others.
2022-04-27 08:16:28 +00:00
Thomas Guillem 80dd05f921 input_item: category: use a vlc_list
Instead of the legacy array.
2022-04-21 11:59:15 +00:00
Lyndon Brown 4d89ef900d fix mis-spelling of overridden
a followup to !1044.
2022-01-13 07:31:11 +00:00
Alexandre Janniaux 6b7a57f984 modules: fix typos
Typos found and reworked from codespell.
2022-01-08 15:19:32 +00:00
Lyndon Brown 6f68f89498 plugins: purge use of set_category()
see e967f81f6a.

note, this does **not** affect cat-based module selection items
(of which there are just three in use by the core), since that
mechanism uses subcats not cats.
2021-12-20 09:45:01 +00:00
Thomas Guillem 46f4ab44dc cli: don't show hidden info categories 2021-12-10 08:53:41 +00:00