1
0
mirror of https://github.com/clementine-player/Clementine synced 2025-01-15 19:21:16 +01:00

Timeout if the spotify client hasn't connected to the tcpsrc within 5 seconds.

This commit is contained in:
David Sansome 2011-11-28 12:18:03 +00:00
parent cb211190c7
commit e16f1d8bdd

View File

@ -35,6 +35,7 @@
static const int kPollTimeoutMsec = 100;
static const int kMaxConnectionWaits = 50; // each one takes kPollTimeoutMsec
// This is about one second of audio at spotify's bitrate.
static const int kSocketBufferSize = 176400;
@ -231,11 +232,18 @@ static gboolean gst_spotifytcp_src_start(GstBaseSrc* src) {
server->StartPlayback(QString::fromAscii(*self->uri_), self->server_->serverPort());
// Wait for a client to connect
int attempts = 0;
while (!self->server_->waitForNewConnection(kPollTimeoutMsec)) {
if (self->unlock_) {
qLog(Warning) << "Unlock while waiting for connection";
return FALSE;
}
++attempts;
if (attempts > kMaxConnectionWaits) {
qLog(Warning) << "Timed out waiting for connection";
return FALSE;
}
}
// Take the socket