Skip to content

Commit 72d199e

Browse files
authored
Merge pull request #931 from jstasiak/doc-audiodevice-lock
Try to guide AudioDevice users towards the lock method
2 parents 60a4b27 + ca6bfb1 commit 72d199e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/sdl2/audio.rs

+14
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ use crate::sys::SDL_AudioStatus;
7070

7171
impl AudioSubsystem {
7272
/// Opens a new audio device given the desired parameters and callback.
73+
///
74+
/// If you want to modify the callback-owned data at a later point (for example to update
75+
/// its data buffer) you're likely to be interested in the
76+
/// [AudioDevice.lock method](audio/struct.AudioDevice.html#method.lock).
7377
#[inline]
7478
pub fn open_playback<'a, CB, F, D>(&self, device: D, spec: &AudioSpecDesired, get_callback: F) -> Result<AudioDevice <CB>, String>
7579
where CB: AudioCallback, F: FnOnce(AudioSpec) -> CB, D: Into<Option<&'a str>>,
@@ -79,6 +83,10 @@ impl AudioSubsystem {
7983

8084
/// Opens a new audio device for capture (given the desired parameters and callback).
8185
/// Supported since SDL 2.0.5
86+
///
87+
/// If you want to modify the callback-owned data at a later point (for example to update
88+
/// its data buffer) you're likely to be interested in the
89+
/// [AudioDevice.lock method](audio/struct.AudioDevice.html#method.lock).
8290
pub fn open_capture<'a, CB, F, D>(&self, device: D, spec: &AudioSpecDesired, get_callback: F) -> Result<AudioDevice <CB>, String>
8391
where CB: AudioCallback, F: FnOnce(AudioSpec) -> CB, D: Into<Option<&'a str>>,
8492
{
@@ -646,6 +654,9 @@ impl<CB: AudioCallback> AudioDevice<CB> {
646654
}
647655

648656
/// Opens a new audio device for playback (given the desired parameters and callback).
657+
///
658+
/// If you want to modify the callback-owned data at a later point (for example to update
659+
/// its data buffer) you're likely to be interested in the [lock method](#method.lock).
649660
pub fn open_playback<'a, F, D>(a: &AudioSubsystem, device: D, spec: &AudioSpecDesired, get_callback: F) -> Result<AudioDevice <CB>, String>
650661
where
651662
F: FnOnce(AudioSpec) -> CB,
@@ -656,6 +667,9 @@ impl<CB: AudioCallback> AudioDevice<CB> {
656667

657668
/// Opens a new audio device for capture (given the desired parameters and callback).
658669
/// Supported since SDL 2.0.5
670+
///
671+
/// If you want to modify the callback-owned data at a later point (for example to update
672+
/// its data buffer) you're likely to be interested in the [lock method](#method.lock).
659673
pub fn open_capture<'a, F, D>(a: &AudioSubsystem, device: D, spec: &AudioSpecDesired, get_callback: F) -> Result<AudioDevice <CB>, String>
660674
where
661675
F: FnOnce(AudioSpec) -> CB,

0 commit comments

Comments
 (0)