Merge pull request #26220 from 78andyp/blurayfixes
[xbmc.git] / lib / libUPnP / patches / 0005-platinum-use-server-provided-item-count-to-iterate-b.patch
blobb35bd0b1c92c18e1bd5c069590cf4b60999d38d3
1 From 883f4f02d741317f5c8c6866d38b4b78dd79adf1 Mon Sep 17 00:00:00 2001
2 From: Alasdair Campbell <alcoheca@gmail.com>
3 Date: Wed, 6 Jun 2012 18:40:00 +0100
4 Subject: [PATCH 05/24] platinum: use server provided item count to iterate
5 browse req
7 all other modifications to libPlatinum/Neptune since codiqs last commit have
8 been checked and are not required / have been included upstream
10 the following patches therefore do not need to be reinstated:
12 5e5156bde70bb4250c9d912e43656a19d008f110
13 4df0a4cb1cd059f585de289a10ab915ce1bd95a8
14 a6eaa587174f73c0fdd7a5130774772c7d475fec
15 964b08aed02ee52d7f88250409b4e3fdd0363be3
16 2f70d124f75d76813e48ecc26ffd9aa3625072aa
17 299d326314619aa3a085f2c026e55860a75b3a5c
18 5bbf59fbc049325ec4205fadaa0903a753b866ee
19 370c8366ed83115558e4dcb00561207854c4f971
20 755f17fe4353b7047ca04c16b7461d1ef3b8ed1b
21 20c1ed61030f7a5bada60821507f29e54821b1a9
22 0b11444d6e405fa17e73ef0abc9ceba25a559cce
23 f96d966e7575b4d9f7c864ad153dd9fb968344c9
24 99479c384176fd3f82d518506e560ba08ad57e40
25 347aa55b6c55e2801ff7a421e8bcc02ce0314cab
26 a1993bf0380b9ced60c39064833435e458aa5434
27 f13f20aaa9493d58264c55f2a5b2cafd09435b0e
28 95df1d019cb7ea64a6f748a9104db1ecd666af42
29 887728b93d0a8cddd6a08bfddc4079f4c2ae82f8
30 66d2daf7bd90f7be2cb4cdbc5088488627953e3f
31 ec70e260e95becc5bfcd86512b245776ef9653ea
32 296435b9a9262b23b49cbfb2302e36e730f292e7
33 99e0a1eaf18ed07625143e4fadc6eb027f822857
34 588a66a55067433ade77769a39c81552a995b38d
35 3fd25488ba88b30cfa0f5b834bbde91a21f05a73
36 ---
37 .../Source/Devices/MediaServer/PltSyncMediaBrowser.cpp | 16 ++++++++++++----
38 1 file changed, 12 insertions(+), 4 deletions(-)
40 diff --git a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltSyncMediaBrowser.cpp b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltSyncMediaBrowser.cpp
41 index f6391fb..96c36df 100644
42 --- a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltSyncMediaBrowser.cpp
43 +++ b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltSyncMediaBrowser.cpp
44 @@ -36,6 +36,7 @@
45 | includes
46 +---------------------------------------------------------------------*/
47 #include "PltSyncMediaBrowser.h"
48 +#include <algorithm>
50 NPT_SET_LOCAL_LOGGER("platinum.media.server.syncbrowser")
52 @@ -239,6 +240,7 @@ PLT_SyncMediaBrowser::BrowseSync(PLT_DeviceDataReference& device,
54 NPT_Result res = NPT_FAILURE;
55 NPT_Int32 index = start;
56 + NPT_UInt32 count = 0;
58 // only cache metadata or if starting from 0 and asking for maximum
59 bool cache = m_UseCache && (metadata || (start == 0 && max_results == 0));
60 @@ -270,9 +272,15 @@ PLT_SyncMediaBrowser::BrowseSync(PLT_DeviceDataReference& device,
63 // server returned no more, bail now
64 - if (browse_data->info.items->GetItemCount() == 0)
65 + if (browse_data->info.nr == 0)
66 break;
68 + if (browse_data->info.nr != browse_data->info.items->GetItemCount()) {
69 + NPT_LOG_WARNING_2("Server returned unexpected number of items (%d vs %d)",
70 + browse_data->info.nr, browse_data->info.items->GetItemCount());
71 + }
72 + count += std::max<NPT_UInt32>(browse_data->info.nr, browse_data->info.items->GetItemCount());
74 if (list.IsNull()) {
75 list = browse_data->info.items;
76 } else {
77 @@ -290,12 +298,12 @@ PLT_SyncMediaBrowser::BrowseSync(PLT_DeviceDataReference& device,
78 // Unless we were told to stop after reaching a certain amount to avoid
79 // length delays
80 // (some servers may return a total matches out of whack at some point too)
81 - if ((browse_data->info.tm && browse_data->info.tm <= list->GetItemCount()) ||
82 - (max_results && list->GetItemCount() >= max_results))
83 + if ((browse_data->info.tm && browse_data->info.tm <= count) ||
84 + (max_results && count >= max_results))
85 break;
87 // ask for the next chunk of entries
88 - index = list->GetItemCount();
89 + index = count;
90 } while(1);
92 done:
93 --
94 1.7.11.msysgit.0