From 66bbe167b8121303f76129f60ee7a10e96c71536 Mon Sep 17 00:00:00 2001 From: moeur Date: Mon, 14 Nov 2022 20:24:21 +0300 Subject: [PATCH 1/5] document file formats for `bytes` field of `AudioSource` --- crates/bevy_audio/src/audio_source.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_audio/src/audio_source.rs b/crates/bevy_audio/src/audio_source.rs index 217c9aa868350..322a2d7967004 100644 --- a/crates/bevy_audio/src/audio_source.rs +++ b/crates/bevy_audio/src/audio_source.rs @@ -8,7 +8,7 @@ use std::{io::Cursor, sync::Arc}; #[derive(Debug, Clone, TypeUuid)] #[uuid = "7a14806a-672b-443b-8d16-4f18afefa463"] pub struct AudioSource { - /// Raw data of the audio source + /// Raw data of the audio source, which must be in one of the file formats supported by Bevy (wav, ogg, flac or mp3). pub bytes: Arc<[u8]>, } From 53d04970642b436c61b47c8a9756717ad966c737 Mon Sep 17 00:00:00 2001 From: moeur Date: Tue, 15 Nov 2022 08:26:23 +0300 Subject: [PATCH 2/5] specify that features need to be enabled for certain formats --- crates/bevy_audio/src/audio_source.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_audio/src/audio_source.rs b/crates/bevy_audio/src/audio_source.rs index 322a2d7967004..0dd259aeb0a81 100644 --- a/crates/bevy_audio/src/audio_source.rs +++ b/crates/bevy_audio/src/audio_source.rs @@ -8,7 +8,7 @@ use std::{io::Cursor, sync::Arc}; #[derive(Debug, Clone, TypeUuid)] #[uuid = "7a14806a-672b-443b-8d16-4f18afefa463"] pub struct AudioSource { - /// Raw data of the audio source, which must be in one of the file formats supported by Bevy (wav, ogg, flac or mp3). + /// Raw data of the audio source, which must be in one of the file formats supported by Bevy (wav, ogg, flac or mp3). wav, flac and mp3 require their respective flags to be enabled so that they can be decoded, as `Rodio::Decode` (which Bevy uses internally for audio) compiles specific functions for each format depending on the enabled feature. pub bytes: Arc<[u8]>, } From 6d8fa2da98f0dc1425aeebe9f4059c54ac0c879f Mon Sep 17 00:00:00 2001 From: dis-da-moe <84386186+dis-da-moe@users.noreply.github.com> Date: Tue, 15 Nov 2022 09:39:01 +0300 Subject: [PATCH 3/5] format doc for `bytes` field of `AudioSource` crates/bevy_audio/src/audio_source.rs Co-authored-by: harudagondi --- crates/bevy_audio/src/audio_source.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/bevy_audio/src/audio_source.rs b/crates/bevy_audio/src/audio_source.rs index 0dd259aeb0a81..10a40a7798160 100644 --- a/crates/bevy_audio/src/audio_source.rs +++ b/crates/bevy_audio/src/audio_source.rs @@ -8,7 +8,15 @@ use std::{io::Cursor, sync::Arc}; #[derive(Debug, Clone, TypeUuid)] #[uuid = "7a14806a-672b-443b-8d16-4f18afefa463"] pub struct AudioSource { - /// Raw data of the audio source, which must be in one of the file formats supported by Bevy (wav, ogg, flac or mp3). wav, flac and mp3 require their respective flags to be enabled so that they can be decoded, as `Rodio::Decode` (which Bevy uses internally for audio) compiles specific functions for each format depending on the enabled feature. + /// Raw data of the audio source. + /// + /// The data must be one of the file formats supported by Bevy (`wav`, `ogg`, `flac`, or `mp3`). + /// It is decoded using [`rodio::decoder::Decoder`]. + /// + /// The decoder has conditionally compiled methods + /// depending on the features enabled. + /// If the format used is not enabled, + /// then this will panic with an `UnrecognizedFormat` error. pub bytes: Arc<[u8]>, } From efd76aa4c5b01f2ff52ae3f9fa2b9638e62b1aee Mon Sep 17 00:00:00 2001 From: moeur Date: Tue, 15 Nov 2022 09:50:49 +0300 Subject: [PATCH 4/5] fix formatting --- crates/bevy_audio/src/audio_source.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/bevy_audio/src/audio_source.rs b/crates/bevy_audio/src/audio_source.rs index 10a40a7798160..88e7c0cf7cef1 100644 --- a/crates/bevy_audio/src/audio_source.rs +++ b/crates/bevy_audio/src/audio_source.rs @@ -8,15 +8,15 @@ use std::{io::Cursor, sync::Arc}; #[derive(Debug, Clone, TypeUuid)] #[uuid = "7a14806a-672b-443b-8d16-4f18afefa463"] pub struct AudioSource { - /// Raw data of the audio source. - /// - /// The data must be one of the file formats supported by Bevy (`wav`, `ogg`, `flac`, or `mp3`). - /// It is decoded using [`rodio::decoder::Decoder`]. - /// - /// The decoder has conditionally compiled methods - /// depending on the features enabled. - /// If the format used is not enabled, - /// then this will panic with an `UnrecognizedFormat` error. + /// Raw data of the audio source. + /// + /// The data must be one of the file formats supported by Bevy (`wav`, `ogg`, `flac`, or `mp3`). + /// It is decoded using [`rodio::decoder::Decoder`]. + /// + /// The decoder has conditionally compiled methods + /// depending on the features enabled. + /// If the format used is not enabled, + /// then this will panic with an `UnrecognizedFormat` error. pub bytes: Arc<[u8]>, } From ef1f05500bc1dd1c9570ff518910ed7ba8add0e8 Mon Sep 17 00:00:00 2001 From: moeur Date: Tue, 15 Nov 2022 10:02:58 +0300 Subject: [PATCH 5/5] fix link for --- crates/bevy_audio/src/audio_source.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_audio/src/audio_source.rs b/crates/bevy_audio/src/audio_source.rs index 88e7c0cf7cef1..470eccd04f59e 100644 --- a/crates/bevy_audio/src/audio_source.rs +++ b/crates/bevy_audio/src/audio_source.rs @@ -11,7 +11,7 @@ pub struct AudioSource { /// Raw data of the audio source. /// /// The data must be one of the file formats supported by Bevy (`wav`, `ogg`, `flac`, or `mp3`). - /// It is decoded using [`rodio::decoder::Decoder`]. + /// It is decoded using [`rodio::decoder::Decoder`](https://docs.rs/rodio/latest/rodio/decoder/struct.Decoder.html). /// /// The decoder has conditionally compiled methods /// depending on the features enabled.