stream: don't print reconnection message if no stream support

This code does not know whether the stream supports reconnecting until
STREAM_CTRL_RECONNECT is called. So the message should be printed after
it. To avoid that reconnects that succeed on the first try go unnoticed,
print a warning on success.
This commit is contained in:
wm4 2015-04-29 19:54:46 +02:00
parent daf4334697
commit 38114b6a36
1 changed files with 5 additions and 3 deletions

View File

@ -401,13 +401,15 @@ static bool stream_reconnect(stream_t *s)
if (mp_cancel_wait(s->cancel, sleep_secs))
break;
MP_WARN(s, "Connection lost! Attempting to reconnect (%d)...\n", retry + 1);
int r = stream_control(s, STREAM_CTRL_RECONNECT, NULL);
if (r == STREAM_UNSUPPORTED)
break;
if (r == STREAM_OK && stream_seek_unbuffered(s, pos) && s->pos == pos)
if (r == STREAM_OK && stream_seek_unbuffered(s, pos) && s->pos == pos) {
MP_WARN(s, "Reconnected successfully.\n");
return true;
}
MP_WARN(s, "Connection lost! Attempting to reconnect (%d)...\n", retry + 1);
sleep_secs = MPMAX(sleep_secs, 0.1);
sleep_secs = MPMIN(sleep_secs * 4, 10.0);