2 * Copyright 2009, Axel Dörfler, axeld@pinc-software.de.
3 * Copyright 2002, Marcus Overhagen. All Rights Reserved.
4 * Distributed under the terms of the MIT License.
8 //! A cache for BBuffers to be received by BBufferConsumer::BufferReceived().
11 #include "BufferCache.h"
21 BufferCache::BufferCache()
26 BufferCache::~BufferCache()
28 for (BufferMap::iterator iterator
= fMap
.begin(); iterator
!= fMap
.end();
30 delete iterator
->second
;
36 BufferCache::GetBuffer(media_buffer_id id
)
41 BufferMap::iterator found
= fMap
.find(id
);
42 if (found
!= fMap
.end())
45 buffer_clone_info info
;
47 BBuffer
* buffer
= new(std::nothrow
) BBuffer(info
);
48 if (buffer
== NULL
|| buffer
->Data() == NULL
) {
54 fMap
.insert(std::make_pair(id
, buffer
));
55 } catch (std::bad_alloc
& exception
) {
64 } // namespace BPrivate