summaryrefslogtreecommitdiff
path: root/src/audio/player.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio/player.c')
-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