diff options
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs | 53 |
1 files changed, 42 insertions, 11 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs index db428f1..073c357 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs | |||
@@ -55,18 +55,29 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
55 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 55 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
56 | private bool m_shuttingdown; | 56 | private bool m_shuttingdown; |
57 | private AssetBase m_missingImage; | 57 | private AssetBase m_missingImage; |
58 | private LLClientView m_client; //Client we're assigned to | 58 | private IAssetService m_assetCache; |
59 | private IAssetService m_assetCache; //Asset Cache | 59 | private IJ2KDecoder m_j2kDecodeModule; |
60 | private IJ2KDecoder m_j2kDecodeModule; //Our J2K module | 60 | |
61 | /// <summary> | ||
62 | /// Priority queue for determining which image to send first. | ||
63 | /// </summary> | ||
61 | private C5.IntervalHeap<J2KImage> m_priorityQueue = new C5.IntervalHeap<J2KImage>(10, new J2KImageComparer()); | 64 | private C5.IntervalHeap<J2KImage> m_priorityQueue = new C5.IntervalHeap<J2KImage>(10, new J2KImageComparer()); |
65 | |||
66 | /// <summary> | ||
67 | /// Used to control thread access to the priority queue. | ||
68 | /// </summary> | ||
62 | private object m_syncRoot = new object(); | 69 | private object m_syncRoot = new object(); |
63 | 70 | ||
64 | public LLClientView Client { get { return m_client; } } | 71 | /// <summary> |
72 | /// Client served by this image manager | ||
73 | /// </summary> | ||
74 | public IClientAPI Client { get; private set; } | ||
75 | |||
65 | public AssetBase MissingImage { get { return m_missingImage; } } | 76 | public AssetBase MissingImage { get { return m_missingImage; } } |
66 | 77 | ||
67 | public LLImageManager(LLClientView client, IAssetService pAssetCache, IJ2KDecoder pJ2kDecodeModule) | 78 | public LLImageManager(IClientAPI client, IAssetService pAssetCache, IJ2KDecoder pJ2kDecodeModule) |
68 | { | 79 | { |
69 | m_client = client; | 80 | Client = client; |
70 | m_assetCache = pAssetCache; | 81 | m_assetCache = pAssetCache; |
71 | 82 | ||
72 | if (pAssetCache != null) | 83 | if (pAssetCache != null) |
@@ -111,8 +122,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
111 | // "[LL IMAGE MANAGER]: Received duplicate of existing request for {0}, start packet {1} from {2}", | 122 | // "[LL IMAGE MANAGER]: Received duplicate of existing request for {0}, start packet {1} from {2}", |
112 | // newRequest.RequestedAssetID, newRequest.PacketNumber, m_client.Name); | 123 | // newRequest.RequestedAssetID, newRequest.PacketNumber, m_client.Name); |
113 | 124 | ||
114 | //m_log.DebugFormat("[TEX]: (UPD) ID={0}: D={1}, S={2}, P={3}", | 125 | // m_log.DebugFormat("[TEX]: (UPD) ID={0}: D={1}, S={2}, P={3}", |
115 | // newRequest.RequestedAssetID, newRequest.DiscardLevel, newRequest.PacketNumber, newRequest.Priority); | 126 | // newRequest.RequestedAssetID, newRequest.DiscardLevel, newRequest.PacketNumber, newRequest.Priority); |
116 | 127 | ||
117 | //Check the packet sequence to make sure this isn't older than | 128 | //Check the packet sequence to make sure this isn't older than |
118 | //one we've already received | 129 | //one we've already received |
@@ -178,8 +189,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
178 | imgrequest = new J2KImage(this); | 189 | imgrequest = new J2KImage(this); |
179 | imgrequest.J2KDecoder = m_j2kDecodeModule; | 190 | imgrequest.J2KDecoder = m_j2kDecodeModule; |
180 | imgrequest.AssetService = m_assetCache; | 191 | imgrequest.AssetService = m_assetCache; |
181 | imgrequest.AgentID = m_client.AgentId; | 192 | imgrequest.AgentID = Client.AgentId; |
182 | imgrequest.InventoryAccessModule = m_client.Scene.RequestModuleInterface<IInventoryAccessModule>(); | 193 | imgrequest.InventoryAccessModule = Client.Scene.RequestModuleInterface<IInventoryAccessModule>(); |
183 | imgrequest.DiscardLevel = newRequest.DiscardLevel; | 194 | imgrequest.DiscardLevel = newRequest.DiscardLevel; |
184 | imgrequest.StartPacket = Math.Max(1, newRequest.PacketNumber); | 195 | imgrequest.StartPacket = Math.Max(1, newRequest.PacketNumber); |
185 | imgrequest.Priority = newRequest.Priority; | 196 | imgrequest.Priority = newRequest.Priority; |
@@ -210,7 +221,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
210 | if (image.IsDecoded) | 221 | if (image.IsDecoded) |
211 | { | 222 | { |
212 | int sent; | 223 | int sent; |
213 | bool imageDone = image.SendPackets(m_client, packetsToSend - packetsSent, out sent); | 224 | bool imageDone = image.SendPackets(Client, packetsToSend - packetsSent, out sent); |
214 | packetsSent += sent; | 225 | packetsSent += sent; |
215 | 226 | ||
216 | // If the send is complete, destroy any knowledge of this transfer | 227 | // If the send is complete, destroy any knowledge of this transfer |
@@ -246,6 +257,26 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
246 | } | 257 | } |
247 | 258 | ||
248 | /// <summary> | 259 | /// <summary> |
260 | /// Clear the image queue. | ||
261 | /// </summary> | ||
262 | /// <returns>The number of requests cleared.</returns> | ||
263 | public int ClearImageQueue() | ||
264 | { | ||
265 | int requestsDeleted; | ||
266 | |||
267 | lock (m_priorityQueue) | ||
268 | { | ||
269 | requestsDeleted = m_priorityQueue.Count; | ||
270 | |||
271 | // Surprisingly, there doesn't seem to be a clear method at this time. | ||
272 | while (!m_priorityQueue.IsEmpty) | ||
273 | m_priorityQueue.DeleteMax(); | ||
274 | } | ||
275 | |||
276 | return requestsDeleted; | ||
277 | } | ||
278 | |||
279 | /// <summary> | ||
249 | /// Returns an array containing all the images in the queue. | 280 | /// Returns an array containing all the images in the queue. |
250 | /// </summary> | 281 | /// </summary> |
251 | /// <returns></returns> | 282 | /// <returns></returns> |