pcm_reader_t *raw_open(pcm_io_context_t *io,
                       const pcm_sample_description_t *desc)
{
    wav_reader_t *reader = 0;

    if ((reader = calloc(1, sizeof(wav_reader_t))) == 0)
        return 0;
    memcpy(&reader->io, io, sizeof(pcm_io_context_t));
    memcpy(&reader->sample_format, desc, sizeof(pcm_sample_description_t));
    if (pcm_seek(&reader->io, 0, SEEK_END) >= 0) {
        int64_t size = pcm_tell(&reader->io);
        if (size > 0)
            reader->length = size / reader->sample_format.bytes_per_frame;
        pcm_seek(&reader->io, 0, SEEK_SET);
    } else
        reader->length = INT64_MAX;
    reader->vtbl = &wav_vtable;
    return (pcm_reader_t *)reader;
}
pcm_reader_t *raw_open(pcm_io_context_t *io,
                       const pcm_sample_description_t *desc)
{
    wav_reader_t *reader = 0;

    if ((reader = calloc(1, sizeof(wav_reader_t))) == 0)
        return 0;
    memcpy(&reader->io, io, sizeof(pcm_io_context_t));
    memcpy(&reader->sample_format, desc, sizeof(pcm_sample_description_t));
    if (pcm_seek(&reader->io, 0, SEEK_END) >= 0) {
        int64_t size = pcm_tell(&reader->io);
        if (size > 0)
            reader->length = size / reader->sample_format.bytes_per_frame;
        pcm_seek(&reader->io, 0, SEEK_SET);
    } else
        reader->length = INT64_MAX;
    reader->vtbl = &wav_vtable;
    return (pcm_reader_t *)reader;
}