X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fclient.cpp;h=835dbbd91597f234ad794571dd3e14d56b2ec1d8;hb=4761421;hp=8d61f3fa51e56c9a78d12a322e4ea973c9a479ba;hpb=2e629085885b652a10d775695e63bc4892aa2eca;p=xinema.git diff --git a/source/client.cpp b/source/client.cpp index 8d61f3f..835dbbd 100644 --- a/source/client.cpp +++ b/source/client.cpp @@ -16,6 +16,7 @@ Client::Client(Xinema &x, Net::StreamSocket *s): socket->signal_end_of_file.connect(sigc::mem_fun(this, &Client::end_of_stream)); xinema.signal_stream_created.connect(sigc::mem_fun(this, &Client::stream_created)); + xinema.signal_stream_destroyed.connect(sigc::mem_fun(this, &Client::stream_destroyed)); XineStream *stream = xinema.get_stream(); if(stream) stream_created(*stream); @@ -24,7 +25,17 @@ Client::Client(Xinema &x, Net::StreamSocket *s): void Client::data_available() { char rbuf[1024]; - unsigned len = socket->read(rbuf, sizeof(rbuf)); + unsigned len; + try + { + len = socket->read(rbuf, sizeof(rbuf)); + } + catch(const std::exception &) + { + stale = true; + return; + } + buffer.append(rbuf, len); string::size_type start = 0; @@ -90,8 +101,15 @@ void Client::process_command(const string &cmd) void Client::send_reply(const string &reply) { Msp::MutexLock lock(mutex); - socket->write(reply); - socket->put('\n'); + try + { + socket->write(reply); + socket->put('\n'); + } + catch(const std::exception &) + { + stale = true; + } } void Client::list_directory(const FS::Path &dn) @@ -125,6 +143,11 @@ void Client::stream_created(XineStream &stream) stream_duration_changed(dur); } +void Client::stream_destroyed() +{ + send_reply("ejected"); +} + void Client::stream_state_changed(XineStream::State state) { send_reply(format("state %s", state));