mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
a34e369252
This creates (and installs upon WebContent startup) a platform plugin to play audio data. On Serenity, we use AudioServer to play audio over IPC. Unfortunately, AudioServer is currently coupled with Serenity's audio devices, and thus cannot be used in Ladybird on Lagom. Instead, we use a Qt audio device to play the audio, which requires the Qt multimedia package. While we use Qt to play the audio, note that we can still use LibAudio to decode the audio data and retrieve samples - we simply send Qt the raw PCM signals.
42 lines
1.1 KiB
C++
42 lines
1.1 KiB
C++
/*
|
|
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Error.h>
|
|
#include <AK/NonnullOwnPtr.h>
|
|
#include <LibAudio/Forward.h>
|
|
#include <LibWeb/Platform/AudioCodecPlugin.h>
|
|
|
|
class QAudioSink;
|
|
class QIODevice;
|
|
class QMediaDevices;
|
|
|
|
namespace Ladybird {
|
|
|
|
class AudioCodecPluginLadybird final : public Web::Platform::AudioCodecPlugin {
|
|
public:
|
|
static ErrorOr<NonnullOwnPtr<AudioCodecPluginLadybird>> create();
|
|
virtual ~AudioCodecPluginLadybird() override;
|
|
|
|
virtual size_t device_sample_rate() override;
|
|
|
|
virtual void enqueue_samples(FixedArray<Audio::Sample>) override;
|
|
virtual size_t remaining_samples() const override;
|
|
|
|
virtual void resume_playback() override;
|
|
virtual void pause_playback() override;
|
|
virtual void playback_ended() override;
|
|
|
|
private:
|
|
AudioCodecPluginLadybird(NonnullOwnPtr<QMediaDevices>, NonnullOwnPtr<QAudioSink>);
|
|
|
|
NonnullOwnPtr<QMediaDevices> m_devices;
|
|
NonnullOwnPtr<QAudioSink> m_audio_output;
|
|
QIODevice* m_io_device { nullptr };
|
|
};
|
|
|
|
}
|