summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/decoder.cc11
-rw-r--r--src/encoder.cc3
-rw-r--r--src/frame.cc9
-rw-r--r--src/player.cc2
-rw-r--r--src/queue.h4
5 files changed, 17 insertions, 12 deletions
diff --git a/src/decoder.cc b/src/decoder.cc
index 9798b03..cd5806f 100644
--- a/src/decoder.cc
+++ b/src/decoder.cc
@@ -69,11 +69,13 @@ void Decoder::decode()
// Read a dvframe
ptr = dv_stream.readFrame();
if(!ptr) return; // No frame read. (Due to firewire error)
- Frame *frame = new Frame(ptr, DVPACKAGE_SIZE);
+ Frame *eframe = new Frame(ptr, DVPACKAGE_SIZE);
+ Frame *pframe = new Frame(ptr, DVPACKAGE_SIZE);
+ free(ptr);
pthread_mutex_lock(mutex);
- encode_queue->push(frame);
- player_queue->push(frame);
+ encode_queue->push(eframe);
+ player_queue->push(pframe);
pthread_mutex_unlock(mutex);
sem_post(encode_sem);
@@ -84,9 +86,6 @@ void Decoder::decode()
user_event.user.data1 = NULL;
user_event.user.data2 = NULL;
SDL_PushEvent(&user_event);
-
- // Free framedata.
- // free(ptr);
}
// Kick the others so they wake up with empty queues
diff --git a/src/encoder.cc b/src/encoder.cc
index d3f4925..08b587d 100644
--- a/src/encoder.cc
+++ b/src/encoder.cc
@@ -94,8 +94,7 @@ void Encoder::encode()
n->sendPackage(&h, frame->data, frame->size);
- // free(f->data);
- // delete f;
+ delete frame;
}
}
// pthread_exit(NULL);
diff --git a/src/frame.cc b/src/frame.cc
index 6a1ba70..4b94fcb 100644
--- a/src/frame.cc
+++ b/src/frame.cc
@@ -28,13 +28,20 @@
#include "debug.h"
+#include <memory.h>
+#include <stdlib.h>
+
Frame::Frame(unsigned char *d, int sz)
{
- data = d;
+ data = (unsigned char *)malloc(sz);
+ memcpy(data, d, sz);
size = sz;
}
Frame::~Frame()
{
+ free(data);
+ data = NULL;
+ size = 0;
}
diff --git a/src/player.cc b/src/player.cc
index bb712f6..8492d42 100644
--- a/src/player.cc
+++ b/src/player.cc
@@ -164,7 +164,7 @@ void Player::player()
SDL_UnlockYUVOverlay(overlay);
SDL_DisplayYUVOverlay(overlay, &rect);
- // delete frame;
+ delete frame;
break;
case SDL_QUIT:
diff --git a/src/queue.h b/src/queue.h
index 8851c57..7352071 100644
--- a/src/queue.h
+++ b/src/queue.h
@@ -70,7 +70,7 @@ Queue<T>::~Queue()
{
if(count != 0) {
fprintf(stderr, "Queue not empty (%d)\n", count);
- while(T *t = pop()) {}//delete t;
+ while(T *t = pop()) delete t;
}
}
@@ -84,7 +84,7 @@ void Queue<T>::push(T *t)
if(limit && count > 0) {
T* tmp = (T*)pop();
- // delete tmp;
+ delete tmp;
}
if(!head) {