mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 03:42:44 +00:00 
			
		
		
		
	 a34e369252
			
		
	
	
		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.
		
			
				
	
	
		
			28 lines
		
	
	
	
		
			687 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
	
		
			687 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #include <LibWeb/Platform/AudioCodecPlugin.h>
 | |
| 
 | |
| namespace Web::Platform {
 | |
| 
 | |
| static Function<ErrorOr<NonnullOwnPtr<AudioCodecPlugin>>()> s_creation_hook;
 | |
| 
 | |
| AudioCodecPlugin::AudioCodecPlugin() = default;
 | |
| AudioCodecPlugin::~AudioCodecPlugin() = default;
 | |
| 
 | |
| void AudioCodecPlugin::install_creation_hook(Function<ErrorOr<NonnullOwnPtr<AudioCodecPlugin>>()> creation_hook)
 | |
| {
 | |
|     VERIFY(!s_creation_hook);
 | |
|     s_creation_hook = move(creation_hook);
 | |
| }
 | |
| 
 | |
| ErrorOr<NonnullOwnPtr<AudioCodecPlugin>> AudioCodecPlugin::create()
 | |
| {
 | |
|     VERIFY(s_creation_hook);
 | |
|     return s_creation_hook();
 | |
| }
 | |
| 
 | |
| }
 |