daemon: initial room object implementation

This commit is contained in:
Nedko Arnaudov 2010-01-10 17:44:14 +02:00
parent b8498c5ad3
commit 0a60fa61a6
4 changed files with 127 additions and 12 deletions

View File

@ -2,7 +2,7 @@
/*
* LADI Session Handler (ladish)
*
* Copyright (C) 2009 Nedko Arnaudov <nedko@arnaudov.name>
* Copyright (C) 2009,2010 Nedko Arnaudov <nedko@arnaudov.name>
*
**************************************************************************
* This file contains stuff that is needed almost everywhere in the ladishd
@ -55,17 +55,6 @@ struct connection
struct port * playback_port_ptr; /* The playback input port */
};
struct room
{
struct list_head siblings; /* link for studio::rooms list */
struct list_head clients; /* non-virtual room clients */
struct list_head ports; /* ports of the room clients */
uuid_t uuid; /* The UUID of the room */
char * name; /* Name of the room */
struct client * link_client_ptr; /* client that connects the room to studio */
struct studio * studio_ptr; /* Studio connected to the room */
};
#include "studio.h"
extern bool g_quit;

81
daemon/room.c Normal file
View File

@ -0,0 +1,81 @@
/* -*- Mode: C ; c-basic-offset: 2 -*- */
/*
* LADI Session Handler (ladish)
*
* Copyright (C) 2010 Nedko Arnaudov <nedko@arnaudov.name>
*
**************************************************************************
* This file contains implementation of the room object
**************************************************************************
*
* LADI Session Handler is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* LADI Session Handler 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
* or write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "room.h"
struct ladish_room
{
uuid_t uuid;
char * name;
};
bool
ladish_room_create(
const uuid_t uuid_ptr,
const char * name,
ladish_room_handle * room_handle_ptr)
{
struct ladish_room * room_ptr;
room_ptr = malloc(sizeof(struct ladish_room));
if (room_ptr == NULL)
{
log_error("malloc() failed to allocate struct ladish_room");
return false;
}
if (uuid_ptr == NULL)
{
uuid_generate(room_ptr->uuid);
}
else
{
uuid_copy(room_ptr->uuid, uuid_ptr);
}
room_ptr->name = strdup(name);
if (room_ptr->name == NULL)
{
log_error("strdup() failed for room name");
free(room_ptr);
return false;
}
*room_handle_ptr = (ladish_room_handle)room_ptr;
return true;
}
#define room_ptr ((struct ladish_room *)room_handle)
void
ladish_room_destroy(
ladish_room_handle room_handle)
{
free(room_ptr->name);
free(room_ptr);
}
#undef room_ptr

44
daemon/room.h Normal file
View File

@ -0,0 +1,44 @@
/* -*- Mode: C ; c-basic-offset: 2 -*- */
/*
* LADI Session Handler (ladish)
*
* Copyright (C) 2010 Nedko Arnaudov <nedko@arnaudov.name>
*
**************************************************************************
* This file contains interface of the room object
**************************************************************************
*
* LADI Session Handler is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* LADI Session Handler 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
* or write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef ROOM_H__9A1CF253_0A17_402A_BDF8_9BD72B467118__INCLUDED
#define ROOM_H__9A1CF253_0A17_402A_BDF8_9BD72B467118__INCLUDED
#include "common.h"
typedef struct ladish_room_tag { int unused; } * ladish_room_handle;
bool
ladish_room_create(
const uuid_t uuid_ptr,
const char * name,
ladish_room_handle * room_handle_ptr);
void
ladish_room_destroy(
ladish_room_handle room_handle);
#endif /* #ifndef ROOM_H__9A1CF253_0A17_402A_BDF8_9BD72B467118__INCLUDED */

View File

@ -231,6 +231,7 @@ def build(bld):
'cmd_exit.c',
'cqueue.c',
'app_supervisor.c',
'room.c',
]:
daemon.source.append(os.path.join("daemon", source))