Ejemplo n.º 1
0
/* Handle Q_CODEC_LOAD */
static void load_codec(const struct codec_load_info *ev_data)
{
    int status = CODEC_ERROR;
    /* Save a local copy so we can let the audio thread go ASAP */
    struct codec_load_info data = *ev_data;
    bool const encoder = type_is_encoder(data.afmt);

    if (codec_type != AFMT_UNKNOWN)
    {
        /* Must have unloaded it first */
        logf("a codec is already loaded");
        if (data.hid >= 0)
            bufclose(data.hid);
        return;
    }

    trigger_cpu_boost();

    if (!encoder)
    {
        /* Do this now because codec may set some things up at load time */
        dsp_configure(ci.dsp, DSP_RESET, 0);
    }

    if (data.hid >= 0)
    {
        /* First try buffer load */
        status = codec_load_buf(data.hid, &ci);
        bufclose(data.hid);
    }

    if (status < 0)
    {
        /* Either not a valid handle or the buffer method failed */
        const char *codec_fn = get_codec_filename(data.afmt);
        if (codec_fn)
        {
#ifdef HAVE_IO_PRIORITY
            buf_back_off_storage(true);
#endif
            status = codec_load_file(codec_fn, &ci);
#ifdef HAVE_IO_PRIORITY
            buf_back_off_storage(false);
#endif
        }
    }

    if (status >= 0)
    {
        codec_type = data.afmt;
        codec_queue_ack(Q_CODEC_LOAD);
        return;
    }

    /* Failed - get rid of it */
    unload_codec();
}
Ejemplo n.º 2
0
Archivo: file.c Proyecto: aahud/harvey
void
fileclose(File *f)
{
	Strclose(&f->name);
	bufclose(&f->Buffer);
	bufclose(&f->delta);
	bufclose(&f->epsilon);
	if(f->rasp)
		listfree(f->rasp);
	free(f);
}
Ejemplo n.º 3
0
void
fileclose(File *f)
{
	free(f->name);
	f->nname = 0;
	f->name = nil;
	free(f->text);
	f->ntext = 0;
	f->text = nil;
	bufclose(&f->b);
	bufclose(&f->delta);
	bufclose(&f->epsilon);
	elogclose(f);
	free(f);
}
Ejemplo n.º 4
0
static int load_radioart_image(struct radioart *ra, const char* preset_name, 
                               struct dim *dim)
{
    char path[MAX_PATH];
#ifndef HAVE_NOISY_IDLE_MODE
    cpu_idle_mode(false);
#endif
    snprintf(path, sizeof(path), FMPRESET_PATH "/%s.bmp",preset_name);
    if (!file_exists(path))
        snprintf(path, sizeof(path), FMPRESET_PATH "/%s.jpg",preset_name);
    if (!file_exists(path))
    {
#ifndef HAVE_NOISY_IDLE_MODE
		cpu_idle_mode(true);
#endif
        return -1;
	}
    strlcpy(ra->name, preset_name, MAX_FMPRESET_LEN+1);
    ra->dim.height = dim->height;
    ra->dim.width = dim->width;
    ra->last_tick = current_tick;
    ra->handle = bufopen(path, 0, TYPE_BITMAP, &ra->dim);
    if (ra->handle == ERR_BUFFER_FULL)
    {
        int i = find_oldest_image();
        bufclose(i);
        ra->handle = bufopen(path, 0, TYPE_BITMAP, &ra->dim);
    }
#ifndef HAVE_NOISY_IDLE_MODE
    cpu_idle_mode(true);
#endif
    return ra->handle;    
}
Ejemplo n.º 5
0
static void codec_discard_codec_callback(void)
{
    int *codec_hid = get_codec_hid();
    if (*codec_hid >= 0)
    {
        bufclose(*codec_hid);
        *codec_hid = -1;
    }
}
Ejemplo n.º 6
0
static void playback_restarting_handler(void *data)
{
    (void)data;
    int i;
    for(i=0;i<MAX_RADIOART_IMAGES;i++)
    {
        if (radioart[i].handle >= 0)
            bufclose(radioart[i].handle);
        radioart[i].handle = -1;
        radioart[i].name[0] = '\0';
    }
}
Ejemplo n.º 7
0
static void buffer_reset_handler(void *data)
{
    buf = NULL;
    for(int i=0;i<MAX_RADIOART_IMAGES;i++)
    {
        if (radioart[i].handle >= 0)
            bufclose(radioart[i].handle);
        radioart[i].handle = -1;
        radioart[i].name[0] = '\0';
    }

    (void)data;
}
Ejemplo n.º 8
0
/* called while row is locked */
void
flushwarnings(void)
{
	Warning *warn, *next;
	Window *w;
	Text *t;
	int owner, nr, q0, n;
	Rune *r;

	for(warn=warnings; warn; warn=next) {
		w = errorwin(warn->md, 'E');
		t = &w->body;
		owner = w->owner;
		if(owner == 0)
			w->owner = 'E';
		wincommit(w, t);
		/*
		 * Most commands don't generate much output. For instance,
		 * Edit ,>cat goes through /dev/cons and is already in blocks
		 * because of the i/o system, but a few can.  Edit ,p will
		 * put the entire result into a single hunk.  So it's worth doing
		 * this in blocks (and putting the text in a buffer in the first
		 * place), to avoid a big memory footprint.
		 */
		r = fbufalloc();
		q0 = t->file->nc;
		for(n = 0; n < warn->buf.nc; n += nr){
			nr = warn->buf.nc - n;
			if(nr > RBUFSIZE)
				nr = RBUFSIZE;
			bufread(&warn->buf, n, r, nr);
			textbsinsert(t, t->file->nc, r, nr, TRUE, &nr);
		}
		textshow(t, q0, t->file->nc, 1);
		free(r);
		winsettag(t->w);
		textscrdraw(t);
		w->owner = owner;
		w->dirty = FALSE;
		winunlock(w);
		bufclose(&warn->buf);
		next = warn->next;
		if(warn->md)
			fsysdelid(warn->md);
		free(warn);
	}
	warnings = nil;
}
Ejemplo n.º 9
0
int radio_get_art_hid(struct dim *requested_dim)
{
    int preset = radio_current_preset();
    int free_idx = -1;
    const char* preset_name;

    if (!buf || radio_scan_mode() || preset < 0)
        return -1;

    preset_name = radio_get_preset_name(preset);
    for (int i=0; i<MAX_RADIOART_IMAGES; i++)
    {
        if (radioart[i].handle < 0)
        {
            free_idx = i;
        }
        else if (!strcmp(radioart[i].name, preset_name) &&
                 radioart[i].dim.width == requested_dim->width &&
                 radioart[i].dim.height == requested_dim->height)
        {
            radioart[i].last_tick = current_tick;
            return radioart[i].handle;
        }
    }
    if (free_idx >= 0)
    {
        return load_radioart_image(&radioart[free_idx], 
                                   preset_name, requested_dim);
    }
    else
    {
        int i = find_oldest_image_index();
        if (i != -1)
        {
            bufclose(radioart[i].handle);
            return load_radioart_image(&radioart[i],
                                       preset_name, requested_dim);
        }
    }
        
    return -1;
}
Ejemplo n.º 10
0
int radio_get_art_hid(struct dim *requested_dim)
{
    int preset = radio_current_preset();
    int i, free_idx = -1;
    const char* preset_name;
    if (radio_scan_mode() || preset < 0)
        return -1;
#ifdef HAVE_RECORDING
    if (!allow_buffer_access)
        return -1;
#endif
    preset_name = radio_get_preset_name(preset);
    for(i=0;i<MAX_RADIOART_IMAGES;i++)
    {
        if (radioart[i].handle < 0)
        {
            free_idx = i;
        }
        else if (!strcmp(radioart[i].name, preset_name) &&
                 radioart[i].dim.width == requested_dim->width &&
                 radioart[i].dim.height == requested_dim->height)
        {
            radioart[i].last_tick = current_tick;
            return radioart[i].handle;
        }
    }
    if (free_idx >= 0)
    {
        return load_radioart_image(&radioart[free_idx], 
                                   preset_name, requested_dim);
    }
    else
    {
        int i = find_oldest_image();
        bufclose(radioart[i].handle);
        return load_radioart_image(&radioart[i],
                                   preset_name, requested_dim);        
    }
        
    return -1;
}
Ejemplo n.º 11
0
static int load_radioart_image(struct radioart *ra, const char* preset_name, 
                               struct dim *dim)
{
    char path[MAX_PATH];
    struct bufopen_bitmap_data user_data;
#ifndef HAVE_NOISY_IDLE_MODE
    cpu_idle_mode(false);
#endif
    snprintf(path, sizeof(path), FMPRESET_PATH "/%s.bmp",preset_name);
    if (!file_exists(path))
        snprintf(path, sizeof(path), FMPRESET_PATH "/%s.jpg",preset_name);
    if (!file_exists(path))
    {
#ifndef HAVE_NOISY_IDLE_MODE
        cpu_idle_mode(true);
#endif
        return -1;
    }
    strlcpy(ra->name, preset_name, MAX_FMPRESET_LEN+1);
    ra->dim.height = dim->height;
    ra->dim.width = dim->width;
    ra->last_tick = current_tick;
    user_data.embedded_albumart = NULL;
    user_data.dim = &ra->dim;
    ra->handle = bufopen(path, 0, TYPE_BITMAP, &user_data);
    if (ra->handle == ERR_BUFFER_FULL)
    {
        int i = find_oldest_image_index();
        if (i != -1)
        {
            bufclose(radioart[i].handle);
            ra->handle = bufopen(path, 0, TYPE_BITMAP, &user_data);
        }
    }
#ifndef HAVE_NOISY_IDLE_MODE
    cpu_idle_mode(true);
#endif
    return ra->handle;    
}