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