nandi/jolt-nativepublic Fork 0
cfd3e3677bed92e80cfe447469a249cfdc0b1401
Commits
Clone
git clone https://git.rickub.com/nandi/jolt-native.git
git clone ssh://git@rickub.com/nandi/jolt-native.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

mod.rs · 170 lines · 4.1 KBRust Blame HistoryRaw
Lift freeq's AV media plane out of sleek 90f8b89 nandi 20d ago1//! Null backend implementation.
2//!
3//! Fallback no-op backend for unsupported platforms.
4
5use std::time::Duration;
6
7use crate::traits::{DeviceTrait, HostTrait, StreamTrait};
8use crate::{
9 BuildStreamError, Data, DefaultStreamConfigError, DeviceDescription, DeviceDescriptionBuilder,
10 DeviceId, DeviceIdError, DeviceNameError, DevicesError, InputCallbackInfo, OutputCallbackInfo,
11 PauseStreamError, PlayStreamError, SampleFormat, StreamConfig, StreamError,
12 SupportedStreamConfig, SupportedStreamConfigRange, SupportedStreamConfigsError,
13};
14
15#[derive(Default)]
16pub struct Devices;
17
18#[derive(Clone, Debug, PartialEq, Eq, Hash)]
19pub struct Device;
20
21pub struct Host;
22
23#[derive(Debug, Clone, PartialEq, Eq, Hash)]
24pub struct Stream;
25
26// Compile-time assertion that Stream is Send and Sync
27crate::assert_stream_send!(Stream);
28crate::assert_stream_sync!(Stream);
29
30#[derive(Clone)]
31pub struct SupportedInputConfigs;
32#[derive(Clone)]
33pub struct SupportedOutputConfigs;
34
35impl Host {
36 #[allow(dead_code)]
37 pub fn new() -> Result<Self, crate::HostUnavailable> {
38 Ok(Host)
39 }
40}
41
42impl Devices {
43 pub fn new() -> Result<Self, DevicesError> {
44 Ok(Devices)
45 }
46}
47
48impl DeviceTrait for Device {
49 type SupportedInputConfigs = SupportedInputConfigs;
50 type SupportedOutputConfigs = SupportedOutputConfigs;
51 type Stream = Stream;
52
53 fn name(&self) -> Result<String, DeviceNameError> {
54 Ok("null".to_string())
55 }
56
57 fn description(&self) -> Result<DeviceDescription, DeviceNameError> {
58 Ok(DeviceDescriptionBuilder::new("Null Device".to_string()).build())
59 }
60
61 fn id(&self) -> Result<DeviceId, DeviceIdError> {
62 Ok(DeviceId(crate::platform::HostId::Null, String::new()))
63 }
64
65 fn supported_input_configs(
66 &self,
67 ) -> Result<SupportedInputConfigs, SupportedStreamConfigsError> {
68 unimplemented!()
69 }
70
71 fn supported_output_configs(
72 &self,
73 ) -> Result<SupportedOutputConfigs, SupportedStreamConfigsError> {
74 unimplemented!()
75 }
76
77 fn default_input_config(&self) -> Result<SupportedStreamConfig, DefaultStreamConfigError> {
78 unimplemented!()
79 }
80
81 fn default_output_config(&self) -> Result<SupportedStreamConfig, DefaultStreamConfigError> {
82 unimplemented!()
83 }
84
85 fn build_input_stream_raw<D, E>(
86 &self,
87 _config: StreamConfig,
88 _sample_format: SampleFormat,
89 _data_callback: D,
90 _error_callback: E,
91 _timeout: Option<Duration>,
92 ) -> Result<Self::Stream, BuildStreamError>
93 where
94 D: FnMut(&Data, &InputCallbackInfo) + Send + 'static,
95 E: FnMut(StreamError) + Send + 'static,
96 {
97 unimplemented!()
98 }
99
100 /// Create an output stream.
101 fn build_output_stream_raw<D, E>(
102 &self,
103 _config: StreamConfig,
104 _sample_format: SampleFormat,
105 _data_callback: D,
106 _error_callback: E,
107 _timeout: Option<Duration>,
108 ) -> Result<Self::Stream, BuildStreamError>
109 where
110 D: FnMut(&mut Data, &OutputCallbackInfo) + Send + 'static,
111 E: FnMut(StreamError) + Send + 'static,
112 {
113 unimplemented!()
114 }
115}
116
117impl HostTrait for Host {
118 type Devices = Devices;
119 type Device = Device;
120
121 fn is_available() -> bool {
122 false
123 }
124
125 fn devices(&self) -> Result<Self::Devices, DevicesError> {
126 Devices::new()
127 }
128
129 fn default_input_device(&self) -> Option<Device> {
130 None
131 }
132
133 fn default_output_device(&self) -> Option<Device> {
134 None
135 }
136}
137
138impl StreamTrait for Stream {
139 fn play(&self) -> Result<(), PlayStreamError> {
140 unimplemented!()
141 }
142
143 fn pause(&self) -> Result<(), PauseStreamError> {
144 unimplemented!()
145 }
146}
147
148impl Iterator for Devices {
149 type Item = Device;
150
151 fn next(&mut self) -> Option<Device> {
152 None
153 }
154}
155
156impl Iterator for SupportedInputConfigs {
157 type Item = SupportedStreamConfigRange;
158
159 fn next(&mut self) -> Option<SupportedStreamConfigRange> {
160 None
161 }
162}
163
164impl Iterator for SupportedOutputConfigs {
165 type Item = SupportedStreamConfigRange;
166
167 fn next(&mut self) -> Option<SupportedStreamConfigRange> {
168 None
169 }
170}