Skip to content

Commit

Permalink
fix granule position
Browse files Browse the repository at this point in the history
  • Loading branch information
g3gg0 committed Aug 30, 2023
1 parent 86c5957 commit d6a9f34
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/toniefile.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,10 @@ error_t toniefile_encode(toniefile_t *ctx, int16_t *sample_buffer, size_t sample
frame_len = target_length;
}

ctx->ogg_granule_position += OPUS_FRAME_SIZE;
/* we have to retrieve the actually encoded samples in this frame */
int frames = opus_packet_get_samples_per_frame(output_frame, OPUS_SAMPLING_RATE) * opus_packet_get_nb_frames(output_frame, frame_len);
ctx->ogg_granule_position += frames;

/* now fill output page */
ogg_packet op;
op.packet = output_frame;
Expand Down

0 comments on commit d6a9f34

Please sign in to comment.