LibMedia: Remove AudioQueue and UserSampleQueue

Both unused.
This commit is contained in:
Jelle Raaijmakers 2024-08-28 13:14:15 +02:00 committed by Andreas Kling
parent 7728633906
commit 3bf910706f
Notes: github-actions[bot] 2024-09-12 08:02:27 +00:00
6 changed files with 1 additions and 138 deletions

View file

@ -12,7 +12,6 @@ shared_library("LibMedia") {
"Audio/QOALoader.cpp",
"Audio/QOATypes.cpp",
"Audio/SampleFormats.cpp",
"Audio/UserSampleQueue.cpp",
"Audio/VorbisComment.cpp",
"Audio/WavLoader.cpp",
]

View file

@ -6,11 +6,11 @@
#pragma once
#include "Queue.h"
#include "SampleFormats.h"
#include <AK/ByteBuffer.h>
#include <AK/Types.h>
#include <AK/Variant.h>
#include <AK/Vector.h>
#include <LibCrypto/Checksum/CRC16.h>
#include <LibCrypto/Checksum/CRC8.h>

View file

@ -1,21 +0,0 @@
/*
* Copyright (c) 2018-2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include "Sample.h"
#include <LibCore/SharedCircularQueue.h>
namespace Audio {
static constexpr size_t AUDIO_BUFFERS_COUNT = 128;
// The audio buffer size is specifically chosen to be about 1/1000th of a second (1ms).
// This has the biggest impact on latency and performance.
// The currently chosen value was not put here with much thought and a better choice is surely possible.
static constexpr size_t AUDIO_BUFFER_SIZE = 50;
using AudioQueue = Core::SharedSingleProducerCircularQueue<Array<Sample, AUDIO_BUFFER_SIZE>, AUDIO_BUFFERS_COUNT>;
}

View file

@ -1,64 +0,0 @@
/*
* Copyright (c) 2022, kleines Filmröllchen <filmroellchen@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "UserSampleQueue.h"
namespace Audio {
void UserSampleQueue::append(FixedArray<Sample>&& samples)
{
Threading::MutexLocker lock(m_sample_mutex);
if (m_samples_to_discard != 0)
m_backing_samples = m_backing_samples.release_slice(m_samples_to_discard);
m_backing_samples.append(move(samples));
fix_spans();
}
void UserSampleQueue::clear()
{
discard_samples(size());
}
void UserSampleQueue::fix_spans()
{
Threading::MutexLocker lock(m_sample_mutex);
m_enqueued_samples = m_backing_samples.spans();
m_samples_to_discard = 0;
}
Sample UserSampleQueue::operator[](size_t index)
{
Threading::MutexLocker lock(m_sample_mutex);
return m_enqueued_samples[index];
}
void UserSampleQueue::discard_samples(size_t count)
{
Threading::MutexLocker lock(m_sample_mutex);
m_samples_to_discard += count;
m_enqueued_samples = m_enqueued_samples.slice(count);
}
size_t UserSampleQueue::size()
{
Threading::MutexLocker lock(m_sample_mutex);
return m_enqueued_samples.size();
}
size_t UserSampleQueue::remaining_samples()
{
Threading::MutexLocker lock(m_sample_mutex);
VERIFY(m_backing_samples.size() >= m_samples_to_discard);
return m_backing_samples.size() - m_samples_to_discard;
}
bool UserSampleQueue::is_empty()
{
Threading::MutexLocker lock(m_sample_mutex);
return m_enqueued_samples.is_empty();
}
}

View file

@ -1,50 +0,0 @@
/*
* Copyright (c) 2022, kleines Filmröllchen <filmroellchen@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include "Sample.h"
#include <AK/DisjointChunks.h>
#include <AK/FixedArray.h>
#include <AK/Noncopyable.h>
#include <AK/Vector.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 {};
};
}

View file

@ -9,7 +9,6 @@ set(SOURCES
Audio/PlaybackStream.cpp
Audio/QOALoader.cpp
Audio/QOATypes.cpp
Audio/UserSampleQueue.cpp
Audio/VorbisComment.cpp
Color/ColorConverter.cpp
Color/ColorPrimaries.cpp