Commit graph

186 commits

Author SHA1 Message Date
Andrew Kaster 1c3f11a5a6 Userland: Remove remaining callers of synchronous ImageDecoder API
Most of these now just await the image decoding, equivalent (ish) to
the old behavior. A more async-aware refactor should happen some time
in the future.
2024-04-23 12:32:04 -06:00
Dan Klishch 5ed7cd6e32 Everywhere: Use east const in more places
These changes are compatible with clang-format 16 and will be mandatory
when we eventually bump clang-format version. So, since there are no
real downsides, let's commit them now.
2024-04-19 06:31:19 -04:00
Andreas Kling 1cb5385a29 LibCore: Stop obsessing about tiny OOMs in Core::Timer
Work towards #20405
2024-04-17 07:16:52 +02:00
Shannon Booth e800605ad3 AK+LibURL: Move AK::URL into a new URL library
This URL library ends up being a relatively fundamental base library of
the system, as LibCore depends on LibURL.

This change has two main benefits:
 * Moving AK back more towards being an agnostic library that can
   be used between the kernel and userspace. URL has never really fit
   that description - and is not used in the kernel.
 * URL _should_ depend on LibUnicode, as it needs punnycode support.
   However, it's not really possible to do this inside of AK as it can't
   depend on any external library. This change brings us a little closer
   to being able to do that, but unfortunately we aren't there quite
   yet, as the code generators depend on LibCore.
2024-03-18 14:06:28 -04:00
implicitfield 896f213c6f LibFileSystem+Userland: Rename size() to size_from_stat()
This reflects what the functions does more accurately, and allows for
adding functions to get sizes through other methods.

This also corrects the return type of said function, as size_t may only
hold sizes up to 4GB on 32-bit platforms.
2024-02-24 15:54:52 -07:00
Tim Ledbetter 0d8a013ee1 SoundPlayer: Don't drop the unix pledge
Without it, `SoundPlayer` crashes as soon as you try to open a file.
2024-01-19 09:08:37 +01:00
Shannon Booth e2e7c4d574 Everywhere: Use to_number<T> instead of to_{int,uint,float,double}
In a bunch of cases, this actually ends up simplifying the code as
to_number will handle something such as:

```
Optional<I> opt;
if constexpr (IsSigned<I>)
    opt = view.to_int<I>();
else
    opt = view.to_uint<I>();
```

For us.

The main goal here however is to have a single generic number conversion
API between all of the String classes.
2023-12-23 20:41:07 +01:00
Ali Mohammad Pur 5e1499d104 Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
2023-12-17 18:25:10 +03:30
tetektoza 9deaa74ad6 LibGUI: Split HorizontalSlider to separate header
This patch splits HorizontalSlider to separate header so it can be used
as a component in .gml files with new GML compiler.
2023-12-08 01:06:09 +01:00
Ali Mohammad Pur aeee98b3a1 AK+Everywhere: Remove the null state of DeprecatedString
This commit removes DeprecatedString's "null" state, and replaces all
its users with one of the following:
- A normal, empty DeprecatedString
- Optional<DeprecatedString>

Note that null states of DeprecatedFlyString/StringView/etc are *not*
affected by this commit. However, DeprecatedString::empty() is now
considered equal to a null StringView.
2023-10-13 18:33:21 +03:30
Karol Kosek e75d694974 Userland: Compare event MIME type list with a StringView
The following commit will port MIME types to String. Traits<String>
- used in Vector::contains_slow - can't compare String type with char*,
so we need to use StringView instead.
2023-09-29 14:40:21 +01:00
Tim Ledbetter 3aa49f268c Userland: Make Window::set_main_widget() non-fallible 2023-09-21 10:20:23 +02:00
Tim Ledbetter 0d7b13edac Userland: Make GUI::Window construction non-fallible 2023-09-17 16:47:28 -06:00
Tim Ledbetter ccab5ddf9b LibGUI+Applications: Use String in make_about_action() 2023-09-16 11:05:49 +02:00
Andreas Kling bd61e75e0b LibGUI: Remove Window::try_add_menu()
And fall back to the infallible add_menu().
2023-08-14 14:57:54 +02:00
Andreas Kling f2faf2767f LibGUI: Remove Menu::try_add_action()
And fall back to the infallible add_action().
2023-08-14 14:57:54 +02:00
Andreas Kling 1525fa3b8f LibGUI: Remove Menu::try_add_separator()
And fall back to the infallible add_separator().
2023-08-14 14:57:54 +02:00
Lucas CHOLLET 3f35ffb648 Userland: Prefer _string over _short_string
As `_string` can't fail anymore (since 3434412), there are no real
benefits to use the short variant in most cases.
2023-08-08 07:37:21 +02:00
Andreas Kling 34344120f2 AK: Make "foo"_string infallible
Stop worrying about tiny OOMs.

Work towards #20405.
2023-08-07 16:03:27 +02:00
Andreas Kling ddbe6bd7b4 Userland: Rename Core::Object to Core::EventReceiver
This is a more precise description of what this class actually does.
2023-08-06 20:39:51 +02:00
Sam Atkins d00f489cdc SoundPlayer: Rename main widget to SoundPlayerWidget
This is the main widget, and is never replaced by something else, so
having "AdvancedView" in there is a bit confusing.
2023-07-19 19:37:27 +01:00
Sam Atkins fae350be3f SoundPlayer: Use an enum for PlaylistModel columns
Also correct some const-positioning.
2023-07-19 19:37:27 +01:00
Sam Atkins 32e5593ca9 SoundPlayer: Use AK::human_readable_size() for file sizes 2023-07-19 19:37:27 +01:00
Sam Atkins 7d0f70bfa0 Userland: Use AK::human_readable_digital_time() instead of custom code
Use this handy AK function instead of reimplementing the formatting code
several times. The one minor difference is that now, hours are only
shown if the duration is at least an hour long, but that seems like an
improvement to me. :^)
2023-07-19 08:45:43 -04:00
Sam Atkins f25adbd5ae SoundPlayer: Correct formatting of PlaylistModel duration text
The previous code would format 5400 seconds as "1:90:00", when it should
be "1:30:00".
2023-07-18 21:17:58 +01:00
kleines Filmröllchen b4fbd30b70 AudioServer+Userland: Decouple client sample rates from device rate
This change was a long time in the making ever since we obtained sample
rate awareness in the system. Now, each client has its own sample rate,
accessible via new IPC APIs, and the device sample rate is only
accessible via the management interface. AudioServer takes care of
resampling client streams into the device sample rate. Therefore, the
main improvement introduced with this commit is full responsiveness to
sample rate changes; all open audio programs will continue to play at
correct speed with the audio resampled to the new device rate.

The immediate benefits are manifold:
- Gets rid of the legacy hardware sample rate IPC message in the
  non-managing client
- Removes duplicate resampling and sample index rescaling code
  everywhere
- Avoids potential sample index scaling bugs in SoundPlayer (which have
  happened many times before) and fixes a sample index scaling bug in
  aplay
- Removes several FIXMEs
- Reduces amount of sample copying in all applications (especially
  Piano, where this is critical), improving performance
- Reduces number of resampling users, making future API changes (which
  will need to happen for correct resampling to be implemented) easier

I also threw in a simple race condition fix for Piano's audio player
loop.
2023-07-01 23:27:24 +01:00
Sam Atkins f33824d2e9 LibGUI+Userland: Propagate errors in Model::column_name() 2023-06-14 17:53:59 +02:00
thankyouverycool 02d94a303c Base+Userland: Apply Human Interface Guidelines to Object text
Corrects a slew of titles, buttons, labels, menu items and status bars
for capitalization, ellipses and punctuation.

Rewords a few actions and dialogs to use uniform language and
punctuation.
2023-05-23 05:59:49 +02:00
Karol Kosek 945f05ed76 Userland: Port Model::column_name() to String 2023-05-15 06:42:10 +02:00
Lucas CHOLLET 1a97382305 LibGUI: Make Application's construction fallible
The pattern to construct `Application` was to use the `try_create`
method from the `C_OBJECT` macro. While being safe from an OOM
perspective, this method doesn't propagate errors from the constructor.
This patch make `Application` use the `C_OBJECT_ABSTRACT` and manually
define a `create` method that can bubble up errors from the
construction stage.

This commit also removes the ability to use `argc` and `argv` to
create an `Application`, only `Main`'s `Arguments` can be used.

From a user point of view, the patch renames `try_create` => `create`,
hence the huge number of modified files.
2023-05-05 16:41:21 +01:00
Joel Petersson 23bc306f99 SoundPlayer: Clear client buffer when playback is stopped
Previously we would not clear the client buffer of the
ConnectionToServer when playback was stopped. This would
cause old samples to be buffered and played when playback
was restarted.

With this commit we now perform this clearing of the client
buffer correctly.
2023-05-03 10:01:14 +02:00
Joel Petersson e98315de6b SoundPlayer: Fix glitchy visualization on pause/stop
Previously when pausing or stoping a track in SoundPlayer,
the visualizations would glitch out. This was caused by them
being updated with the same buffer over and over.
With this patch a pause action will freeze the visualization at the
point of the pause and a stop action will reset the visualization
so it displays nothing until a track is started.
2023-05-02 09:15:20 +02:00
Joel Petersson f1d8e55168 SoundPlayer: Introduce buffer_reset api to VisualizationWidget
Previously there was no way to clear the internal buffer in a
VisualizationWidget. These buffers are what determines how a
VisualizationWidget is rendered, so with this commit we are now
able to reset visualizations.
2023-05-02 09:15:20 +02:00
thankyouverycool 91bafc2653 LibGUI+Userland: Port Labels to String 2023-04-30 05:48:14 +02:00
Karol Kosek 969543a847 LibGUI+Userland: Make Window::*add_menu take name using new string 2023-04-19 07:59:54 +02:00
Brendan Kelly 8d0985ef01 SoundPlayer: Pledge "FileManager" config domain
This stops SoundPlayer from crashing when attempting to open a sound
file from inside the GUI
2023-04-17 10:34:40 +02:00
MacDue 35612c6a7f AK+Everywhere: Change URL::path() to serialize_path()
This now defaults to serializing the path with percent decoded segments
(which is what all callers expect), but has an option not to. This fixes
`file://` URLs with spaces in their paths.

The name has been changed to serialize_path() path to make it more clear
that this method will generate a new string each call (except for the
cannot_be_a_base_url() case). A few callers have then been updated to
avoid repeatedly calling this function.
2023-04-15 06:37:04 +02:00
Brendan Kelly 7dd3c4a79c SoundPlayer: Check if loader is null
This patch prevents SoundPlayer from crashing when attempting to "seek"
when no file has been loaded
2023-04-14 07:13:32 -04:00
Cameron Youell 1d24f394c6 Everywhere: Use LibFileSystem where trivial 2023-03-21 19:03:21 +00:00
Caoimhe 23d31ac11d SoundPlayer: Keep track of the selected visualization in the config 2023-03-19 18:57:30 +00:00
Caoimhe 4c49e0f4a3 SoundPlayer: Move get_image_from_music_file to the advanced view 2023-03-19 18:57:30 +00:00
kleines Filmröllchen 68447d8f39 SoundPlayer: Display title and artist in the window title if available 2023-03-13 12:35:17 -04:00
Andreas Oppebøen 60908adcbe SoundPlayer: Add action with icon for toggling mute
This adds a button on the menubar next to the volume slider to
indicate mute state and allow toggling the mute. Pressing the M key
will still toggle the mute, as before. When muted, the volume scroll
bar now gets disabled.
2023-03-01 09:04:48 +00:00
Tim Schumacher 874c7bba28 LibCore: Remove Stream.h 2023-02-13 00:50:07 +00:00
Tim Schumacher 606a3982f3 LibCore: Move Stream-based file into the Core namespace 2023-02-13 00:50:07 +00:00
Tim Schumacher d43a7eae54 LibCore: Rename File to DeprecatedFile
As usual, this removes many unused includes and moves used includes
further down the chain.
2023-02-13 00:50:07 +00:00
Julian Offenhäuser adb1c842c2 SoundPlayer: Fix logic bug in bars visualization
When calculating bar height, we clamp our values to the maximum
vertical height of the widget minus a margin. When the window was
resized such that the widget got smaller than this margin however,
our maximum height became negative. This caused a crash in clamp().
2023-02-09 19:41:54 +01:00
Zaggy1024 3a1efbb9e4 SoundPlayer: Remove AutoSlider for the seek bar in favor of Slider 2023-02-07 14:36:58 +00:00
Linus Groh 9c08bb9555 AK: Remove try_ prefix from FixedArray creation functions 2023-01-28 22:41:36 +01:00
Tim Schumacher 82a152b696 LibGfx: Remove try_ prefix from bitmap creation functions
Those don't have any non-try counterpart, so we might as well just omit
it.
2023-01-26 20:24:37 +00:00