Exemplo n.º 1
0
long Cx_StringTable::LoadFiles(const std::wstring& path)
{
	long count = 0;
	std::vector<std::wstring> files;
	CScanFilesByExtension scaner(&files, L".xml");

	ScanFiles(&scaner, path.c_str(), false);
	m_loaded = true;

	std::vector<std::wstring>::const_iterator it = files.begin();
	for (; it != files.end(); ++it)
	{
		if (RegisterFile(*it) > 0)
		{
			count++;
		}
	}
	
	if (0 == count)
	{
		LOG_INFO2(LOGHEAD L"IDS_NO_STRFILE", path);
	}

	return count;
}
Exemplo n.º 2
0
void Screen::notificate(std::string message, bool sendMail)
{
    boost::mutex::scoped_lock lockClass(m_screenMutex);

    LOG_INFO2("NOTIFICATION: " << message);

    if(sendMail) {
        system(boost::str(
                boost::format(ConfigManager::instance()->getString(ConfigManager::NOTIFICATION_COMMAND))
                % ConfigManager::instance()->getString(ConfigManager::NOTIFICATION_SUBJECT)
                % message
                ).c_str());
    }

    m_notifications.push_front(boost::str(boost::format("%1% %2%") % getCurrentTimeString() % message));
    while(m_notifications.size() > 6) {
        m_notifications.pop_back();
    }

    queueClear();
}
Exemplo n.º 3
0
void *metadata_thread_signal(void *arg)
{
    char buf[1024];
    input_module_t *mod = arg;

    while(1)
    {
        char **md = NULL;
        int comments = 0;
        FILE *file;

        while(metadata_update_signalled == 0)
        {
            thread_cond_wait(&ices_config->event_pending_cond);
            if (ices_config->shutdown)
            {
                LOG_INFO0 ("metadata thread shutting down");
                return NULL;
            }
            LOG_DEBUG0("meta thread wakeup");
        }

        metadata_update_signalled = 0;

        file = fopen(ices_config->metadata_filename, "r");
        if(!file) {
            LOG_WARN2("Failed to open file \"%s\" for metadata update: %s", 
                    ices_config->metadata_filename, strerror(errno));
            continue;
        }

        LOG_DEBUG1("reading metadata from \"%s\"", ices_config->metadata_filename);
        while(fgets(buf, 1024, file))
        {
            if(buf[0] == '\n')
                break;
            else
            {
                if(buf[strlen(buf)-1] == '\n')
                    buf[strlen(buf)-1] = 0;
                md = realloc(md, (comments+2)*sizeof(char *));
                md[comments] = malloc(strlen(buf)+1);

                memcpy(md[comments], buf, strlen(buf)+1);
                comments++;
                LOG_INFO2 ("tag %d is %s", comments, buf);
            }
        }

        fclose(file);

        if(md) /* Don't update if there's nothing there */
        {
            md[comments]=0;

            /* Now, let's actually use the new data */
            LOG_INFO0("Updating metadata");
            mod->handle_event(mod,EVENT_METADATAUPDATE,md);
        }
        else
            LOG_INFO0("No metadata has been read");

    }
}
Exemplo n.º 4
0
input_module_t *sndio_open_module(module_param_t *params)
{
    input_module_t *mod = calloc(1, sizeof(input_module_t));
    im_sndio_state *s;
    module_param_t *current;
    char *device = NULL; /* default device */
    int sample_rate = 44100;
    int channels = 2;
    int use_metadata = 1; /* Default to on */

    mod->type = ICES_INPUT_PCM;
#ifdef WORDS_BIGENDIAN
    mod->subtype = INPUT_PCM_BE_16;
#else
    mod->subtype = INPUT_PCM_LE_16;
#endif
    mod->getdata = sndio_read;
    mod->handle_event = event_handler;
    mod->metadata_update = metadata_update;

    mod->internal = calloc(1, sizeof(im_sndio_state));
    s = mod->internal;

    thread_mutex_create(&s->metadatalock);

    current = params;

    while (current) {
        if (!strcmp(current->name, "rate"))
            sample_rate = atoi(current->value);
        else if (!strcmp(current->name, "channels"))
            channels = atoi(current->value);
        else if (!strcmp(current->name, "device"))
            device = current->value;
        else if (!strcmp(current->name, "metadata"))
            use_metadata = atoi(current->value);
        else if(!strcmp(current->name, "metadatafilename"))
            ices_config->metadata_filename = current->value;
        else
            LOG_WARN1("Unknown parameter %s for sndio module", current->name);
        current = current->next;
    }

    /* First up, lets open the audio device */
    if((s->hdl = sio_open(device, SIO_REC, 0)) == NULL) {
        LOG_ERROR0("Failed to open sndio device");
        goto fail;
    }

    /* Try and set up what we want */
    sio_initpar(&s->par);
    s->par.rate = sample_rate;
    s->par.rchan = channels; 
    s->par.bits = 16;
    s->par.sig = 1;
    s->par.le = SIO_LE_NATIVE;
    s->par.round = BUFSIZE;
    s->par.appbufsz = BUFSIZE * 4;

    if (!sio_setpar(s->hdl, &s->par) || !sio_getpar(s->hdl, &s->par)) {
        LOG_ERROR0("Failed to configure sndio device");
        goto fail;
    }

    /* Check all went according to plan */
    if (s->par.rate != sample_rate) {
        LOG_ERROR0("Couldn't set sampling rate");
        goto fail;
    }
    if (s->par.rchan != channels) {
        LOG_ERROR0("Couldn't set number of channels");
        goto fail;
    }
    if (s->par.bits != 16) {
        LOG_ERROR0("Couldn't set 16 bit precision");
        goto fail;
    }
    if (s->par.sig != 1) {
        LOG_ERROR0("Couldn't set signed linear encoding");
        goto fail;
    }
    if (s->par.le != SIO_LE_NATIVE) {
        LOG_ERROR0("Couldn't set proper endianness");
        goto fail;
    }

    if (!sio_start(s->hdl)) {
        LOG_ERROR0("Couldn't start sndio");
        goto fail;
    }

    /* We're done, and we didn't fail! */
    LOG_INFO2("Opened audio device for %d channel(s), %d Hz", 
            channels, sample_rate);

    if(use_metadata)
    {
        LOG_INFO0("Starting metadata update thread");
        if(ices_config->metadata_filename)
            thread_create("im_sndio-metadata", metadata_thread_signal, mod, 1);
        else
            thread_create("im_sndio-metadata", metadata_thread_stdin, mod, 1);
    }

    return mod;

fail:
    close_module(mod); /* safe, this checks for valid contents */
    return NULL;
}