Skip to content

Can we implement Source::total_duration for non-wav sources? #190

@icefoxen

Description

@icefoxen

The question was brought up by this ggez issue: ggez/ggez#477 Edit for clarification: Basically, we just want to be able to find the duration of the decoded stream without having to actually decode the whole thing.

It does indeed appear to be correct that only the WAV decoder implements this method. rodio's stream-based API does seem like it might be problematic, but the method only exists when the stream is Seek, so I think we can manage it.

Looking at the various upstream crates, does the functionality exist to do this without having to decode the entire stream in the process?

  • lewton: https://docs.rs/lewton/0.9.1/lewton/audio/fn.get_decoded_sample_count.html
  • minimp3: Doesn't look like it, though I am pretty darn sure that the C library provides the capability to do this. Just need to write a function that skims through the blocks in the stream reading the metadata without bothering to decode the individual blocks.
  • claxon: I think this has the relevant info, but it doesn't seem reliable (the samples field is an Option) and I'm not sure if there's a nicer way to get to it

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions