Loading media/libmediatranscoding/transcoder/PassthroughTrackTranscoder.cpp +10 −9 Original line number Diff line number Diff line Loading @@ -44,23 +44,24 @@ uint8_t* PassthroughTrackTranscoder::BufferPool::getBufferWithSize(size_t minimu // Check if the free list contains a large enough buffer. auto it = mFreeBufferMap.lower_bound(minimumBufferSize); if (it != mFreeBufferMap.end()) { uint8_t* buffer = it->second; mFreeBufferMap.erase(it); return it->second; } // Allocate a new buffer. uint8_t* buffer = new (std::nothrow) uint8_t[minimumBufferSize]; if (buffer == nullptr) { LOG(ERROR) << "Unable to allocate new buffer of size: " << minimumBufferSize; return nullptr; return buffer; } // If the maximum buffer count is reached, remove an existing free buffer. if (mAddressSizeMap.size() >= mMaxBufferCount) { auto it = mFreeBufferMap.begin(); mFreeBufferMap.erase(it); mAddressSizeMap.erase(it->second); delete[] it->second; mFreeBufferMap.erase(it); } // Allocate a new buffer. uint8_t* buffer = new (std::nothrow) uint8_t[minimumBufferSize]; if (buffer == nullptr) { LOG(ERROR) << "Unable to allocate new buffer of size: " << minimumBufferSize; return nullptr; } // Add the buffer to the tracking set. Loading Loading
media/libmediatranscoding/transcoder/PassthroughTrackTranscoder.cpp +10 −9 Original line number Diff line number Diff line Loading @@ -44,23 +44,24 @@ uint8_t* PassthroughTrackTranscoder::BufferPool::getBufferWithSize(size_t minimu // Check if the free list contains a large enough buffer. auto it = mFreeBufferMap.lower_bound(minimumBufferSize); if (it != mFreeBufferMap.end()) { uint8_t* buffer = it->second; mFreeBufferMap.erase(it); return it->second; } // Allocate a new buffer. uint8_t* buffer = new (std::nothrow) uint8_t[minimumBufferSize]; if (buffer == nullptr) { LOG(ERROR) << "Unable to allocate new buffer of size: " << minimumBufferSize; return nullptr; return buffer; } // If the maximum buffer count is reached, remove an existing free buffer. if (mAddressSizeMap.size() >= mMaxBufferCount) { auto it = mFreeBufferMap.begin(); mFreeBufferMap.erase(it); mAddressSizeMap.erase(it->second); delete[] it->second; mFreeBufferMap.erase(it); } // Allocate a new buffer. uint8_t* buffer = new (std::nothrow) uint8_t[minimumBufferSize]; if (buffer == nullptr) { LOG(ERROR) << "Unable to allocate new buffer of size: " << minimumBufferSize; return nullptr; } // Add the buffer to the tracking set. Loading