diff options
-rw-r--r-- | plugins/mpgmad/mpgmad.c | 6 | ||||
-rw-r--r-- | streamer.c | 27 |
2 files changed, 21 insertions, 12 deletions
diff --git a/plugins/mpgmad/mpgmad.c b/plugins/mpgmad/mpgmad.c index c8a696ad..87761bb6 100644 --- a/plugins/mpgmad/mpgmad.c +++ b/plugins/mpgmad/mpgmad.c @@ -188,7 +188,7 @@ extract_f32 (unsigned char *buf) { // return value: -1 on error static int cmp3_scan_stream (buffer_t *buffer, int sample) { - trace ("cmp3_scan_stream %d\n", sample); + trace ("cmp3_scan_stream %d (offs: %lld)\n", sample, deadbeef->ftell (buffer->file)); // {{{ prepare for scan - seek, reset averages, etc int initpos = deadbeef->ftell (buffer->file); @@ -882,7 +882,7 @@ cmp3_init (DB_fileinfo_t *_info, DB_playItem_t *it) { trace ("duration=%f, endsample=%d, totalsamples=%d\n", info->buffer.duration, info->buffer.endsample, info->buffer.totalsamples); } if (info->buffer.samplerate == 0) { - trace ("bad mpeg file: %f\n", deadbeef->pl_find_meta (it, ":URI")); + trace ("bad mpeg file: %s\n", deadbeef->pl_find_meta (it, ":URI")); return -1; } _info->fmt.bps = info->buffer.bitspersample; @@ -1259,7 +1259,7 @@ cmp3_seek_sample (DB_fileinfo_t *_info, int sample) { trace ("seek failed!\n"); return -1; } - trace ("seek is impossible (avg_samples_per_frame=%d, avg_packetlength=%d)!\n", info->buffer.avg_samples_per_frame, info->buffer.avg_packetlength); + trace ("seek is impossible (avg_samples_per_frame=%d, avg_packetlength=%f)!\n", info->buffer.avg_samples_per_frame, info->buffer.avg_packetlength); return 0; } // }}} @@ -760,23 +760,29 @@ streamer_set_current (playItem_t *it) { goto error; } trace ("got content-type: %s\n", ct); - if (!strcmp (ct, "audio/mpeg")) { + char *cct = strdupa (ct); + char *sc = strchr (cct, ';'); + if (sc) { + *sc = 0; + } + if (!strcmp (cct, "audio/mpeg")) { plug = "stdmpg"; } - else if (!strcmp (ct, "application/ogg") || !strcmp (ct, "audio/ogg")) { + else if (!strcmp (cct, "application/ogg") || !strcmp (cct, "audio/ogg")) { plug = "stdogg"; } - else if (!strcmp (ct, "audio/aacp")) { + else if (!strcmp (cct, "audio/aacp")) { plug = "aac"; } - else if (!strcmp (ct, "audio/aac")) { + else if (!strcmp (cct, "audio/aac")) { plug = "aac"; } - else if (!strcmp (ct, "audio/wma")) { + else if (!strcmp (cct, "audio/wma")) { plug = "ffmpeg"; } - else if (!strcmp (ct, "audio/x-mpegurl") || !strncmp (ct, "text/html", 9) || !strncmp (ct, "audio/x-scpls", 13) || !strncmp (ct, "application/octet-stream", 9)) { + else if (!strcmp (cct, "audio/x-mpegurl") || !strncmp (cct, "text/html", 9) || !strncmp (cct, "audio/x-scpls", 13) || !strncmp (cct, "application/octet-stream", 9)) { // download playlist into temp file + trace ("downloading playlist into temp file...\n"); char *buf = NULL; int fd = -1; FILE *out = NULL; @@ -787,7 +793,7 @@ streamer_set_current (playItem_t *it) { } buf = malloc (size); if (!buf) { - trace ("failed to alloc %d bytes for playlist buffer\n"); + trace ("failed to alloc %d bytes for playlist buffer\n", size); goto m3u_error; } trace ("reading %d bytes\n", size); @@ -843,6 +849,9 @@ streamer_set_current (playItem_t *it) { goto m3u_error; } + // hack: need to sleep here, some servers like to reject frequent connections + usleep(conf_get_int ("streamer.wait_ms_after_m3u_link", 400000)); + // for every playlist uri: override stream uri with the one from playlist, and try to play it playItem_t *i = (playItem_t *)m3u; pl_item_ref (i); @@ -956,7 +965,7 @@ m3u_error: trace ("decoder->init returned %p\n", new_fileinfo); streamer_buffering = 0; if (playlist_track == it) { - trace ("redraw track %d; playing_track=%p; playlist_track=%p\n", to, playing_track, playlist_track); + trace ("redraw track %p; playing_track=%p; playlist_track=%p\n", to, playing_track, playlist_track); send_trackinfochanged (to); } err = -1; @@ -1312,7 +1321,7 @@ streamer_thread (void *ctx) { if (seek >= 0) { playpos = seek; seekpos = -1; - trace ("seeking to %f\n", seek); + trace ("seeking to %d\n", seek); float pos = seek; if (playing_track != streaming_track) { |