Exemple #1
0
/* the main */
int main(void){
    /* the base directory to be used/created */
    const char *base_dir = "data";
    /* the default test db connection string */
    char DEFAULT_TEST_DB_CONN_STR[] = "@localhost";
    char *test_db = DEFAULT_TEST_DB_CONN_STR;

    /* create the target directory where the dump(s) will be stored */
    if( 0 > mkdir_recursive(base_dir)) {
        LOGGER_ERROR("Failed to create target directory: [%s]", base_dir);
        exit(EXIT_FAILURE);
    }
    LOGGER_INFO("target directory: [%s]", base_dir);

    /* the mysql_login_info struct will be used to access the database */
    struct mysql_login_info login_db_test;

    /* parse the test_db connection string in case of any errors */
    /* not necessarily used in this example unless you use a database
        connection string other than '@localhost' */
    if (0 > ribs_mysql_parse_db_conn_str(test_db, &login_db_test)) {
        LOGGER_ERROR("failed to parse DB connection string: [%s]", test_db);
        exit(EXIT_FAILURE);
    }
    login_db_test.db = DB_TEST;

    /* initialize the event loop */
    if( 0 > epoll_worker_init()) {
        LOGGER_ERROR("epoll_worker_init failed");
        exit(EXIT_FAILURE);
    }

    /* initialize the client pool */
    http_client_pool_init(&client_pool, 10, 10);

    /* initialize the query buffer used in dump_test_data() */
    struct vmbuf query = VMBUF_INITIALIZER;
    vmbuf_init(&query, 65536);

    /* dump the test db data table into its target directory */
    if( 0 > dump_test_data(base_dir, login_db_test, &query)) {
        LOGGER_ERROR("Faied to dump data from test db");
        exit(EXIT_FAILURE);
    }

    /* return when successful */
    LOGGER_INFO("completed successfully");
    exit(EXIT_SUCCESS);
    return 0;
}
Exemple #2
0
	ConverterInterfacePtr ConverterEngine::createConverter( const ConstString & _type )
	{
        LOGGER_INFO(m_serviceProvider)("ConverterEngine::createConverter %s"
            , _type.c_str()
            );

		TMapConverterSystem::iterator it_find = m_mapConverterSystem.find( _type );

		if( it_find == m_mapConverterSystem.end() )
		{
            LOGGER_INFO(m_serviceProvider)("ConverterEngine::createConverter not found converter %s"
                , _type.c_str()
                );

			return nullptr;
		}

		ConverterFactoryInterface * factory = it_find->second;

		if( factory == nullptr )
		{
			LOGGER_INFO( m_serviceProvider )("ConverterEngine::createConverter invalid factory %s is nullptr"
				, _type.c_str()
				);

			return nullptr;
		}

		ConverterInterfacePtr converter = factory->createConverter();

		if( converter == nullptr )
		{
            LOGGER_INFO(m_serviceProvider)("ConverterEngine::createConverter invalid create converter %s"
                , _type.c_str()
                );

			return nullptr;
		}

		if( converter->initialize() == false )
		{
            LOGGER_INFO(m_serviceProvider)("ConverterEngine::createConverter invalid initialize converter %s"
                , _type.c_str()
                );

			return nullptr;
		}

		return converter;
	}
Exemple #3
0
size_t builder::calculate_memory_limit() const {
     // compute memory parameters
    const size_t memory_budget = get_total_memory() * desc_.memory_ratio;
    const size_t occupied = get_total_memory() - get_available_memory();

    if (occupied >= memory_budget) {
        LOGGER_ERROR("Memory ratio is too small");
        return false;
    }
    size_t memory_limit = memory_budget - occupied; 
    LOGGER_INFO("Total physical memory: " << get_total_memory() / 1024 / 1024 << " MiB");
    LOGGER_INFO("Memory limit: " << memory_limit / 1024 / 1024 << " MiB");
    LOGGER_INFO("Precision for storing coordinates and radii: " << std::string((sizeof(real) == 8) ? "double" : "single"));   
    return memory_limit;
}
Exemple #4
0
int http_client_pool_init(struct http_client_pool *http_client_pool, size_t initial, size_t grow) {
    LOGGER_INFO("http client pool: initial=%zu, grow=%zu", initial, grow);
    if (0 > ctx_pool_init(&http_client_pool->ctx_pool, initial, grow, CLIENT_STACK_SIZE, sizeof(struct http_client_context)))
        return -1;

    /* Global to all clients */
    if (!client_chains) {
        struct rlimit rlim;
        if (0 > getrlimit(RLIMIT_NOFILE, &rlim))
            return LOGGER_PERROR("getrlimit(RLIMIT_NOFILE)"), -1;

        client_chains = calloc(rlim.rlim_cur, sizeof(struct list));
        if (!client_chains)
            return LOGGER_PERROR("calloc client_chains"), -1;

        /* storage for multiple client chains */
        client_heads = calloc(rlim.rlim_cur, sizeof(struct list));
        struct list *tmp = client_heads, *tmp_end = tmp + rlim.rlim_cur;
        if (!client_heads)
            return LOGGER_PERROR("calloc client_heads"), -1;
        for (; tmp != tmp_end; ++tmp)
            list_insert_tail(&free_list, tmp);

        idle_ctx = ribs_context_create(SMALL_STACK_SIZE, http_client_idle_handler);

        hashtable_init(&ht_persistent_clients, rlim.rlim_cur);
    }
    return timeout_handler_init(&http_client_pool->timeout_handler);
}
Exemple #5
0
/**
 * \~french
 * \brief Affiche l'utilisation et les différentes options de la commande tiff2tile
 * \details L'affichage se fait dans le niveau de logger INFO
 * \~ \code
 * tiff2tile version X.Y.Z
 * 
 * Make image tiled and compressed, in TIFF format, respecting ROK4 specifications.
 * 
 * Usage: tiff2tile -c <VAL> -t <VAL> <VAL> <INPUT FILE> <OUTPUT FILE> [-crop]
 * 
 * Parameters:
 *      -c output compression :
 *              raw     no compression
 *              none    no compression
 *              jpg     Jpeg encoding
 *              lzw     Lempel-Ziv & Welch encoding
 *              pkb     PackBits encoding
 *              zip     Deflate encoding
 *              png     Non-official TIFF compression, each tile is an independant PNG image (with PNG header)
 *      -t tile size : widthwise and heightwise. Have to be a divisor of the global image's size
 *      -crop : blocks (used by JPEG compression) wich contain a white pixel are filled with white
 *      -d debug logger activation
 * 
 * Examples
 *      - for orthophotography
 *      tiff2tile input.tif -c png -t 256 256 output.tif
 *      - for DTM
 *      tiff2tile input.tif -c zip -t 256 256 output.tif
 * 
 * \endcode
 */
void usage() {
    LOGGER_INFO ( "\ttiff2tile version " << BE4_VERSION << "\n\n" <<

                  "Make image tiled and compressed, in TIFF format, respecting ROK4 specifications.\n\n" <<

                  "Usage: tiff2tile -c <VAL> -t <VAL> <VAL> <INPUT FILE> <OUTPUT FILE> [-crop]\n\n" <<

                  "Parameters:\n" <<
                  "     -c output compression :\n" <<
                  "             raw     no compression\n" <<
                  "             none    no compression\n" <<
                  "             jpg     Jpeg encoding\n" <<
                  "             lzw     Lempel-Ziv & Welch encoding\n" <<
                  "             pkb     PackBits encoding\n" <<
                  "             zip     Deflate encoding\n" <<
                  "             png     Non-official TIFF compression, each tile is an independant PNG image (with PNG header)\n" <<
                  "     -t tile size : widthwise and heightwise. Have to be a divisor of the global image's size\n" <<
                  "     -crop : blocks (used by JPEG compression) wich contain a white pixel are filled with white\n" <<
                  "     -d : debug logger activation\n\n" <<

                  "Examples\n" <<
                  "     - for orthophotography\n" <<
                  "     tiff2tile input.tif -c png -t 256 256 output.tif\n" <<
                  "     - for DTM\n" <<
                  "     tiff2tile input.tif -c zip -t 256 256 output.tif\n\n" );
}
Exemple #6
0
int mysql_pool_get(struct mysql_login_info *info, struct mysql_pool_entry **mysql) {
    if (0 > make_ht_key(&misc, info))
        return -1;
    char *ht_key = vmbuf_data(&misc);
    size_t key_len = vmbuf_wlocpos(&misc);

    uint32_t ofs = hashtable_lookup(&ht_idle_connections, ht_key, key_len);
    if (0 == ofs) {
        struct list *l = (struct list *)calloc(1, sizeof(struct list));
        list_init(l);
        ofs = hashtable_insert(&ht_idle_connections,
                               ht_key, key_len,
                               &l, sizeof(struct list *));
        if (0 == ofs) // unable to insert
            return -1;
        // add one element since we know there isn't any
        if (0 > create_entry(l))
            return -1;
        // get first free element
        if (0 > get_free_entry(info, l, mysql))
            return -1;
    }
    struct list *l = *(struct list **)hashtable_get_val(&ht_idle_connections, ofs);
    if (list_empty(l)) {
        LOGGER_INFO("adding one more entry in the list");
        if (0 > create_entry(l))
            return -1;
    }
    if (0 > get_free_entry(info, l, mysql))
        return -1;
    return 0;
}
Exemple #7
0
int http_server_init(struct http_server *server) {
    /*
     * one time global initializers
     */
    if (0 > mime_types_init())
        return LOGGER_ERROR("failed to initialize mime types"), -1;
    if (0 > http_headers_init())
        return LOGGER_ERROR("failed to initialize http headers"), -1;
    /*
     * idle connection handler
     */
    server->idle_ctx = ribs_context_create(SMALL_STACK_SIZE, http_server_idle_handler);
    server->idle_ctx->data.ptr = server;
    /*
     * context pool
     */
    if (0 == server->stack_size || 0 == server->num_stacks) {
        struct rlimit rlim;
        if (0 > getrlimit(RLIMIT_STACK, &rlim))
            return LOGGER_PERROR("getrlimit(RLIMIT_STACK)"), -1;

        long total_mem = sysconf(_SC_PHYS_PAGES);
        if (total_mem < 0)
            return LOGGER_PERROR("sysconf"), -1;
        total_mem *= getpagesize();
        size_t num_ctx_in_one_map = total_mem / rlim.rlim_cur;
        /* half of total mem to start with so we don't need to enable overcommit */
        num_ctx_in_one_map >>= 1;
        LOGGER_INFO("http server pool: initial=%zu, grow=%zu", num_ctx_in_one_map, num_ctx_in_one_map);
        ctx_pool_init(&server->ctx_pool, num_ctx_in_one_map, num_ctx_in_one_map, rlim.rlim_cur, sizeof(struct http_server_context) + server->context_size);
    } else {
Exemple #8
0
void Rok4Server::initFCGI() {
    int init=FCGX_Init();
    if ( !socket.empty() ) {
        LOGGER_INFO ( _ ( "Listening on " ) << socket );
        sock = FCGX_OpenSocket ( socket.c_str(), backlog );
    }
}
Exemple #9
0
void SGTables::initialize()
{
    LOGGER_INFO("Initialising Portfolio Widgets");
    tableHeadersOrderBook <<
                             "Order Id"<<
                             "Mode"<<
                             "Instrument Name"<<
                             "Instrument Type"<<
                             "Quantity"<<
                             "Price"<<
                             "Status"<<
                             "Exch Order ID"<<
                             "Mkt-To-Limit"<<
                             "Orig Order Id"<<
                             "Disclosed Order Qty"<<
                             "Last Fill Qty"<<
                             "Last Fill Price"<<
                             "Total Fill qty"<<
                             "Pending Qty"<<
                             "Stop Price"<<
                             "Product Type"<<
                             "Series"<<
                             "Order Type"<<
                             "Validity"<<
                             "Is Triggered"<<
                             "Date/Time";
    int i =0;
    foreach (QString header, tableHeadersOrderBook) {
        hashOrderBookColumns.insert(header,i++);
    }
Exemple #10
0
    bool AccountManager::_initialize()
    {
		LOGGER_INFO( m_serviceProvider )("Initializing Account manager..."
			);
		
        return true;
    }
Exemple #11
0
	ResourceReferencePtr ResourceManager::generateResource( const ConstString& _type ) const
	{
		ResourceReferencePtr resource = PROTOTYPE_SERVICE( m_serviceProvider )
			->generatePrototypeT<ResourceReference *>( CONST_STRING( m_serviceProvider, Resource ), _type );

		if( resource == nullptr )
		{
			LOGGER_ERROR( m_serviceProvider )("ResourceManager::generateResource not registered resource type '%s'"
				, _type.c_str()
				);

			return nullptr;
		}

		LOGGER_INFO( m_serviceProvider )("ResourceManager::generateResource type %s"
			, _type.c_str()
			);

		if( resource->initialize() == false )
		{
			return nullptr;
		}

		return resource;
	}
Exemple #12
0
int daemonize(void) {
    if (0 > pipe(child_is_up_pipe))
        return LOGGER_ERROR("failed to create pipe"), -1;

    pid_t pid = fork();
    if (pid < 0) {
        LOGGER_PERROR("daemonize, fork");
        exit(EXIT_FAILURE);
    }

    if (pid > 0) {
        LOGGER_INFO("daemonize started (pid=%d)", pid);
        close(child_is_up_pipe[1]); /* close the write side */
        /* wait for child to come up */
        uint8_t t;
        int res;
        LOGGER_INFO("waiting for the child process to start...");
        if (0 >= (res = read(child_is_up_pipe[0], &t, sizeof(t)))) {
            if (0 > res)
                LOGGER_PERROR("pipe");
            LOGGER_ERROR("child process failed to start");
            exit(EXIT_FAILURE);
        }
        LOGGER_INFO("child process started successfully");
        exit(EXIT_SUCCESS);
    }

    close(child_is_up_pipe[0]); /* close the read side */

    umask(0);

    if (0 > setsid()) {
        LOGGER_PERROR("daemonize, setsid");
        exit(EXIT_FAILURE);
    }

    int fdnull = open("/dev/null", O_RDWR);
    dup2(fdnull, STDIN_FILENO);
    dup2(fdnull, STDOUT_FILENO);
    dup2(fdnull, STDERR_FILENO);
    close(fdnull);

    pid = getpid();

    LOGGER_INFO("child process started (pid=%d)", pid);
    return 0;
}
Exemple #13
0
int vc_reconfigure_encoder(VCSession *vc, uint32_t bit_rate, uint16_t width, uint16_t height, int16_t kf_max_dist)
{
    if (!vc) {
        return -1;
    }

    vpx_codec_enc_cfg_t cfg2 = *vc->encoder->config.enc;
    vpx_codec_err_t rc;

    if (cfg2.rc_target_bitrate == bit_rate && cfg2.g_w == width && cfg2.g_h == height && kf_max_dist == -1) {
        return 0; /* Nothing changed */
    }

    if (cfg2.g_w == width && cfg2.g_h == height && kf_max_dist == -1) {
        /* Only bit rate changed */
        LOGGER_INFO(vc->log, "bitrate change from: %u to: %u", (uint32_t)cfg2.rc_target_bitrate, (uint32_t)bit_rate);
        cfg2.rc_target_bitrate = bit_rate;
        rc = vpx_codec_enc_config_set(vc->encoder, &cfg2);

        if (rc != VPX_CODEC_OK) {
            LOGGER_ERROR(vc->log, "Failed to set encoder control setting: %s", vpx_codec_err_to_string(rc));
            return -1;
        }
    } else {
        /* Resolution is changed, must reinitialize encoder since libvpx v1.4 doesn't support
         * reconfiguring encoder to use resolutions greater than initially set.
         */
        LOGGER_DEBUG(vc->log, "Have to reinitialize vpx encoder on session %p", (void *)vc);
        vpx_codec_ctx_t new_c;
        vpx_codec_enc_cfg_t  cfg;
        vc_init_encoder_cfg(vc->log, &cfg, kf_max_dist);
        cfg.rc_target_bitrate = bit_rate;
        cfg.g_w = width;
        cfg.g_h = height;

        LOGGER_DEBUG(vc->log, "Using VP8 codec for encoder");
        rc = vpx_codec_enc_init(&new_c, video_codec_encoder_interface(), &cfg, VPX_CODEC_USE_FRAME_THREADING);

        if (rc != VPX_CODEC_OK) {
            LOGGER_ERROR(vc->log, "Failed to initialize encoder: %s", vpx_codec_err_to_string(rc));
            return -1;
        }

        int cpu_used_value = VP8E_SET_CPUUSED_VALUE;

        rc = vpx_codec_control(&new_c, VP8E_SET_CPUUSED, cpu_used_value);

        if (rc != VPX_CODEC_OK) {
            LOGGER_ERROR(vc->log, "Failed to set encoder control setting: %s", vpx_codec_err_to_string(rc));
            vpx_codec_destroy(&new_c);
            return -1;
        }

        vpx_codec_destroy(vc->encoder);
        memcpy(vc->encoder, &new_c, sizeof(new_c));
    }

    return 0;
}
Exemple #14
0
	void ConverterEngine::registerConverter( const ConstString & _type, ConverterFactoryInterface * _factory )
	{
        LOGGER_INFO(m_serviceProvider)("ConverterEngine::registerConverter add converter %s"
            , _type.c_str()
            );

		m_mapConverterSystem.insert( std::make_pair(_type, _factory) );
	}
Exemple #15
0
void handle_pop(MSICall *call, const MSIMessage *msg)
{
    assert(call);

    LOGGER_DEBUG(call->session->messenger->log, "Session: %p Handling 'pop', friend id: %d", call->session,
                 call->friend_number);

    /* callback errors are ignored */

    if (msg->error.exists) {
        LOGGER_WARNING(call->session->messenger->log, "Friend detected an error: %d", msg->error.value);
        call->error = msg->error.value;
        invoke_callback(call, msi_OnError);
    } else {
        switch (call->state) {
            case msi_CallInactive: {
                LOGGER_ERROR(call->session->messenger->log, "Handling what should be impossible case");
                abort();
            }

            case msi_CallActive: {
                /* Hangup */
                LOGGER_INFO(call->session->messenger->log, "Friend hung up on us");
                invoke_callback(call, msi_OnEnd);
            }
            break;

            case msi_CallRequesting: {
                /* Reject */
                LOGGER_INFO(call->session->messenger->log, "Friend rejected our call");
                invoke_callback(call, msi_OnEnd);
            }
            break;

            case msi_CallRequested: {
                /* Cancel */
                LOGGER_INFO(call->session->messenger->log, "Friend canceled call invite");
                invoke_callback(call, msi_OnEnd);
            }
            break;
        }
    }

    kill_call(call);
}
bool SFB::Audio::Decoder::SupportsSeeking() const
{
	if(!IsOpen()) {
		LOGGER_INFO("org.sbooth.AudioEngine.Decoder", "SupportsSeeking() called on a Decoder that hasn't been opened");
		return false;
	}

	return _SupportsSeeking();
}
SInt64 SFB::Audio::Decoder::GetCurrentFrame() const
{
	if(!IsOpen()) {
		LOGGER_INFO("org.sbooth.AudioEngine.Decoder", "GetCurrentFrame() called on a Decoder that hasn't been opened");
		return -1;
	}

	return _GetCurrentFrame();
}
CFStringRef SFB::Audio::Decoder::CreateSourceFormatDescription() const
{
	if(!IsOpen()) {
		LOGGER_INFO("org.sbooth.AudioEngine.Decoder", "CreateSourceFormatDescription() called on a Decoder that hasn't been opened");
		return nullptr;
	}

	return _GetSourceFormatDescription().Relinquish();
}
  void TestAddEphemeralNodeEventHandlerWhenNodeDeleted::Execute()
  {
    bool result = false;

    std::string path = "/zookeeper/doughnuts";
    std::string data = "glazed, chocolate, powdered";

    try
    {
      bool r1 = m_zooKeeper->CreateNode( path, data, ZooKeeper::ZooKeeperNodeType::EPHEMERAL );
      if( r1 )
      {
        m_zooKeeper->AddNodeEventHandler( path, this );
        LOGGER_INFO( m_logger, boost::str( boost::format( "Node <%s> event handler created" ) % path ) );

        m_zooKeeper->DeleteNode( path );

        Lock lock( m_mutex );
        if( m_condition.wait_for( lock, std::chrono::seconds( 5 ) ) == std::cv_status::timeout )
        {
          LOGGER_ERROR( m_logger, boost::str( boost::format( "Node <%s> event handler timeout" ) % path ) );
        }
        else
        {
          m_zooKeeper->RemoveNodeEventHandler( path );

          result = true;
        }
      }
    }
    catch( const std::exception& ex )
    {
      LOGGER_ERROR( m_logger, ex.what() );
    }

    if( result )
    {
      LOGGER_INFO( m_logger, "Test PASSED" );
    }
    else
    {
      LOGGER_ERROR( m_logger, "Test FAILED" );
    }
  }
int _c00_receive_http_path(struct c00_consumer_command *tmp_cmd, struct http_path_request *pth_req){
	FILE *fp;
	fp = fdopen(dup(tmp_cmd->peer_socket),"r");
	char header_line[max_http_path_line_len];
	if(fp){
		
		c00_increment_count(tmp_cmd);

		char buffer[INET_ADDRSTRLEN];
		const char* result=inet_ntop(AF_INET,&(tmp_cmd->client.sin_addr),buffer,sizeof(buffer));
		char log_all[STD_LOG_LEN];
		snprintf(log_all,STD_LOG_LEN,"rcv from %s count %llu:\n",result,tmp_cmd->serverConfig->count->count);
		/**read the first line**/
		fgets(header_line,max_http_path_line_len,fp);
		
		strlcat(log_all,header_line,sizeof(log_all));

		int count_all = 0;

		if(sscanf(header_line,"%s %s HTTP/%d.%d%*s",pth_req->http_method,pth_req->http_path,&pth_req->major_version,&pth_req->minor_version)!=4){

			C00DEBUG("line %s error",header_line); 
			fclose(fp);
			strlcpy(pth_req->http_method,"GET",3);
			strlcpy(pth_req->http_path,"/500.html",9);
			pth_req->major_version = 1;
			pth_req->minor_version = 1;
			pth_req->http_response = C00_HTTP_SERVER_ERROR;
			
			return FALSE;
		}

		while(count_all < _c00_http_path_header_max_len){
       			fgets(header_line,_c00_http_path_header_max_line_len,fp);
			if(strstr(header_line,":")){
				strlcat(log_all,header_line,sizeof(log_all));
				count_all ++;
			}
			else{
				break;
			}
		}

		//fprintf(fp,"HTTP/1.1 200 OK\r\n");
		LOGGER_INFO(tmp_cmd->serverConfig->logger,"%s",log_all);
		fclose(fp);
	}
	else{
		syslog(LOG_ERR,"I can not close fr in http_path");
		return FALSE;
	}

	return TRUE;
}
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
	ui(new Ui::MainWindow)
{
	mLogger = LoggerFactory::getInstance()->getLogger("MainWindow");

	LOGGER_INFO( mLogger, "Inicializando Aplicaci'on" );

    ui->setupUi(this);

	inicializar();
}
Exemple #22
0
    void ImportHelper::reportProgress (const int64_t totalLength,
                                       const int64_t totalRead,
                                       double& nextProgress) {
      if (! _progress || totalLength == 0) {
        return;
      }

      double pct = 100.0 * ((double) totalRead / (double) totalLength);
      if (pct >= nextProgress) {
        LOGGER_INFO("processed " << totalRead << " bytes (" << std::fixed << std::setprecision(2) << pct << " %) of input file");
        nextProgress = pct + ProgressStep;
      }
    }
UInt32 SFB::Audio::Decoder::ReadAudio(AudioBufferList *bufferList, UInt32 frameCount)
{
	if(!IsOpen()) {
		LOGGER_INFO("org.sbooth.AudioEngine.Decoder", "ReadAudio() called on a Decoder that hasn't been opened");
		return 0;
	}

	if(nullptr == bufferList || 0 == frameCount) {
		LOGGER_WARNING("org.sbooth.AudioEngine.Decoder", "ReadAudio() called with invalid parameters");
		return 0;
	}

	return _ReadAudio(bufferList, frameCount);
}
Exemple #24
0
static void signal_handler(int signum) {
    switch(signum) {
    case SIGINT:
        if (0 != daemon_instance) {
            LOGGER_INFO("ignoring SIGINT in child process");
            break;
        }
    case SIGTERM:
        epoll_worker_exit();
        break;
    default:
        LOGGER_ERROR("unknown signal");
    }
}
Exemple #25
0
bool MarmaladeAmplifier::_initialize()
{
    LOGGER_INFO(m_serviceProvider)( "Starting Marmalade Amplifier..." );

    int32 available = s3eAudioGetInt( S3E_AUDIO_AVAILABLE );

    if( available == 0 )
    {
        LOGGER_ERROR(m_serviceProvider)("Unavailable..."
                                       );

        return false;
    }

    s3eResult result = s3eAudioRegister( S3E_AUDIO_STOP, (s3eCallback)&s_Amplifier_AudioCallback_Stop, this );

    if( result != S3E_RESULT_SUCCESS )
    {
        s3eAudioError s3eAudio_error = s3eAudioGetError();
        const char * s3eAudio_string = s3eAudioGetErrorString();

        LOGGER_ERROR(m_serviceProvider)("Amplifier::initialize: invalid register callback %d [%s]"
                                        , s3eAudio_error
                                        , s3eAudio_string
                                       );

        return false;
    }

    SOUND_SERVICE(m_serviceProvider)
    ->addSoundVolumeProvider( this );

#	define MARMALADE_AMPLIFIER_SUPPORT_CODEC( Codec )\
	LOGGER_WARNING(m_serviceProvider)("Amplifier::initialize: " #Codec " %s"\
		, s3eAudioIsCodecSupported( Codec ) ? "support" : "unsupport!" )

    MARMALADE_AMPLIFIER_SUPPORT_CODEC( S3E_AUDIO_CODEC_MIDI );
    MARMALADE_AMPLIFIER_SUPPORT_CODEC( S3E_AUDIO_CODEC_MP3 );
    MARMALADE_AMPLIFIER_SUPPORT_CODEC( S3E_AUDIO_CODEC_AAC );
    MARMALADE_AMPLIFIER_SUPPORT_CODEC( S3E_AUDIO_CODEC_AACPLUS );
    MARMALADE_AMPLIFIER_SUPPORT_CODEC( S3E_AUDIO_CODEC_QCP );
    MARMALADE_AMPLIFIER_SUPPORT_CODEC( S3E_AUDIO_CODEC_PCM );
    MARMALADE_AMPLIFIER_SUPPORT_CODEC( S3E_AUDIO_CODEC_SPF );
    MARMALADE_AMPLIFIER_SUPPORT_CODEC( S3E_AUDIO_CODEC_AMR );
    MARMALADE_AMPLIFIER_SUPPORT_CODEC( S3E_AUDIO_CODEC_MP4 );

#	undef AMPLIFIER_SUPPORT_CODEC

    return true;
}
SInt64 SFB::Audio::Decoder::SeekToFrame(SInt64 frame)
{
	if(!IsOpen()) {
		LOGGER_INFO("org.sbooth.AudioEngine.Decoder", "SeekToFrame() called on a Decoder that hasn't been opened");
		return -1;
	}

	if(0 > frame || frame >= GetTotalFrames()) {
		LOGGER_WARNING("org.sbooth.AudioEngine.Decoder", "SeekToFrame() called with invalid parameters");
		return -1;
	}

	return _SeekToFrame(frame);
}
Exemple #27
0
sint32 WorkerThreadPool::init(sint32 number, timeval &tv)
{
    ret_val_if_fail(number > 0, -1);

    for (sint32 i = 0; i < number; ++i)
    {
        WorkerThread* wt = new WorkerThread(this, i, tv);
        if (-1 == wt->init())
        {
            LOGGER_ERROR(g_framework_logger, "init worker thread failed");
            return -1;
        }
        m_worker_threads.push_back(wt);
    }

    for (sint32 i = 0; i < number; ++i)
    {
        if (-1 == m_worker_threads[i]->start_thread())
        {
            LOGGER_ERROR(g_framework_logger, "start worker thread failed");
            return -1;
        }
    }

    // wait the worker_thread all start work
    pthread_mutex_lock(&m_init_lock);
    while (m_num_active_thread < number)
    {
        pthread_cond_wait(&m_init_cond, &m_init_lock);
    }
    pthread_mutex_unlock(&m_init_lock);

    for (sint32 i = 0; i < number; i++)
    {
        pthread_t id = m_worker_threads[i]->get_thread_id();
        m_thread_ids.push_back(id);
        std::pair<map<pthread_t, sint32>::iterator, bool> res = m_threadid_index_map.insert(std::make_pair<pthread_t, sint32>(id, i));
        if (false == res.second)
        {
            LOGGER_ERROR(g_framework_logger, "insert <threadid, index> fail!");
            return -1;
        }
    }

    LOGGER_INFO(g_framework_logger, "need worker thread number=" << number
            << ", active thread number=" << m_num_active_thread);

    return 0;
}
bool SFB::Audio::Decoder::Open(CFErrorRef *error)
{
	if(IsOpen()) {
		LOGGER_INFO("org.sbooth.AudioEngine.Decoder", "Open() called on a Decoder that is already open");
		return true;
	}

	// Ensure the input source is open
	if(!GetInputSource().IsOpen() && !GetInputSource().Open(error))
		return false;

	bool result = _Open(error);
	if(result)
		mIsOpen = true;
	return result;
}
Exemple #29
0
int queue_current_ctx(void) {
    while (0 > write(queue_ctx_fd, &current_ctx, sizeof(void *))) {
        if (EAGAIN != errno)
            return LOGGER_PERROR("unable to queue context: write"), -1;
        /* pipe is full!!! wait for it to clear
           This is switching to LIFO mode, which can cause IO starvation
           if too many contexes are trying to use this facility, very unlikely
        */
        LOGGER_INFO("Warning: context queue is full");
        struct ribs_context *previous_context = epoll_worker_fd_map[queue_ctx_fd].ctx;
        epoll_worker_fd_map[queue_ctx_fd].ctx = current_ctx;
        yield(); // come back to me when can write
        epoll_worker_fd_map[queue_ctx_fd].ctx = previous_context;
    }
    return 0;
}
Exemple #30
0
	bool ConverterEngine::unregisterConverter( const ConstString& _type )
	{
        LOGGER_INFO(m_serviceProvider)("ConverterEngine::unregisterConverter remove converter %s"
            , _type.c_str()
            );

		TMapConverterSystem::iterator it_found = m_mapConverterSystem.find( _type );

		if( it_found == m_mapConverterSystem.end() )
		{
			return false;
		}

		m_mapConverterSystem.erase( it_found );

		return true;
	}