X-Git-Url: http://git.tdb.fi/?p=xinema.git;a=blobdiff_plain;f=remote%2Fsource%2Fxinemacontrol.cpp;h=eb2ec47e5706b0a67016491cedde811468c31ede;hp=f793e3bb0f1a271fcb69e119fc4692d29ae75b1c;hb=857fbdc12041b7f01f45d4dcf2208f9dccf29294;hpb=a5fc8a4255dabc9d5d514e597a7b19ffd5baf793 diff --git a/remote/source/xinemacontrol.cpp b/remote/source/xinemacontrol.cpp index f793e3b..eb2ec47 100644 --- a/remote/source/xinemacontrol.cpp +++ b/remote/source/xinemacontrol.cpp @@ -3,7 +3,9 @@ XinemaControl::XinemaControl(): playback_state(STOPPED), duration(0.0f), - position(0.0f) + position(0.0f), + current_audio_channel(-1), + current_spu_channel(-1) { QObject::connect(&socket, &QAbstractSocket::connected, this, &XinemaControl::connected); QObject::connect(&socket, &QAbstractSocket::disconnected, this, &XinemaControl::disconnected); @@ -56,6 +58,22 @@ void XinemaControl::stop() send_request("stop"); } +void XinemaControl::select_audio_channel(int chan) +{ + if(chan<0) + send_request("select_audio off"); + else + send_request(QString("select_audio %1").arg(chan)); +} + +void XinemaControl::select_spu_channel(int chan) +{ + if(chan<0) + send_request("select_spu off"); + else + send_request(QString("select_spu %1").arg(chan)); +} + void XinemaControl::send_request(const QString &req) { socket.write(req.toUtf8()); @@ -129,4 +147,46 @@ void XinemaControl::process_reply(const QString &reply) position = args.toFloat(); emit position_changed(position); } + else if(keyword=="audio_count") + resize_list(audio_channels, args.toInt()); + else if(keyword=="audio") + { + space = args.indexOf(' '); + audio_channels[args.mid(0, space).toInt()] = args.mid(space+1); + } + else if(keyword=="spu_count") + resize_list(spu_channels, args.toInt()); + else if(keyword=="spu") + { + space = args.indexOf(' '); + spu_channels[args.mid(0, space).toInt()] = args.mid(space+1); + } + else if(keyword=="channels_end") + emit channels_changed(); + else if(keyword=="current_audio") + { + current_audio_channel = convert_channel(args); + emit current_audio_channel_changed(current_audio_channel); + } + else if(keyword=="current_spu") + { + current_spu_channel = convert_channel(args); + emit current_spu_channel_changed(current_spu_channel); + } +} + +int XinemaControl::convert_channel(const QString &arg) +{ + if(arg=="off") + return OFF; + else + return arg.toInt(); +} + +void XinemaControl::resize_list(QStringList &list, int size) +{ + while(list.size()>size) + list.removeLast(); + while(list.size()