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