(&self, source: &str)
| 213 | pub fn new(static_audio_lookup: Option<fn(u64) -> &'static [u8]>) -> Result<Self, String> { |
| 214 | if audio_disabled_by_env() { |
| 215 | return Err(format!("audio disabled by {AUDIO_DISABLED_ENV}")); |
| 216 | } |
| 217 | |
| 218 | Self::new_with_player_factory(static_audio_lookup, BarkPlayer::new) |
| 219 | } |
| 220 | |
| 221 | fn new_with_player_factory<F>( |
| 222 | static_audio_lookup: Option<fn(u64) -> &'static [u8]>, |
| 223 | player_factory: F, |
| 224 | ) -> Result<Self, String> |
| 225 | where |
| 226 | F: FnOnce(Option<fn(u64) -> &'static [u8]>) -> Result<BarkPlayer, String> + Send + 'static, |
| 227 | { |
| 228 | let (tx, rx) = crossbeam_channel::bounded::<AudioCommand>(Self::COMMAND_QUEUE_CAPACITY); |
| 229 | let (startup_tx, startup_rx) = crossbeam_channel::bounded::<Result<(), String>>(1); |
| 230 | let next_playback_id = Arc::new(AtomicU64::new(1)); |
| 231 | let loaded = Arc::new(Mutex::new(AudioLoadedState::default())); |
no test coverage detected