From 934b1c052504b90baa3b4f5481c70e7a4bb4c382 Mon Sep 17 00:00:00 2001 From: weixubin Date: Mon, 22 Apr 2024 16:20:14 +0800 Subject: [PATCH] Add comment about Sink and OutputStream --- src/lib.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 83f16c7..77f411b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -50,7 +50,8 @@ //! use std::time::Duration; //! use rodio::{Decoder, OutputStream, Sink}; //! use rodio::source::{SineWave, Source}; -//! +//! +//! // _stream must live as long as the sink //! let (_stream, stream_handle) = OutputStream::try_default().unwrap(); //! let sink = Sink::try_new(&stream_handle).unwrap(); //! @@ -68,6 +69,8 @@ //! sounds to play simultaneously, you should create multiple [`Sink`]s. //! //! The [`Sink`] type also provides utilities such as playing/pausing or controlling the volume. +//! +//! **Please note that the [`Sink`] requires the [`OutputStream`], thus ensuring that it has to live as long as the sink.** //! //! ## Filters //!