summaryrefslogtreecommitdiff
path: root/src/audio
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-04-18 17:34:38 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-04-18 17:34:38 +0300
commit23ccb3e39e71cffd3ce66fb0fb42f1941e05fb94 (patch)
treebfabab8d61d43b9ee0fdcc5b2ccc907ec9f744c6 /src/audio
parent9397a2e125009678da9465770910b24fadaaee2e (diff)
Player: Fixed audio media type check
IssueID #249
Diffstat (limited to 'src/audio')
-rw-r--r--src/audio/player.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/audio/player.c b/src/audio/player.c
index c08b20fc..35786284 100644
--- a/src/audio/player.c
+++ b/src/audio/player.c
@@ -459,22 +459,29 @@ static int silence_Player_(const iPlayer *d) {
459 return d->spec.silence; 459 return d->spec.silence;
460} 460}
461 461
462static iRangecc mediaType_(const iString *str) {
463 iRangecc part = iNullRange;
464 nextSplit_Rangecc(range_String(str), ";", &part);
465 return part;
466}
467
462static iContentSpec contentSpec_Player_(const iPlayer *d) { 468static iContentSpec contentSpec_Player_(const iPlayer *d) {
463 iContentSpec content; 469 iContentSpec content;
464 iZap(content); 470 iZap(content);
465 const size_t dataSize = size_InputBuf(d->data); 471 const size_t dataSize = size_InputBuf(d->data);
466 iBuffer *buf = iClob(new_Buffer()); 472 iBuffer *buf = iClob(new_Buffer());
467 open_Buffer(buf, &d->data->data); 473 open_Buffer(buf, &d->data->data);
468 if (!cmp_String(&d->mime, "audio/wave") || !cmp_String(&d->mime, "audio/wav") || 474 const iRangecc mediaType = mediaType_(&d->mime);
469 !cmp_String(&d->mime, "audio/x-wav") || !cmp_String(&d->mime, "audio/x-pn-wav")) { 475 if (equal_Rangecc(mediaType, "audio/wave") || equal_Rangecc(mediaType, "audio/wav") ||
476 equal_Rangecc(mediaType, "audio/x-wav") || equal_Rangecc(mediaType, "audio/x-pn-wav")) {
470 content.type = wav_DecoderType; 477 content.type = wav_DecoderType;
471 } 478 }
472 else if (!cmp_String(&d->mime, "audio/vorbis") || !cmp_String(&d->mime, "audio/ogg") || 479 else if (equal_Rangecc(mediaType, "audio/vorbis") || equal_Rangecc(mediaType, "audio/ogg") ||
473 !cmp_String(&d->mime, "audio/x-vorbis+ogg")) { 480 equal_Rangecc(mediaType, "audio/x-vorbis+ogg")) {
474 content.type = vorbis_DecoderType; 481 content.type = vorbis_DecoderType;
475 } 482 }
476#if defined (LAGRANGE_ENABLE_MPG123) 483#if defined (LAGRANGE_ENABLE_MPG123)
477 else if (!cmp_String(&d->mime, "audio/mpeg") || !cmp_String(&d->mime, "audio/mp3")) { 484 else if (equal_Rangecc(mediaType, "audio/mpeg") || equal_Rangecc(mediaType, "audio/mp3")) {
478 content.type = mpeg_DecoderType; 485 content.type = mpeg_DecoderType;
479 } 486 }
480#endif 487#endif