Skip to content

Fix null host - #1369

Open
Marco-Farruggio wants to merge 12 commits into
RustAudio:masterfrom
Marco-Farruggio:fix-null-host
Open

Marco-Farruggio wants to merge 12 commits into
RustAudio:masterfrom
Marco-Farruggio:fix-null-host

Conversation

@Marco-Farruggio

Copy link
Copy Markdown
Contributor

Not sure if we will delete null host for now, but until then this patches up some things :)

@Marco-Farruggio

Copy link
Copy Markdown
Contributor Author

Also, <Host>::new() got moved into the HostTrait, which is probably has a far greater impact than I originally intended, which means doc updates etc, up to ideas on what to do here

@LastExceed LastExceed left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick glance, static only. Although I have a strong suspicion that this is all getting deleted anyway 😁

Comment thread src/platform/mod.rs
Comment on lines +1020 to +1025
#[cfg(feature = "custom")]
pub fn default_host() -> Host {
CustomHost::new()
.expect("the default host should always be available")
.into()
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defaulting to custom host seems counter intuitive to me

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is only because no other hosts exist there, so its either custom or a panic

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm ok if it returned a result I would actually be inclined to an error, but panic is no-go of course

Comment thread src/host/null/mod.rs Outdated
Comment on lines +124 to +140
Error::with_message(DeviceNotAvailable, "Null host in use")
}

fn pause(&self) -> Result<(), Error> {
unimplemented!()
Error::with_message(DeviceNotAvailable, "Null host in use")
}

fn stop(&self, _timeout: Option<std::time::Duration>) -> Result<(), Error> {
unimplemented!()
Error::with_message(DeviceNotAvailable, "Null host in use")
}

fn now(&self) -> StreamInstant {
unimplemented!()
StreamInstant::ZERO
}

fn buffer_size(&self) -> Result<FrameCount, Error> {
unimplemented!()
Error::with_message(DeviceNotAvailable, "Null host in use")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about adding a private field to Device and Stream so it is impossible to get an instance of them? then the functions could be left unimplemented

@Marco-Farruggio

Copy link
Copy Markdown
Contributor Author

If you mean the PR or the null host, either way they will probably both get deleted 😆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants