Skip to content

get_last_absgp returns None for the first stream #84

@TonalidadeHidrica

Description

@TonalidadeHidrica

The following is a snippet that reads first 30 packets from an ogg file.

    use lewton::inside_ogg::OggStreamReader;
    use std::io::BufReader;
    use std::fs::File;
    let reader = BufReader::new(File::open("some_ogg_file.ogg").unwrap());
    let mut reader = OggStreamReader::new(reader).unwrap();
    dbg!(reader.get_last_absgp());
    let mut i = 0;
    while let Some(_packet) = reader.read_dec_packet().unwrap() {
        dbg!(reader.get_last_absgp());
        i += 1;
        if i >= 30 {
            break;
        }
    }

It is reasonable that get_last_absgp returns None before reading any packet, but the program above actually output 23 Nones, followed by 7 reasonable values. Reading the code, I realized that cur_absgp is never updated for the first stream, but updated for the second and subsequent streams. Is this an intended behaviour, or just a bug?

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