100 lines
2.4 KiB
C
100 lines
2.4 KiB
C
/* GStreamer
|
|
* Copyright (C) 2023 <[email protected]>
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Library General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Library General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Library General Public
|
|
* License along with this library; if not, write to the
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
* Boston, MA 02110-1301, USA.
|
|
*/
|
|
|
|
#include "gstamldmxmgr.h"
|
|
|
|
GST_DEBUG_CATEGORY_EXTERN(gst_amlhwdmx_mgr_debug);
|
|
#ifdef GST_CAT_DEFAULT
|
|
#undef GST_CAT_DEFAULT
|
|
#endif
|
|
#define GST_CAT_DEFAULT gst_amlhwdmx_mgr_debug
|
|
|
|
typedef struct _GstAmlhwdmxMgr GstAmlhwdmxMgr;
|
|
|
|
struct _GstAmlhwdmxMgr
|
|
{
|
|
gboolean used_dmx_id[DMX_DEV_NUM];
|
|
};
|
|
|
|
void *gst_aml_dmxmgr_init()
|
|
{
|
|
GstAmlhwdmxMgr *dmx_mgr;
|
|
|
|
if (!(dmx_mgr = g_slice_new0(GstAmlhwdmxMgr)))
|
|
goto done;
|
|
|
|
for (guint i = 0; i < DMX_DVB_RESERVE_NUM; i++)
|
|
dmx_mgr->used_dmx_id[i] = TRUE;
|
|
|
|
done:
|
|
return (void *)dmx_mgr;
|
|
}
|
|
|
|
void gst_aml_dmxmgr_finalize(void *dmx_mgr)
|
|
{
|
|
g_assert(dmx_mgr != NULL);
|
|
|
|
g_slice_free(GstAmlhwdmxMgr, dmx_mgr);
|
|
}
|
|
|
|
gboolean gst_aml_dmxmgr_acquire(void *dmx_mgr, gint *id)
|
|
{
|
|
GstAmlhwdmxMgr *mgr;
|
|
gboolean ret = FALSE;
|
|
|
|
g_assert(dmx_mgr != NULL);
|
|
|
|
*id = -1;
|
|
mgr = (GstAmlhwdmxMgr *)dmx_mgr;
|
|
|
|
for (guint i = 0; i < DMX_DEV_NUM; i++)
|
|
{
|
|
GST_DEBUG("dmx id[%d] used:%d", i, mgr->used_dmx_id[i]);
|
|
if (!mgr->used_dmx_id[i])
|
|
{
|
|
ret = TRUE;
|
|
*id = i;
|
|
mgr->used_dmx_id[i] = TRUE;
|
|
break;
|
|
}
|
|
}
|
|
|
|
GST_DEBUG("acquire ret:%d with dmx_id:%d ", ret, *id);
|
|
return ret;
|
|
}
|
|
|
|
gboolean gst_aml_dmxmgr_release(void *dmx_mgr, gint id)
|
|
{
|
|
GstAmlhwdmxMgr *mgr;
|
|
gboolean ret = FALSE;
|
|
|
|
g_assert(dmx_mgr != NULL);
|
|
|
|
mgr = (GstAmlhwdmxMgr *)dmx_mgr;
|
|
|
|
if (id < 0 || id >= DMX_DEV_NUM)
|
|
goto done;
|
|
|
|
mgr->used_dmx_id[id] = FALSE;
|
|
ret = TRUE;
|
|
|
|
done:
|
|
GST_DEBUG("release ret:%d with dmx_id:%d ", ret, id);
|
|
return ret;
|
|
} |