decklink: Fix indentation

This commit is contained in:
Sebastian Dröge 2017-08-02 18:43:54 +03:00
parent 58e2b2ef1c
commit 571c8bc1ff
3 changed files with 35 additions and 41 deletions

View File

@ -865,36 +865,33 @@ private:
GMutex m_mutex; GMutex m_mutex;
uint32_t m_lastBufferSize; uint32_t m_lastBufferSize;
uint32_t m_nonEmptyCalls; uint32_t m_nonEmptyCalls;
GstQueueArray * m_buffers; GstQueueArray *m_buffers;
gint m_refcount; gint m_refcount;
void _clearBufferPool() void _clearBufferPool ()
{ {
uint8_t * buf; uint8_t *buf;
if (!m_buffers) if (!m_buffers)
return; return;
while ((buf = (uint8_t*)gst_queue_array_pop_head (m_buffers))) while ((buf = (uint8_t *) gst_queue_array_pop_head (m_buffers)))
g_free(buf - 128); g_free (buf - 128);
} }
public: public:
GStreamerDecklinkMemoryAllocator () GStreamerDecklinkMemoryAllocator ()
: IDeckLinkMemoryAllocator (), : IDeckLinkMemoryAllocator (),
m_lastBufferSize (0), m_lastBufferSize (0),
m_nonEmptyCalls (0), m_nonEmptyCalls (0), m_buffers (NULL), m_refcount (1)
m_buffers (NULL),
m_refcount (1)
{ {
g_mutex_init (&m_mutex); g_mutex_init (&m_mutex);
m_buffers = gst_queue_array_new (60); m_buffers = gst_queue_array_new (60);
} }
virtual ~ GStreamerDecklinkMemoryAllocator () virtual ~ GStreamerDecklinkMemoryAllocator () {
{ Decommit ();
Decommit();
gst_queue_array_free (m_buffers); gst_queue_array_free (m_buffers);
@ -938,20 +935,20 @@ public:
virtual HRESULT STDMETHODCALLTYPE virtual HRESULT STDMETHODCALLTYPE
AllocateBuffer (uint32_t bufferSize, void **allocatedBuffer) AllocateBuffer (uint32_t bufferSize, void **allocatedBuffer)
{ {
uint8_t * buf; uint8_t *buf;
g_mutex_lock (&m_mutex); g_mutex_lock (&m_mutex);
/* If buffer size changed since last call, empty buffer pool */ /* If buffer size changed since last call, empty buffer pool */
if (bufferSize != m_lastBufferSize) { if (bufferSize != m_lastBufferSize) {
_clearBufferPool(); _clearBufferPool ();
m_lastBufferSize = bufferSize; m_lastBufferSize = bufferSize;
} }
/* Look if there is a free buffer in the pool */ /* Look if there is a free buffer in the pool */
if (!(buf = (uint8_t*) gst_queue_array_pop_head (m_buffers))) { if (!(buf = (uint8_t *) gst_queue_array_pop_head (m_buffers))) {
/* If not, alloc a new one */ /* If not, alloc a new one */
buf = (uint8_t*) g_malloc (bufferSize + 128); buf = (uint8_t *) g_malloc (bufferSize + 128);
*((uint32_t *) buf) = bufferSize; *((uint32_t *) buf) = bufferSize;
buf += 128; buf += 128;
} }
@ -961,7 +958,7 @@ public:
* remove one of them every fifth call */ * remove one of them every fifth call */
if (gst_queue_array_get_length (m_buffers) > 0) { if (gst_queue_array_get_length (m_buffers) > 0) {
if (++m_nonEmptyCalls >= 5) { if (++m_nonEmptyCalls >= 5) {
buf = (uint8_t*) gst_queue_array_pop_head (m_buffers) - 128; buf = (uint8_t *) gst_queue_array_pop_head (m_buffers) - 128;
g_free (buf); g_free (buf);
m_nonEmptyCalls = 0; m_nonEmptyCalls = 0;
} }
@ -974,13 +971,12 @@ public:
return S_OK; return S_OK;
} }
virtual HRESULT STDMETHODCALLTYPE virtual HRESULT STDMETHODCALLTYPE ReleaseBuffer (void *buffer)
ReleaseBuffer (void * buffer)
{ {
g_mutex_lock (&m_mutex); g_mutex_lock (&m_mutex);
/* Put the buffer back to the pool if size matches with current pool */ /* Put the buffer back to the pool if size matches with current pool */
uint32_t size = *(uint32_t *) ((uint8_t*)buffer - 128); uint32_t size = *(uint32_t *) ((uint8_t *) buffer - 128);
if (size == m_lastBufferSize) { if (size == m_lastBufferSize) {
gst_queue_array_push_tail (m_buffers, buffer); gst_queue_array_push_tail (m_buffers, buffer);
} else { } else {
@ -992,17 +988,15 @@ public:
return S_OK; return S_OK;
} }
virtual HRESULT STDMETHODCALLTYPE virtual HRESULT STDMETHODCALLTYPE Commit ()
Commit ()
{ {
return S_OK; return S_OK;
} }
virtual HRESULT STDMETHODCALLTYPE virtual HRESULT STDMETHODCALLTYPE Decommit ()
Decommit ()
{ {
/* Clear all remaining pools */ /* Clear all remaining pools */
_clearBufferPool(); _clearBufferPool ();
return S_OK; return S_OK;
} }
@ -1299,8 +1293,8 @@ gst_decklink_acquire_nth_input (gint n, GstElement * src, gboolean is_audio)
} }
g_mutex_lock (&input->lock); g_mutex_lock (&input->lock);
input->input->SetVideoInputFrameMemoryAllocator( input->input->SetVideoInputFrameMemoryAllocator (new
new GStreamerDecklinkMemoryAllocator); GStreamerDecklinkMemoryAllocator);
if (is_audio && !input->audiosrc) { if (is_audio && !input->audiosrc) {
input->audiosrc = GST_ELEMENT_CAST (gst_object_ref (src)); input->audiosrc = GST_ELEMENT_CAST (gst_object_ref (src));
g_mutex_unlock (&input->lock); g_mutex_unlock (&input->lock);

View File

@ -275,8 +275,8 @@ public:
written_sum += written; written_sum += written;
} while (len > 0 && res == S_OK); } while (len > 0 && res == S_OK);
GST_LOG_OBJECT (m_ringbuffer->sink, "Wrote %u samples: 0x%08lx", written_sum, GST_LOG_OBJECT (m_ringbuffer->sink, "Wrote %u samples: 0x%08lx",
(unsigned long) res); written_sum, (unsigned long) res);
gst_audio_ring_buffer_clear (GST_AUDIO_RING_BUFFER_CAST (m_ringbuffer), gst_audio_ring_buffer_clear (GST_AUDIO_RING_BUFFER_CAST (m_ringbuffer),
seg); seg);

View File

@ -71,9 +71,8 @@ public:
return ret; return ret;
} }
virtual HRESULT WINAPI ScheduledFrameCompleted ( virtual HRESULT WINAPI ScheduledFrameCompleted (IDeckLinkVideoFrame *
IDeckLinkVideoFrame * completedFrame, completedFrame, BMDOutputFrameCompletionResult result)
BMDOutputFrameCompletionResult result)
{ {
switch (result) { switch (result) {
case bmdOutputFrameCompleted: case bmdOutputFrameCompleted:
@ -624,7 +623,8 @@ gst_decklink_video_sink_prepare (GstBaseSink * bsink, GstBuffer * buffer)
frame->GetBytes ((void **) &outdata); frame->GetBytes ((void **) &outdata);
indata = (guint8 *) GST_VIDEO_FRAME_PLANE_DATA (&vframe, 0); indata = (guint8 *) GST_VIDEO_FRAME_PLANE_DATA (&vframe, 0);
stride = MIN (GST_VIDEO_FRAME_PLANE_STRIDE (&vframe, 0), frame->GetRowBytes()); stride =
MIN (GST_VIDEO_FRAME_PLANE_STRIDE (&vframe, 0), frame->GetRowBytes ());
for (i = 0; i < self->info.height; i++) { for (i = 0; i < self->info.height; i++) {
memcpy (outdata, indata, stride); memcpy (outdata, indata, stride);
indata += GST_VIDEO_FRAME_PLANE_STRIDE (&vframe, 0); indata += GST_VIDEO_FRAME_PLANE_STRIDE (&vframe, 0);