Code Coverage Report for src/api/submit.c


Hit Total Coverage
Lines: 17 17 100.0%
Branches: 108 108 100.0%

1 /*
2 * libnogg: a decoder library for Ogg Vorbis streams
3 * Copyright (c) 2014-2023 Andrew Church <achurch@achurch.org>
4 *
5 * This software may be copied and redistributed under certain conditions;
6 * see the file "COPYING" in the source code distribution for details.
7 * NO WARRANTY is provided with this software.
8 */
9
10 #include "include/nogg.h"
11 #include "src/common.h"
12 #include "src/util/decode-frame.h"
13
14 #include <stddef.h>
15
16
17 int vorbis_submit_packet(vorbis_t *handle, const void *packet,
18 int32_t packet_len, vorbis_error_t *error_ret)
19 {
20 vorbis_error_t error;
21
22 (36/36) if (!packet || packet_len <= 0) {
23 error = VORBIS_ERROR_INVALID_ARGUMENT;
24 goto exit;
25 }
26 (18/18) if (!handle->packet_mode) {
27 error = VORBIS_ERROR_INVALID_OPERATION;
28 goto exit;
29 }
30 (18/18) if (handle->decode_buf_pos < handle->decode_buf_len) {
31 error = VORBIS_ERROR_INVALID_OPERATION;
32 goto exit;
33 }
34 error = decode_frame(handle, packet, packet_len);
35 (18/18) if (error == VORBIS_ERROR_STREAM_END) {
36 /* The packet had no audio data (e.g., the first packet in the
37 * stream). This is not an error for our purposes. */
38 error = VORBIS_NO_ERROR;
39 }
40
41 exit:
42 (18/18) if (error_ret) {
43 *error_ret = error;
44 }
45 return error == VORBIS_NO_ERROR;
46 }