summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibAudio
AgeCommit message (Collapse)Author
2021-07-13LibAudio: Use new Vector formatterkleines Filmröllchen
2021-07-12LibAudio: Set variable type for decoding fixed subframes in FLACKarol Kosek
This fixes an crash caused by using the type from FlacSubframeHeader::order (unsigned 8-bit), which after overflowing the integer, converting it back to u32, and decrementing by one resulted in accessing an array waaay out of bounds.
2021-07-05LibAudio: Add ClientConnection::async_enqueue()kleines Filmröllchen
async_enqueue() is a wrapper over the async_enqueue_buffer() call to AudioServer. This allows users to asyncronously enqueue audio samples, when the program requires non-blocking audio streaming. This also makes ClientConnection use east-const everywhere.
2021-07-05LibAudio: Improve latency on audio queue failureskleines Filmröllchen
We don't know what is a good time to wait after an audio buffer fails to be processed by AudioServer. However, it seems like decreasing the wait time to 10ms after such a failure should improve latency and has not caused issues in my testing. After all, 10ms is quite some time in audio sample magnitudes.
2021-06-25LibAudio: Implement a basic FLAC loaderkleines Filmröllchen
This commit adds a loader for the FLAC audio codec, the Free Lossless Audio codec by the Xiph.Org foundation. LibAudio will automatically read and parse FLAC files, so users do not need to adjust. This implementation is bare-bones and needs to be improved upon. There are many bugs, verbatim subframes and any kind of seeking is not supported. However, stereo files exported by libavcodec on highest compression setting seem to work well.
2021-06-25LibAudio: Make ResampleHelper templated for different sample typeskleines Filmröllchen
Previously, ResampleHelper was fixed on handling double's, which makes it unsuitable for the upcoming FLAC loader that needs to resample integers. For this reason, ResampleHelper is templated to support theoretically any type of sample, though only the necessary i32 and double are templated right now. The ResampleHelper implementations are moved from WavLoader.cpp to Buffer.cpp. This also improves some imports in the WavLoader files.
2021-06-25LibAudio: Make LoaderPlugin::error_string return String&kleines Filmröllchen
Previously, error_string() returned char* which is bad Serenity style and caused issues when other error handling methods were tried. As both WavLoader and (future) FLAC loader store a String internally for the error message, it makes sense to return a String reference instead.
2021-06-25LibAudio: Add the Int32 sample formatkleines Filmröllchen
The signed 32-bit PCM sample format is required for the FLAC standard.
2021-06-21SoundPlayer: Handle any input file sample rateNick Miller
This commit addresses two issues: 1. If you play a 96 KHz Wave file, the slider position is incorrect, because it is assumed all files are 44.1 KHz. 2. For high-bitrate files, there are audio dropouts due to not buffering enough audio data. Issue 1 is addressed by scaling the number of played samples by the ratio between the source and destination sample rates. Issue 2 is addressed by buffering a certain number of milliseconds worth of audio data (instead of a fixed number of bytes). This makes the the buffer size independent of the source sample rate. Some of the code is redesigned to be simpler. The code that did the book-keeping of which buffers need to be loaded and which have been already played has been removed. Instead, we enqueue a new buffer based on a low watermark of samples remaining in the audio server queue. Other small fixes include: 1. Disable the stop button when playback is finished. 2. Remove hard-coded instances of 44100. 3. Update the GUI every 50 ms (was 100), which improves visualizations.
2021-06-21LibAudio: Sleep less when the audio buffer is fullNick Miller
When using `aplay` to play audio files with a sample rate of 96000, there were occasional one-second gaps in playback. This is because the Audio::ClientConnection sleeps for a full second when the audio buffer is full. One second is too long to sleep, especially for high-bitrate files. Changing the sleep to a more reasonable value like 100 ms ensures we attempt to enqueue again before the audio buffer runs empty.
2021-06-21LibAudio: Avoid reading past the end of sample dataNick Miller
Prior code in `WavLoader::get_more_samples()` would attempt to read the requested number of samples without actually checking whether that many samples were remaining in the stream. This was the cause of an audible pop at the end of a track, due to reading non-audio data that is sometimes at the end of a Wave file. Now we only attempt to read up to the end of sample data, but no further. Also, added comments to clarify the meaning of "sample", and how it should be independent of the number of channels.
2021-06-09LibAudio: Add support for WAVE_FORMAT_EXTENSIBLENick Miller
This enables support for playing float32 and float64 WAVE_FORMAT_EXTENSIBLE files. The PCM data format is encoded in the first two bytes of the SubFormat GUID inside of the WAVE_FORMAT_EXTENSIBLE `fmt` chunk. Also, fixed the RIFF header size check to allow up to maximum_wav_size (currently defined as 1 GiB). The RIFF header size is the size of the entire file, so it should be checked against the largest Wave size.
2021-06-09LibAudio: Make Loader::seek() treat its input as a sample indexNick Miller
This fixes a bug where if you try to play a Wave file a second time (or loop with `aplay -l`), the second time will be pure noise. The function `Audio::Loader::seek` is meant to seek to a specific audio sample, e.g. seek(0) should go to the first audio sample. However, WavLoader was interpreting seek(0) as the beginning of the file or stream, which contains non-audio header data. This fixes the bug by capturing the byte offset of the start of the audio data, and offseting the raw file/stream seek by that amount.
2021-06-08LibAudio: WavLoader: Avoid reading partial samplesNick Miller
When samples are requested in `Audio::Loader::get_more_samples`, the request comes in as a max number of bytes to read. However, the requested number of bytes may not be an even multiple of the bytes per sample of the loaded file. If this is the case, and the bytes are read from the file/stream, then the last sample will be a partial/runt sample, which then offsets the remainder of the stream, causing white noise in playback. This bug was discovered when trying to play 24-bit Wave files, which happened to have a sample size that never aligned with the number of requested bytes. This commit fixes the bug by only reading a multiple of "bytes per sample" for the loaded file.
2021-06-08LibAudio+LibCore: Remove unnecessary IODeviceStreamReader.hNick Miller
IODeviceStreamReader isn't pulling its weight. It's essentially a subset of InputFileStream with only one user (WavLoader). This refactors WavLoader to use InputFileStream instead.
2021-05-23Userland: Mark subclasses of IPC::{Client,Server}Connection finalAndreas Kling
2021-05-23LibIPC: Remove unnecessary IPC::ServerConnection::handshake()Andreas Kling
This is no longer used by any of our IPC pairs.
2021-05-23AudioServer: Remove unnecessary greet() messageAndreas Kling
2021-05-12LibCore+Everywhere: Move OpenMode out of IODeviceAli Mohammad Pur
...and make it an enum class so people don't omit "OpenMode".
2021-05-03Userland: Make IPC results with one return value available directlyGunnar Beutner
This changes client methods so that they return the IPC response's return value directly - instead of the response struct - for IPC methods which only have a single return value.
2021-05-03Userland: Update IPC calls to use proxiesGunnar Beutner
This updates all existing code to use the auto-generated client methods instead of post_message/send_sync.
2021-05-03Userland: Change IPC funcs to use plain arguments instead of a structGunnar Beutner
Instead of having a single overloaded handle method each method gets its own unique method name now.
2021-05-01Everywhere: Turn #if *_DEBUG into dbgln_if/if constexprGunnar Beutner
2021-04-26LibAudio: Support 32 and 64-bit float WAV fileskleines Filmröllchen
LibAudio's WavLoader plugin for loading WAV files now supports loading audio files with 32-bit float or 64-bit float samples. By supporting these new non-int sample formats, Audio::Buffer now stores the sample format (out of a list of supported formats) instead of the raw bit depth. (The bit depth is easily calculated with pcm_bits_per_sample)
2021-04-23AK: Rename adopt() to adopt_ref()Andreas Kling
This makes it more symmetrical with adopt_own() (which is used to create a NonnullOwnPtr from the result of a naked new.)
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-03-27Everywhere: rename 'Sample' type to 'Frame'Cesar Torres
Because it's what it really is. A frame is composed of 1 or more samples, in the case of SerenityOS 2 (stereo). This will make it less confusing for future mantainability.
2021-03-16LibAudio: decrease WavLoader's size limit to a more reasonable sizeIdan Horowitz
A 4 GiB wav (current size limit) is very unreasonable, and larger than oss-fuzz's 2.5 GiB per-process memory limit.
2021-03-01LibAudio: Move format and BPS checks before VERIFYs in WAV loaderLuke
It was accidentally checking the format/bits per sample too late, which would crash with the assertion.
2021-03-01LibAudio: Use handle_any_error in WAV loaderLuke
It was using has_any_error, which causes an assertion failure when destroying the stream. Instead, use handle_any_error, as the WAV loader does handle errors.
2021-02-23Everywhere: Rename ASSERT => VERIFYAndreas Kling
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED) Since all of these checks are done in release builds as well, let's rename them to VERIFY to prevent confusion, as everyone is used to assertions being compiled out in release. We can introduce a new ASSERT macro that is specifically for debug checks, but I'm doing this wholesale conversion first since we've accumulated thousands of these already, and it's not immediately obvious which ones are suitable for ASSERT.
2021-02-01LibIPC: Stop sending client ID to clientsAndreas Kling
The client ID is not useful to normal clients anymore, so stop telling everyone what their ID is.
2021-01-25Everywhere: Hook up remaining debug macros to Debug.h.asynts
2021-01-22Libraries: Add missing headersBen Wiederhake
A C++ source file containing just #include <LibFoo/Bar.h> should always compile cleanly. This patch adds missing header inclusions that could have caused weird error messages if they were used in a different context. Also, this confused QtCreator.
2021-01-17AudioServer+LibAudio: Pass audio buffers as Core::AnonymousBufferAndreas Kling
This was the last remaining user of shbufs! :^)
2021-01-16Everywhere: Remove a bunch of <AK/SharedBuffer.h> includesAndreas Kling
2021-01-12Libraries: Move to Userland/Libraries/Andreas Kling