xbmc/xbmc — pull request #4232 by Montellese (2014-02-18 12:55:55+00:00)
Title: upnp: executing AVTransport's Stop action in state NO_MEDIA_PRESENT is not allowed

There was a report on the forum (see http://forum.xbmc.org/showthread.php?tid=186512) that "Play using" to the AV receiver's UPnP renderer wasn't working from XBMC. I tracked it down to the fact that XBMC blindly sending a Stop action whenever playback of a new file is being started. I checked the AVTransport:1 UPnP specification and it states that executing the Stop action is not allowed if the renderer is in the state NO_MEDIA_PRESENT (which is e.g. the case when the renderer was just started). Therefore we first need to check the state of the renderer before sending (or not sending) the Stop action otherwise we may get a 701 "Transistion not available" error (as dictated by the specification) and the result of the Stop action is handled as an error and the whole playback is being aborted.

Furthermore I've removed the comment saying that
```
dlna specifies that a return code of 705 should be returned if TRANSPORT_STATE is not STOPPED or NO_MEDIA_PRESENT
```
I don't know the DLNA restrictions imposed upon UPnP but the UPnP specification says that 701 is returned in case of a wrong state (only NO_MEDIA_PRESENT) whereas 705 is in case of a "playback lock" (remember those mechanical locks on "old" MP3 players?) where it is not allowed to change the currently playing item.

@elupus and @alcoheca for comments.