Merge pull request #4614 from Montellese/upnp_player_logging
authorSascha Montellese <sascha.montellese@gmail.com>
Sun, 27 Apr 2014 11:49:40 +0000 (13:49 +0200)
committerJonathan Marshall <jmarshall@xbmc.org>
Thu, 1 May 2014 20:08:19 +0000 (08:08 +1200)
upnp: add some potentially useful logging to CUPnPPlayer::PlayFile()

xbmc/network/upnp/UPnPPlayer.cpp

index c591203..4d41d10 100644 (file)
@@ -229,7 +229,7 @@ int CUPnPPlayer::PlayFile(const CFileItem& file, const CPlayerOptions& options,
   obj = BuildObject(item, path, false, thumb_loader, NULL, CUPnP::GetServer());
   if(obj.IsNull()) goto failed;
 
-  NPT_CHECK_LABEL_SEVERE(PLT_Didl::ToDidl(*obj, "", tmp), failed);
+  NPT_CHECK_LABEL_SEVERE(PLT_Didl::ToDidl(*obj, "", tmp), failed_todidl);
   tmp.Insert(didl_header, 0);
   tmp.Append(didl_footer);
 
@@ -238,6 +238,7 @@ int CUPnPPlayer::PlayFile(const CFileItem& file, const CPlayerOptions& options,
   {
     for (NPT_Cardinal i=0; i< obj->m_Resources.GetItemCount(); i++) {
       if (obj->m_Resources[i].m_ProtocolInfo.GetContentType().Compare("video/x-matroska") == 0) {
+        CLog::Log(LOGDEBUG, "CUPnPPlayer::PlayFile(%s): applying video/x-mkv quirk", file.GetPath().c_str());
         NPT_String protocolInfo = obj->m_Resources[i].m_ProtocolInfo.ToString();
         protocolInfo.Replace(":video/x-matroska:", ":video/x-mkv:");
         obj->m_Resources[i].m_ProtocolInfo = PLT_ProtocolInfo(protocolInfo);
@@ -248,15 +249,15 @@ int CUPnPPlayer::PlayFile(const CFileItem& file, const CPlayerOptions& options,
   /* The resource uri's are stored in the Didl. We must choose the best resource
    * for the playback device */
   NPT_Cardinal res_index;
-  NPT_CHECK_LABEL_SEVERE(m_control->FindBestResource(m_delegate->m_device, *obj, res_index), failed);
+  NPT_CHECK_LABEL_SEVERE(m_control->FindBestResource(m_delegate->m_device, *obj, res_index), failed_findbestresource);
 
   // get the transport info to evaluate the TransportState to be able to
   // determine whether we first need to call Stop()
   timeout.Set(timeout.GetInitialTimeoutValue());
   NPT_CHECK_LABEL_SEVERE(m_control->GetTransportInfo(m_delegate->m_device
                                                      , m_delegate->m_instance
-                                                     , m_delegate), failed);
-  NPT_CHECK_LABEL_SEVERE(WaitOnEvent(m_delegate->m_traevnt, timeout, dialog), failed);
+                                                     , m_delegate), failed_gettransportinfo);
+  NPT_CHECK_LABEL_SEVERE(WaitOnEvent(m_delegate->m_traevnt, timeout, dialog), failed_gettransportinfo);
 
   if (m_delegate->m_trainfo.cur_transport_state != "NO_MEDIA_PRESENT" &&
       m_delegate->m_trainfo.cur_transport_state != "STOPPED")
@@ -264,9 +265,9 @@ int CUPnPPlayer::PlayFile(const CFileItem& file, const CPlayerOptions& options,
     timeout.Set(timeout.GetInitialTimeoutValue());
     NPT_CHECK_LABEL_SEVERE(m_control->Stop(m_delegate->m_device
                                            , m_delegate->m_instance
-                                           , m_delegate), failed);
-    NPT_CHECK_LABEL_SEVERE(WaitOnEvent(m_delegate->m_resevent, timeout, dialog), failed);
-    NPT_CHECK_LABEL_SEVERE(m_delegate->m_resstatus, failed);
+                                           , m_delegate), failed_stop);
+    NPT_CHECK_LABEL_SEVERE(WaitOnEvent(m_delegate->m_resevent, timeout, dialog), failed_stop);
+    NPT_CHECK_LABEL_SEVERE(m_delegate->m_resstatus, failed_stop);
   }
 
 
@@ -275,17 +276,17 @@ int CUPnPPlayer::PlayFile(const CFileItem& file, const CPlayerOptions& options,
                                                     , m_delegate->m_instance
                                                     , obj->m_Resources[res_index].m_Uri
                                                     , (const char*)tmp
-                                                    , m_delegate), failed);
-  NPT_CHECK_LABEL_SEVERE(WaitOnEvent(m_delegate->m_resevent, timeout, dialog), failed);
-  NPT_CHECK_LABEL_SEVERE(m_delegate->m_resstatus, failed);
+                                                    , m_delegate), failed_setavtransporturi);
+  NPT_CHECK_LABEL_SEVERE(WaitOnEvent(m_delegate->m_resevent, timeout, dialog), failed_setavtransporturi);
+  NPT_CHECK_LABEL_SEVERE(m_delegate->m_resstatus, failed_setavtransporturi);
 
   timeout.Set(timeout.GetInitialTimeoutValue());
   NPT_CHECK_LABEL_SEVERE(m_control->Play(m_delegate->m_device
                                        , m_delegate->m_instance
                                        , "1"
-                                       , m_delegate), failed);
-  NPT_CHECK_LABEL_SEVERE(WaitOnEvent(m_delegate->m_resevent, timeout, dialog), failed);
-  NPT_CHECK_LABEL_SEVERE(m_delegate->m_resstatus, failed);
+                                       , m_delegate), failed_play);
+  NPT_CHECK_LABEL_SEVERE(WaitOnEvent(m_delegate->m_resevent, timeout, dialog), failed_play);
+  NPT_CHECK_LABEL_SEVERE(m_delegate->m_resstatus, failed_play);
 
 
   /* wait for PLAYING state */
@@ -293,7 +294,7 @@ int CUPnPPlayer::PlayFile(const CFileItem& file, const CPlayerOptions& options,
   do {
     NPT_CHECK_LABEL_SEVERE(m_control->GetTransportInfo(m_delegate->m_device
                                                      , m_delegate->m_instance
-                                                     , m_delegate), failed);
+                                                     , m_delegate), failed_waitplaying);
 
 
     { CSingleLock lock(m_delegate->m_section);
@@ -305,11 +306,11 @@ int CUPnPPlayer::PlayFile(const CFileItem& file, const CPlayerOptions& options,
       && m_delegate->m_trainfo.cur_transport_status != "OK")
       {
         CLog::Log(LOGERROR, "UPNP: CUPnPPlayer::OpenFile - remote player signalled error %s", file.GetPath().c_str());
-        goto failed;
+        return NPT_FAILURE;
       }
     }
 
-    NPT_CHECK_LABEL_SEVERE(WaitOnEvent(m_delegate->m_traevnt, timeout, dialog), failed);
+    NPT_CHECK_LABEL_SEVERE(WaitOnEvent(m_delegate->m_traevnt, timeout, dialog), failed_waitplaying);
 
   } while(!timeout.IsTimePast());
 
@@ -320,11 +321,36 @@ int CUPnPPlayer::PlayFile(const CFileItem& file, const CPlayerOptions& options,
                                     , m_delegate->m_instance
                                     , "REL_TIME"
                                     , PLT_Didl::FormatTimeStamp((NPT_UInt32)options.starttime)
-                                    , m_delegate), failed);
+                                    , m_delegate), failed_seek);
   }
 
   return NPT_SUCCESS;
+failed_todidl:
+  CLog::Log(LOGERROR, "CUPnPPlayer::PlayFile(%s) failed to serialize item into DIDL-Lite", file.GetPath().c_str());
+  return NPT_FAILURE;
+failed_findbestresource:
+  CLog::Log(LOGERROR, "CUPnPPlayer::PlayFile(%s) failed to find a matching resource", file.GetPath().c_str());
+  return NPT_FAILURE;
+failed_gettransportinfo:
+  CLog::Log(LOGERROR, "CUPnPPlayer::PlayFile(%s): call to GetTransportInfo failed", file.GetPath().c_str());
+  return NPT_FAILURE;
+failed_stop:
+  CLog::Log(LOGERROR, "CUPnPPlayer::PlayFile(%s) failed to stop current playback", file.GetPath().c_str());
+  return NPT_FAILURE;
+failed_setavtransporturi:
+  CLog::Log(LOGERROR, "CUPnPPlayer::PlayFile(%s) failed to set the playback URI", file.GetPath().c_str());
+  return NPT_FAILURE;
+failed_play:
+  CLog::Log(LOGERROR, "CUPnPPlayer::PlayFile(%s) failed to start playback", file.GetPath().c_str());
+  return NPT_FAILURE;
+failed_waitplaying:
+  CLog::Log(LOGERROR, "CUPnPPlayer::PlayFile(%s) failed to wait for PLAYING state", file.GetPath().c_str());
+  return NPT_FAILURE;
+failed_seek:
+  CLog::Log(LOGERROR, "CUPnPPlayer::PlayFile(%s) failed to seek to start offset", file.GetPath().c_str());
+  return NPT_FAILURE;
 failed:
+  CLog::Log(LOGERROR, "CUPnPPlayer::PlayFile(%s) failed", file.GetPath().c_str());
   return NPT_FAILURE;
 }