/* * libnogg: a decoder library for Ogg Vorbis streams * Copyright (c) 2014-2024 Andrew Church * * This software may be copied and redistributed under certain conditions; * see the file "COPYING" in the source code distribution for details. * NO WARRANTY is provided with this software. */ /* Normally there is no reason to use residue type 2 in a single-channel * stream (since it is then identical to type 1), but we test to ensure * that it is still handled correctly, since we handle type 2 differently * for single-channel and multiple-channel streams. */ #include "include/nogg.h" #include "tests/common.h" #include "tests/data/square_float.h" // Defines expected_pcm[]. int main(void) { FILE *f; uint8_t *data; long size; EXPECT(f = fopen("tests/data/square.ogg", "rb")); EXPECT_EQ(fseek(f, 0, SEEK_END), 0); EXPECT_GT(size = ftell(f), 0); EXPECT_EQ(fseek(f, 0, SEEK_SET), 0); EXPECT(data = malloc(size)); EXPECT_EQ(fread(data, 1, size, f), size); fclose(f); MODIFY(data[0xA39], 0x08, 0x10); vorbis_t *vorbis; EXPECT(vorbis = vorbis_open_buffer(data, size, 0, NULL)); float pcm[41]; vorbis_error_t error = (vorbis_error_t)-1; EXPECT_EQ(vorbis_read_float(vorbis, pcm, 41, &error), 40); EXPECT_EQ(error, VORBIS_ERROR_STREAM_END); COMPARE_PCM_FLOAT(pcm, expected_pcm, 40); vorbis_close(vorbis); free(data); return EXIT_SUCCESS; }