66//!
77//! # Features
88//!
9- //! - **Bit depths**: Full support for 8, 16, 24, and 32-bit audio (including 12 and 20-bit)
9+ //! - **Bit depths**: Full support for 8, 12, 16, 20, 24, and 32-bit audio
1010//! - **Sample rates**: Supports all FLAC-compatible sample rates (1Hz to 655,350Hz)
1111//! - **Channels**: Supports mono, stereo, and multi-channel audio (up to 8 channels)
1212//! - **Seeking**: Full forward and backward seeking with sample-accurate positioning
@@ -80,7 +80,7 @@ use crate::{
8080
8181/// Reader options for `claxon` FLAC decoder.
8282///
83- /// Configured to skip metadata parsing and vorbis comments for faster initialization.
83+ /// Configured to skip metadata parsing and Vorbis comments for faster initialization.
8484/// This improves decoder creation performance by only parsing essential stream information
8585/// needed for audio playback.
8686///
@@ -139,7 +139,7 @@ where
139139 ///
140140 /// Used for calculating the correct memory layout when accessing interleaved samples.
141141 /// FLAC blocks can have variable sizes, so this changes per block.
142- current_block_channel_len : usize ,
142+ current_block_samples_per_channel : usize ,
143143
144144 /// Current position within the current block.
145145 ///
@@ -297,7 +297,7 @@ where
297297 Ok ( Self {
298298 reader : Some ( reader) ,
299299 current_block : Vec :: with_capacity ( max_block_size) ,
300- current_block_channel_len : 1 ,
300+ current_block_samples_per_channel : 1 ,
301301 current_block_off : 0 ,
302302 bits_per_sample : spec. bits_per_sample ,
303303 sample_rate : SampleRate :: new ( sample_rate)
@@ -350,15 +350,10 @@ where
350350{
351351 /// Returns the number of samples before parameters change.
352352 ///
353- /// For FLAC, this always returns `None` because audio parameters (sample rate, channels, bit
354- /// depth) never change during the stream. This allows Rodio to optimize by not frequently
355- /// checking for parameter changes.
356- ///
357- /// # Implementation Note
353+ /// # Returns
358354 ///
359- /// FLAC streams have fixed parameters throughout their duration, unlike some formats
360- /// that may have parameter changes at specific points. This enables optimizations
361- /// in the audio pipeline by avoiding frequent parameter validation.
355+ /// For FLAC, this always returns `None` because audio parameters (sample rate, channels, bit
356+ /// depth) never change during the stream.
362357 #[ inline]
363358 fn current_span_len ( & self ) -> Option < usize > {
364359 None
@@ -374,26 +369,17 @@ where
374369 ///
375370 /// # Guarantees
376371 ///
377- /// The returned value is constant for the lifetime of the decoder and matches
378- /// the channel count specified in the FLAC stream metadata.
372+ /// The returned value is constant for the lifetime of the decoder.
379373 #[ inline]
380374 fn channels ( & self ) -> ChannelCount {
381375 self . channels
382376 }
383377
384378 /// Returns the sample rate in Hz.
385379 ///
386- /// Common rates that FLAC supports are:
387- /// - **44.1kHz**: CD quality (most common)
388- /// - **48kHz**: Professional audio standard
389- /// - **96kHz**: High-resolution audio
390- /// - **192kHz**: Ultra high-resolution audio
391- ///
392380 /// # Guarantees
393381 ///
394- /// The returned value is constant for the lifetime of the decoder and matches
395- /// the sample rate specified in the FLAC stream metadata. This value is
396- /// available immediately upon decoder creation.
382+ /// The returned value is constant for the lifetime of the decoder.
397383 #[ inline]
398384 fn sample_rate ( & self ) -> SampleRate {
399385 self . sample_rate
@@ -404,32 +390,24 @@ where
404390 /// FLAC metadata contains the total number of samples, allowing accurate duration calculation.
405391 /// This is available immediately upon decoder creation without needing to scan the entire file.
406392 ///
407- /// Returns `None` only for malformed FLAC files missing sample count metadata.
408- ///
409- /// # Accuracy
393+ /// # Returns
410394 ///
411- /// The duration is calculated from exact sample counts, providing sample-accurate
412- /// timing information. This is more precise than duration estimates based on
413- /// bitrate calculations used by lossy formats.
395+ /// Returns `None` only for malformed FLAC files missing sample count metadata.
414396 #[ inline]
415397 fn total_duration ( & self ) -> Option < Duration > {
416398 self . total_duration
417399 }
418400
419401 /// Returns the bit depth of the audio samples.
420402 ///
421- /// FLAC is a lossless format that preserves the original bit depth:
422- /// - 16-bit: Standard CD quality
423- /// - 24-bit: Professional/high-resolution audio
424- /// - 32-bit: Professional/studio quality
425- /// - Other depths: 8, 12, and 20-bit are also supported
426- ///
427- /// Always returns `Some(depth)` for valid FLAC streams.
428- ///
429403 /// # Implementation Note
430404 ///
431- /// The bit depth information is preserved from the original FLAC stream and
405+ /// Up to 24 bits of information is preserved from the original FLAC stream and
432406 /// used for proper sample scaling during conversion to Rodio's sample format.
407+ ///
408+ /// # Returns
409+ ///
410+ /// Always returns `Some(depth)` for valid FLAC streams.
433411 #[ inline]
434412 fn bits_per_sample ( & self ) -> Option < u32 > {
435413 Some ( self . bits_per_sample )
@@ -476,12 +454,6 @@ where
476454 /// // Seek to 30 seconds into the track
477455 /// decoder.try_seek(Duration::from_secs(30)).unwrap();
478456 /// ```
479- ///
480- /// # Implementation Details
481- ///
482- /// The seeking implementation handles channel alignment to ensure that seeking
483- /// to a specific time position results in the correct channel being returned
484- /// for the first sample after the seek operation.
485457 fn try_seek ( & mut self , pos : Duration ) -> Result < ( ) , SeekError > {
486458 // Seeking should be "saturating", meaning: target positions beyond the end of the stream
487459 // are clamped to the end.
@@ -545,9 +517,9 @@ impl<R> Iterator for FlacDecoder<R>
545517where
546518 R : Read + Seek ,
547519{
548- /// The type of items yielded by the iterator.
520+ /// The type of samples yielded by the iterator.
549521 ///
550- /// Returns `Sample` (typically `f32`) values representing individual audio samples.
522+ /// Returns `Sample` values representing individual audio samples.
551523 /// Samples are interleaved across channels in the order: channel 0, channel 1, etc.
552524 type Item = Sample ;
553525
@@ -587,7 +559,7 @@ where
587559 if self . current_block_off < self . current_block . len ( ) {
588560 // Read from current block.
589561 let real_offset = ( self . current_block_off % self . channels . get ( ) as usize )
590- * self . current_block_channel_len
562+ * self . current_block_samples_per_channel
591563 + self . current_block_off / self . channels . get ( ) as usize ;
592564 let raw_val = self . current_block [ real_offset] ;
593565 self . current_block_off += 1 ;
@@ -622,7 +594,8 @@ where
622594 . read_next_or_eof ( buffer)
623595 {
624596 Ok ( Some ( block) ) => {
625- self . current_block_channel_len = ( block. len ( ) / block. channels ( ) ) as usize ;
597+ self . current_block_samples_per_channel =
598+ ( block. len ( ) / block. channels ( ) ) as usize ;
626599 self . current_block = block. into_buffer ( ) ;
627600 }
628601 Ok ( None ) | Err ( _) => {
@@ -634,7 +607,7 @@ where
634607 }
635608 }
636609
637- /// Returns bounds on the remaining length of the iterator .
610+ /// Returns bounds on the remaining amount of samples .
638611 ///
639612 /// Provides accurate size estimates based on FLAC metadata when available.
640613 /// This information can be used by consumers for buffer pre-allocation
0 commit comments