mirror of
https://gitlab.xiph.org/xiph/icecast-common.git
synced 2024-12-04 14:46:31 -05:00
Feature: Added igloo_io_new()
This commit is contained in:
parent
71176a6fc5
commit
812a2ccaaf
@ -119,6 +119,19 @@ typedef struct {
|
||||
#endif
|
||||
} igloo_io_ifdesc_t;
|
||||
|
||||
/* This creates a new IO handle from a interface description and state.
|
||||
* Parameters:
|
||||
* ifdesc
|
||||
* The interface description to use.
|
||||
* backend_object
|
||||
* A object used by the backend or igloo_RO_NULL.
|
||||
* backend_userdata
|
||||
* A userdata pointer used by the backend or NULL.
|
||||
* name, associated
|
||||
* See refobject_new().
|
||||
*/
|
||||
igloo_io_t * igloo_io_new(const igloo_io_ifdesc_t *ifdesc, igloo_ro_t backend_object, void *backend_userdata, const char *name, igloo_ro_t associated);
|
||||
|
||||
/* Read data from a IO handle.
|
||||
* Parameters:
|
||||
* io
|
||||
|
@ -20,7 +20,7 @@ void igloo_interface_base_free(igloo_ro_t self)
|
||||
{
|
||||
igloo__interface_base_t *iface = igloo_INTERFACE_CAST(self);
|
||||
|
||||
if (iface->ifdesc->free)
|
||||
if (iface->ifdesc && iface->ifdesc->free)
|
||||
iface->ifdesc->free(igloo_INTERFACE_BASIC_CALL(self));
|
||||
|
||||
if (!igloo_RO_IS_NULL(iface->backend_object))
|
||||
|
28
src/io.c
28
src/io.c
@ -29,6 +29,34 @@ igloo_RO_PUBLIC_TYPE(igloo_io_t,
|
||||
igloo_RO_TYPEDECL_FREE(igloo_interface_base_free)
|
||||
);
|
||||
|
||||
|
||||
igloo_io_t * igloo_io_new(const igloo_io_ifdesc_t *ifdesc, igloo_ro_t backend_object, void *backend_userdata, const char *name, igloo_ro_t associated)
|
||||
{
|
||||
igloo_io_t *io;
|
||||
|
||||
if (!ifdesc)
|
||||
return NULL;
|
||||
|
||||
io = igloo_ro_new_raw(igloo_io_t, name, associated);
|
||||
|
||||
if (!io)
|
||||
return NULL;
|
||||
|
||||
if (!igloo_RO_IS_NULL(backend_object)) {
|
||||
if (igloo_ro_ref(backend_object) != 0) {
|
||||
igloo_ro_unref(io);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
io->ifdesc = ifdesc;
|
||||
io->backend_object = backend_object;
|
||||
io->backend_userdata = backend_userdata;
|
||||
|
||||
return io;
|
||||
}
|
||||
|
||||
|
||||
ssize_t igloo_io_read(igloo_io_t *io, void *buffer, size_t len)
|
||||
{
|
||||
if (!io || !buffer)
|
||||
|
Loading…
Reference in New Issue
Block a user