X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fmiracle%2Fmiracle_server.c;h=a746c8bd033dcba0453ddad13c67c7106733521d;hb=bf3264b9e340ba5c11cbf59835a8af3db94e0cc2;hp=94a15e514ab54d9c9bdf1e5b8cd03157b728f261;hpb=1a2a5ad3793a0b6b6ed53f3e5e50a4bea4c99b0b;p=melted diff --git a/src/miracle/miracle_server.c b/src/miracle/miracle_server.c index 94a15e5..a746c8b 100644 --- a/src/miracle/miracle_server.c +++ b/src/miracle/miracle_server.c @@ -1,5 +1,5 @@ /* - * miracle_server.c -- DV Server + * miracle_server.c * Copyright (C) 2002-2003 Ushodaya Enterprises Limited * Author: Charles Yates * @@ -41,6 +41,7 @@ #include "miracle_connection.h" #include "miracle_local.h" #include "miracle_log.h" +#include "miracle_commands.h" #include #include @@ -86,6 +87,11 @@ miracle_server miracle_server_init( char *id ) return server; } +const char *miracle_server_id( miracle_server server ) +{ + return server != NULL && server->id != NULL ? server->id : "miracle"; +} + void miracle_server_set_config( miracle_server server, char *config ) { if ( server != NULL ) @@ -152,11 +158,6 @@ static void *miracle_server_run( void *arg ) their resources get freed automatically. (CY: ... hmmph...) */ pthread_attr_init( &thread_attributes ); pthread_attr_setdetachstate( &thread_attributes, PTHREAD_CREATE_DETACHED ); - pthread_attr_init( &thread_attributes ); - pthread_attr_setinheritsched( &thread_attributes, PTHREAD_INHERIT_SCHED ); - /* pthread_attr_setschedpolicy( &thread_attributes, SCHED_RR ); */ - - server->shutdown = 0; while ( !server->shutdown ) { @@ -193,6 +194,8 @@ int miracle_server_execute( miracle_server server ) struct sockaddr_in ServerAddr; int flag = 1; + server->shutdown = 0; + ServerAddr.sin_family = AF_INET; ServerAddr.sin_port = htons( server->port ); ServerAddr.sin_addr.s_addr = INADDR_ANY; @@ -261,25 +264,13 @@ int miracle_server_execute( miracle_server server ) if ( response != NULL ) { - pthread_attr_t attr; int result; - pthread_attr_init( &attr ); - pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_JOINABLE ); - pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED ); - pthread_attr_setschedpolicy( &attr, SCHED_FIFO ); - pthread_attr_setscope( &attr, PTHREAD_SCOPE_SYSTEM ); valerie_response_close( response ); - result = pthread_create( &server->thread, &attr, miracle_server_run, server ); + result = pthread_create( &server->thread, NULL, miracle_server_run, server ); if ( result ) { - miracle_log( LOG_WARNING, "Failed to schedule realtime (%s)", strerror(errno) ); - pthread_attr_setschedpolicy( &attr, SCHED_OTHER ); - result = pthread_create( &server->thread, &attr, miracle_server_run, server ); - if ( result ) - { - miracle_log( LOG_CRIT, "Failed to launch TCP listener thread" ); - error = -1; - } + miracle_log( LOG_CRIT, "Failed to launch TCP listener thread" ); + error = -1; } } } @@ -293,6 +284,15 @@ int miracle_server_execute( miracle_server server ) return error; } +/** Fetch a units properties +*/ + +mlt_properties miracle_server_fetch_unit( miracle_server server, int index ) +{ + miracle_unit unit = miracle_get_unit( index ); + return unit != NULL ? unit->properties : NULL; +} + /** Shutdown the server. */