mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 16:32:45 +00:00 
			
		
		
		
	 8464da1439
			
		
	
	
		8464da1439
		
	
	
	
	
		
			
			`Stream` will be qualified as `AK::Stream` until we remove the `Core::Stream` namespace. `IODevice` now reuses the `SeekMode` that is defined by `SeekableStream`, since defining its own would require us to qualify it with `AK::SeekMode` everywhere.
		
			
				
	
	
		
			70 lines
		
	
	
	
		
			1.7 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			70 lines
		
	
	
	
		
			1.7 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2018-2021, the SerenityOS developers.
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #include <LibAudio/FlacLoader.h>
 | |
| #include <LibAudio/Loader.h>
 | |
| #include <LibAudio/MP3Loader.h>
 | |
| #include <LibAudio/WavLoader.h>
 | |
| 
 | |
| namespace Audio {
 | |
| 
 | |
| LoaderPlugin::LoaderPlugin(NonnullOwnPtr<SeekableStream> stream)
 | |
|     : m_stream(move(stream))
 | |
| {
 | |
| }
 | |
| 
 | |
| Loader::Loader(NonnullOwnPtr<LoaderPlugin> plugin)
 | |
|     : m_plugin(move(plugin))
 | |
| {
 | |
| }
 | |
| 
 | |
| Result<NonnullOwnPtr<LoaderPlugin>, LoaderError> Loader::create_plugin(StringView path)
 | |
| {
 | |
|     {
 | |
|         auto plugin = WavLoaderPlugin::create(path);
 | |
|         if (!plugin.is_error())
 | |
|             return NonnullOwnPtr<LoaderPlugin>(plugin.release_value());
 | |
|     }
 | |
| 
 | |
|     {
 | |
|         auto plugin = FlacLoaderPlugin::create(path);
 | |
|         if (!plugin.is_error())
 | |
|             return NonnullOwnPtr<LoaderPlugin>(plugin.release_value());
 | |
|     }
 | |
| 
 | |
|     {
 | |
|         auto plugin = MP3LoaderPlugin::create(path);
 | |
|         if (!plugin.is_error())
 | |
|             return NonnullOwnPtr<LoaderPlugin>(plugin.release_value());
 | |
|     }
 | |
| 
 | |
|     return LoaderError { "No loader plugin available" };
 | |
| }
 | |
| 
 | |
| Result<NonnullOwnPtr<LoaderPlugin>, LoaderError> Loader::create_plugin(Bytes buffer)
 | |
| {
 | |
|     {
 | |
|         auto plugin = WavLoaderPlugin::create(buffer);
 | |
|         if (!plugin.is_error())
 | |
|             return NonnullOwnPtr<LoaderPlugin>(plugin.release_value());
 | |
|     }
 | |
| 
 | |
|     {
 | |
|         auto plugin = FlacLoaderPlugin::create(buffer);
 | |
|         if (!plugin.is_error())
 | |
|             return NonnullOwnPtr<LoaderPlugin>(plugin.release_value());
 | |
|     }
 | |
| 
 | |
|     {
 | |
|         auto plugin = MP3LoaderPlugin::create(buffer);
 | |
|         if (!plugin.is_error())
 | |
|             return NonnullOwnPtr<LoaderPlugin>(plugin.release_value());
 | |
|     }
 | |
| 
 | |
|     return LoaderError { "No loader plugin available" };
 | |
| }
 | |
| 
 | |
| }
 |