Ticket #6188: 0003-Correctly-check-when-the-BBuffer-failed-the-registra.patch

File 0003-Correctly-check-when-the-BBuffer-failed-the-registra.patch, 2.0 KB (added by Barrett, 5 years ago)
  • src/kits/media/BufferCache.cpp

    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)  
    4242    buffer_clone_info info;
    4343    info.buffer = id;
    4444    BBuffer* buffer = new(std::nothrow) BBuffer(info);
    45     if (buffer == NULL)
     45    if (buffer == NULL || buffer->Data() == NULL) {
     46        delete buffer;
    4647        return NULL;
     48    }
    4749
    4850    try {
    4951        fMap.insert(std::make_pair(id, buffer));
  • src/kits/media/BufferConsumer.cpp

    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)  
    385385                = static_cast<const consumer_buffer_received_command*>(data);
    386386
    387387            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            }
    396401            return B_OK;
    397402        }
    398403