From 62e74f0087d2acd91fc11fc5e0c7ef92d6ed68b4 Mon Sep 17 00:00:00 2001
From: Dario Casalinuovo <b.vitruvio@gmail.com>
Date: Fri, 10 Apr 2015 00:04:24 +0200
Subject: [PATCH 3/3] Correctly check when the BBuffer failed the registration
with the server.
---
src/kits/media/BufferCache.cpp | 4 +++-
src/kits/media/BufferConsumer.cpp | 21 +++++++++++++--------
2 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/src/kits/media/BufferCache.cpp b/src/kits/media/BufferCache.cpp
index 10947df..69d5eda 100644
a
|
b
|
BufferCache::GetBuffer(media_buffer_id id)
|
42 | 42 | buffer_clone_info info; |
43 | 43 | info.buffer = id; |
44 | 44 | BBuffer* buffer = new(std::nothrow) BBuffer(info); |
45 | | if (buffer == NULL) |
| 45 | if (buffer == NULL || buffer->Data() == NULL) { |
| 46 | delete buffer; |
46 | 47 | return NULL; |
| 48 | } |
47 | 49 | |
48 | 50 | try { |
49 | 51 | fMap.insert(std::make_pair(id, buffer)); |
diff --git a/src/kits/media/BufferConsumer.cpp b/src/kits/media/BufferConsumer.cpp
index 29ae9a2..edd5b57 100644
a
|
b
|
BBufferConsumer::HandleMessage(int32 message, const void* data, size_t size)
|
385 | 385 | = static_cast<const consumer_buffer_received_command*>(data); |
386 | 386 | |
387 | 387 | BBuffer* buffer = fBufferCache->GetBuffer(command->buffer); |
388 | | buffer->SetHeader(&command->header); |
389 | | |
390 | | PRINT(4, "calling BBufferConsumer::BufferReceived buffer %ld at " |
391 | | "perf %Ld and TimeSource()->Now() is %Ld\n", |
392 | | buffer->Header()->buffer, buffer->Header()->start_time, |
393 | | TimeSource()->Now()); |
394 | | |
395 | | BufferReceived(buffer); |
| 388 | if (buffer == NULL) { |
| 389 | ERROR("BBufferConsumer::CONSUMER_BUFFER_RECEIVED can't" |
| 390 | "find the buffer\n"); |
| 391 | } else { |
| 392 | buffer->SetHeader(&command->header); |
| 393 | |
| 394 | PRINT(4, "calling BBufferConsumer::BufferReceived buffer %ld " |
| 395 | "at perf %Ld and TimeSource()->Now() is %Ld\n", |
| 396 | buffer->Header()->buffer, buffer->Header()->start_time, |
| 397 | TimeSource()->Now()); |
| 398 | |
| 399 | BufferReceived(buffer); |
| 400 | } |
396 | 401 | return B_OK; |
397 | 402 | } |
398 | 403 | |