summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRay <[email protected]>2023-10-31 15:54:38 +0100
committerRay <[email protected]>2023-10-31 15:54:38 +0100
commitf88604e6d5e0b17280b05081450a0e9b31d8621d (patch)
tree05cce56016845f9c2a090c629979655c62298084
parent0a3567439d90bb1a4955b13441f157ec9c956998 (diff)
downloadraylib-f88604e6d5e0b17280b05081450a0e9b31d8621d.tar.gz
raylib-f88604e6d5e0b17280b05081450a0e9b31d8621d.zip
Reviewed QOA seek PR
-rw-r--r--src/external/qoaplay.c4
-rw-r--r--src/raudio.c11
2 files changed, 10 insertions, 5 deletions
diff --git a/src/external/qoaplay.c b/src/external/qoaplay.c
index 7f937f4f..039e2797 100644
--- a/src/external/qoaplay.c
+++ b/src/external/qoaplay.c
@@ -36,7 +36,7 @@
// QOA streaming data descriptor
typedef struct {
qoa_desc info; // QOA descriptor data
-
+
FILE *file; // QOA file to read, if NULL, using memory buffer -> file_data
unsigned char *file_data; // QOA file data on memory
unsigned int file_data_size; // QOA file data on memory size
@@ -107,7 +107,7 @@ qoaplay_desc *qoaplay_open(const char *path)
unsigned int sample_data_size = qoa.channels*QOA_FRAME_LEN*sizeof(short)*2;
qoaplay_desc *qoa_ctx = QOA_MALLOC(sizeof(qoaplay_desc) + buffer_size + sample_data_size);
memset(qoa_ctx, 0, sizeof(qoaplay_desc));
-
+
qoa_ctx->file = file;
qoa_ctx->file_data = NULL;
qoa_ctx->file_data_size = 0;
diff --git a/src/raudio.c b/src/raudio.c
index 47667604..e38e51e6 100644
--- a/src/raudio.c
+++ b/src/raudio.c
@@ -1797,9 +1797,14 @@ void SeekMusicStream(Music music, float position)
case MUSIC_AUDIO_MP3: drmp3_seek_to_pcm_frame((drmp3 *)music.ctxData, positionInFrames); break;
#endif
#if defined(SUPPORT_FILEFORMAT_QOA)
- //qoaplay_seek_frame seeks to QOA frame, not PCM frame, therefore we need to compute QOA frame number and change positionInFrames
- case MUSIC_AUDIO_QOA: { int qoaFrame = positionInFrames/QOA_FRAME_LEN; qoaplay_seek_frame((qoaplay_desc*)music.ctxData, qoaFrame);
- positionInFrames = ((qoaplay_desc*)music.ctxData)->sample_position; break; }
+ case MUSIC_AUDIO_QOA:
+ {
+ int qoaFrame = positionInFrames/QOA_FRAME_LEN;
+ qoaplay_seek_frame((qoaplay_desc *)music.ctxData, qoaFrame); // Seeks to QOA frame, not PCM frame
+
+ // We need to compute QOA frame number and update positionInFrames
+ positionInFrames = ((qoaplay_desc *)music.ctxData)->sample_position;
+ } break;
#endif
#if defined(SUPPORT_FILEFORMAT_FLAC)
case MUSIC_AUDIO_FLAC: drflac_seek_to_pcm_frame((drflac *)music.ctxData, positionInFrames); break;