-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgstplayertaskpool.cpp
More file actions
120 lines (103 loc) · 3.32 KB
/
Copy pathgstplayertaskpool.cpp
File metadata and controls
120 lines (103 loc) · 3.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
* If not stated otherwise in this file or this component's license file the
* following copyright and licenses apply:
*
* Copyright 2024 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file gstplayertaskpool.cpp
* @brief PLAYER Gstreamer Task pool code
*/
#include <gst/gst.h>
#include "gstplayertaskpool.h"
#include <pthread.h>
/**
* @brief PlayerGstTaskId to store the threadId
*/
typedef struct
{
pthread_t thread;
} PlayerGstTaskId;
/** class initialization */
#define gst_player_taskpool_parent_class parent_class
G_DEFINE_TYPE(GstPlayerTaskpool, gst_player_taskpool, GST_TYPE_TASK_POOL);
GST_DEBUG_CATEGORY(gst_player_taskpool_debug_category);
#define GST_CAT_DEFAULT gst_player_taskpool_debug_category
/**
* @brief Override for gst_task_pool_push
* Start the execution of a new thread from pool.
* In this case create and assign a thread for gst task
*
* Not setting any specific policies or priorities for now
* as the pthread implementation takes thread attributes automatically
* from the calling thread.
*
* For now we just need same priority for PLAYER gst threads, and if enabled
* RT priority is set on PLAYER thread which setup the pipeline thus the gst
* threads also get same priority
*
* @param pool GstTaskPool
* @param func the function to call
* @param data data to pass to func
* @param error stores error
* @return gpointer a pointer that should be used for the gst_task_pool_join function
*/
static gpointer gst_player_taskpool_push (GstTaskPool * pool, GstTaskPoolFunction func, gpointer data,
GError ** error)
{
PlayerGstTaskId *tid;
gint res;
tid = g_new0 (PlayerGstTaskId, 1);
res = pthread_create (&tid->thread, NULL, (void *(*)(void *)) func, data);
if (res != 0) {
g_set_error (error, G_THREAD_ERROR, G_THREAD_ERROR_AGAIN,
"Error creating thread: %s", g_strerror (res));
g_free (tid);
tid = NULL;
}
return tid;
}
/**
* @brief Override for gst_task_pool_join
* Used to join the created thread
* @param pool GstTaskPool
* @param id TaskId containing the thread info to join
*/
static void gst_player_taskpool_join (GstTaskPool * pool, gpointer id)
{
PlayerGstTaskId *tid = (PlayerGstTaskId *) id;
pthread_join (tid->thread, NULL);
g_free (tid);
}
/**
* @brief class_init function for gst_player_taskpool
*
* @param klass GstPlayerTaskpoolClass defined in header file
*/
static void gst_player_taskpool_class_init (GstPlayerTaskpoolClass * klass)
{
GstTaskPoolClass *gsttaskpool_class;
gsttaskpool_class = (GstTaskPoolClass *) klass;
gsttaskpool_class->push = gst_player_taskpool_push;
gsttaskpool_class->join = gst_player_taskpool_join;
}
/**
* @brief gst_player_taskpool_init
*
* @param pool
*/
static void gst_player_taskpool_init (GstPlayerTaskpool * pool)
{
}