new = g_new (GstTensorRepoData, 1);
new->eos = FALSE;
new->buffer = NULL;
- g_cond_init (&new->cond);
+ g_cond_init (&new->cond_push);
+ g_cond_init (&new->cond_pull);
g_mutex_init (&new->lock);
ret = g_hash_table_insert (_repo.hash, GINT_TO_POINTER (nth), new);
GstTensorRepoData *data = gst_tensor_repo_get_repodata (nth);
- if (data == NULL) {
- GST_TENSOR_REPO_UNLOCK (nth);
- return FALSE;
+ while (data->buffer != NULL) {
+ GST_TENSOR_REPO_WAIT_PULL (nth);
}
data->buffer = buffer;
GST_DEBUG ("Pushed [%d] (size : %lu)\n", nth, size);
}
- GST_TENSOR_REPO_SIGNAL (nth);
+ GST_TENSOR_REPO_SIGNAL_PUSH (nth);
GST_TENSOR_REPO_UNLOCK (nth);
return TRUE;
}
GST_TENSOR_REPO_LOCK (nth);
GstTensorRepoData *data = gst_tensor_repo_get_repodata (nth);
data->eos = TRUE;
- GST_TENSOR_REPO_SIGNAL (nth);
+ GST_TENSOR_REPO_SIGNAL_PUSH (nth);
GST_TENSOR_REPO_UNLOCK (nth);
return data->eos;
}
eos = TRUE;
break;
}
- GST_TENSOR_REPO_WAIT (nth);
+ GST_TENSOR_REPO_WAIT_PUSH (nth);
}
if (eos) {
if (DBG)
}
}
current_data->buffer = NULL;
+ GST_TENSOR_REPO_SIGNAL_PULL (nth);
GST_TENSOR_REPO_UNLOCK (nth);
return buf;
}
gboolean ret;
GST_REPO_LOCK ();
g_mutex_clear (GST_TENSOR_REPO_GET_LOCK (nth));
- g_cond_clear (GST_TENSOR_REPO_GET_COND (nth));
+ g_cond_clear (GST_TENSOR_REPO_GET_COND_PULL (nth));
+ g_cond_clear (GST_TENSOR_REPO_GET_COND_PUSH (nth));
ret = g_hash_table_remove (_repo.hash, GINT_TO_POINTER (nth));
typedef struct
{
GstBuffer *buffer;
- GCond cond;
+ GCond cond_push;
+ GCond cond_pull;
GMutex lock;
gboolean eos;
} GstTensorRepoData;
* @brief Macro for Lock & Cond
*/
#define GST_TENSOR_REPO_GET_LOCK(id) (&((GstTensorRepoData*)(gst_tensor_repo_get_repodata(id)))->lock)
-#define GST_TENSOR_REPO_GET_COND(id) (&((GstTensorRepoData*)(gst_tensor_repo_get_repodata(id)))->cond)
+#define GST_TENSOR_REPO_GET_COND_PUSH(id) (&((GstTensorRepoData*)(gst_tensor_repo_get_repodata(id)))->cond_push)
+#define GST_TENSOR_REPO_GET_COND_PULL(id) (&((GstTensorRepoData*)(gst_tensor_repo_get_repodata(id)))->cond_pull)
#define GST_TENSOR_REPO_LOCK(id) (g_mutex_lock(GST_TENSOR_REPO_GET_LOCK(id)))
#define GST_TENSOR_REPO_UNLOCK(id) (g_mutex_unlock(GST_TENSOR_REPO_GET_LOCK(id)))
-#define GST_TENSOR_REPO_WAIT(id) (g_cond_wait(GST_TENSOR_REPO_GET_COND(id), GST_TENSOR_REPO_GET_LOCK(id)))
-#define GST_TENSOR_REPO_SIGNAL(id) (g_cond_signal (GST_TENSOR_REPO_GET_COND(id)))
+#define GST_TENSOR_REPO_WAIT_PULL(id) (g_cond_wait(GST_TENSOR_REPO_GET_COND_PULL(id), GST_TENSOR_REPO_GET_LOCK(id)))
+#define GST_TENSOR_REPO_WAIT_PUSH(id) (g_cond_wait(GST_TENSOR_REPO_GET_COND_PUSH(id), GST_TENSOR_REPO_GET_LOCK(id)))
+#define GST_TENSOR_REPO_SIGNAL_PULL(id) (g_cond_signal (GST_TENSOR_REPO_GET_COND_PULL(id)))
+#define GST_TENSOR_REPO_SIGNAL_PUSH(id) (g_cond_signal (GST_TENSOR_REPO_GET_COND_PUSH(id)))
#define GST_REPO_LOCK()(g_mutex_lock(&_repo.repo_lock))
#define GST_REPO_UNLOCK()(g_mutex_unlock(&_repo.repo_lock))
#define GST_REPO_WAIT() (g_cond_wait(&_repo.repo_cond, &_repo.repo_lock))