From fa0b64bdcea3000292fed79dc4d18e3e24dbb690 Mon Sep 17 00:00:00 2001

From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= jaakko.keranen@iki.fi

Date: Mon, 4 Dec 2023 11:05:39 +0200

Subject: [PATCH 1/1] Player: Avoid copying memory when detecting audio format

BubbleID #64


src/audio/player.c | 15 +++++++++++----

1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/audio/player.c b/src/audio/player.c

index 67ca9521..01e54191 100644

--- a/src/audio/player.c

+++ b/src/audio/player.c

@@ -475,12 +475,11 @@ static iRangecc mediaType_(const iString *str) {

 return part;

}

-static iContentSpec contentSpec_Player_(const iPlayer *d) {

+static iContentSpec detectContentSpec_Player_(const iPlayer *d) {

 iContentSpec content;

 iZap(content);

 const size_t dataSize = size_InputBuf(d->data);

 const iRangecc mediaType = mediaType_(&d->mime);

 if (equal_Rangecc(mediaType, "audio/wave") || equal_Rangecc(mediaType, "audio/wav") ||

     equal_Rangecc(mediaType, "audio/x-wav") || equal_Rangecc(mediaType, "audio/x-pn-wav")) {

@@ -499,6 +498,12 @@ static iContentSpec contentSpec_Player_(const iPlayer *d) {

     /* TODO: Could try decoders to see if one works? */

     content.type = none_DecoderType;

 }

 if (content.type == wav_DecoderType && dataSize >= 44) {

     /* Read the RIFF/WAVE header. */

     iStream *is = stream_Buffer(buf);

@@ -713,6 +718,8 @@ void updateSourceData_Player(iPlayer *d, const iString *mimeType, const iBlock *

             break;

         }

         /* The old parts cannot have changed. */

         appendData_Block(&input->data, constBegin_Block(data) + oldSize, newSize - oldSize);

         break;

     }

@@ -769,7 +776,7 @@ iBool start_Player(iPlayer *d) {

     return iTrue;

 }

#endif

 if (!content.output.freq) {

     return iFalse;

 }

--

2.25.1

Proxy Information
Original URL
gemini://git.skyjake.fi/lagrange/work%2Fv1.8/patch/fa0b64bdcea3000292fed79dc4d18e3e24dbb690.patch
Status Code
Success (20)
Meta
text/plain
Capsule Response Time
57.678916 milliseconds
Gemini-to-HTML Time
0.961802 milliseconds

This content has been proxied by September (ba2dc).