mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 19:22:45 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			38 lines
		
	
	
	
		
			1.4 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
	
		
			1.4 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2023, Gregory Bertilson <zaggy1024@gmail.com>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #include "PlaybackStream.h"
 | |
| 
 | |
| #include <AK/Platform.h>
 | |
| #include <LibCore/ThreadedPromise.h>
 | |
| 
 | |
| #if defined(AK_OS_SERENITY)
 | |
| #    include <LibAudio/PlaybackStreamSerenity.h>
 | |
| #elif defined(HAVE_PULSEAUDIO)
 | |
| #    include <LibAudio/PlaybackStreamPulseAudio.h>
 | |
| #elif defined(AK_OS_MACOS)
 | |
| #    include <LibAudio/PlaybackStreamAudioUnit.h>
 | |
| #endif
 | |
| 
 | |
| namespace Audio {
 | |
| 
 | |
| ErrorOr<NonnullRefPtr<PlaybackStream>> PlaybackStream::create(OutputState initial_output_state, u32 sample_rate, u8 channels, u32 target_latency_ms, AudioDataRequestCallback&& data_request_callback)
 | |
| {
 | |
|     VERIFY(data_request_callback);
 | |
|     // Create the platform-specific implementation for this stream.
 | |
| #if defined(AK_OS_SERENITY)
 | |
|     return PlaybackStreamSerenity::create(initial_output_state, sample_rate, channels, target_latency_ms, move(data_request_callback));
 | |
| #elif defined(HAVE_PULSEAUDIO)
 | |
|     return PlaybackStreamPulseAudio::create(initial_output_state, sample_rate, channels, target_latency_ms, move(data_request_callback));
 | |
| #elif defined(AK_OS_MACOS)
 | |
|     return PlaybackStreamAudioUnit::create(initial_output_state, sample_rate, channels, target_latency_ms, move(data_request_callback));
 | |
| #else
 | |
|     (void)initial_output_state, (void)sample_rate, (void)channels, (void)target_latency_ms;
 | |
|     return Error::from_string_literal("Audio output is not available for this platform");
 | |
| #endif
 | |
| }
 | |
| 
 | |
| }
 | 
