mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-04 09:14:21 +03:00
6fd478b6ce
These instances were detected by searching for files that include AK/Format.h, but don't match the regex: \\b(CheckedFormatString|critical_dmesgln|dbgln|dbgln_if|dmesgln|FormatBu ilder|__FormatIfSupported|FormatIfSupported|FormatParser|FormatString|Fo rmattable|Formatter|__format_value|HasFormatter|max_format_arguments|out |outln|set_debug_enabled|StandardFormatter|TypeErasedFormatParams|TypeEr asedParameter|VariadicFormatParams|v_critical_dmesgln|vdbgln|vdmesgln|vf ormat|vout|warn|warnln|warnln_if)\\b (Without the linebreaks.) This regex is pessimistic, so there might be more files that don't actually use any formatting functions. Observe that this revealed that Userland/Libraries/LibC/signal.cpp is missing an include. In theory, one might use LibCPP to detect things like this automatically, but let's do this one step after another.
51 lines
1.4 KiB
C++
51 lines
1.4 KiB
C++
/*
|
|
* Copyright (c) 2022, kleines Filmröllchen <filmroellchen@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/DisjointChunks.h>
|
|
#include <AK/FixedArray.h>
|
|
#include <AK/Noncopyable.h>
|
|
#include <AK/Vector.h>
|
|
#include <LibAudio/Sample.h>
|
|
#include <LibThreading/Mutex.h>
|
|
|
|
namespace Audio {
|
|
|
|
// A sample queue providing synchronized access to efficiently-stored segmented user-provided audio data.
|
|
class UserSampleQueue {
|
|
AK_MAKE_NONCOPYABLE(UserSampleQueue);
|
|
AK_MAKE_NONMOVABLE(UserSampleQueue);
|
|
|
|
public:
|
|
UserSampleQueue() = default;
|
|
|
|
void append(FixedArray<Sample>&& samples);
|
|
void clear();
|
|
// Slice off some amount of samples from the beginning.
|
|
void discard_samples(size_t count);
|
|
Sample operator[](size_t index);
|
|
|
|
// The number of samples in the span.
|
|
size_t size();
|
|
bool is_empty();
|
|
size_t remaining_samples();
|
|
|
|
private:
|
|
// Re-initialize the spans after a vector resize.
|
|
void fix_spans();
|
|
|
|
Threading::Mutex m_sample_mutex;
|
|
// Sample data view to keep track of what to play next.
|
|
DisjointSpans<Sample> m_enqueued_samples;
|
|
// The number of samples that were played from the backing store since last discarding its start.
|
|
size_t m_samples_to_discard { 0 };
|
|
// The backing store for the enqueued sample view.
|
|
DisjointChunks<Sample, FixedArray<Sample>> m_backing_samples {};
|
|
};
|
|
|
|
}
|