Beispiel #1
0
static void next_state(void)
{
    s_current_state++;
    if (s_current_state == s_state_count)
    {
        if (s_repetitions > 0)
        {
            s_repetitions--;
        }

        // we've reached the end of the sequence, repeat
        if (s_repetitions == 0)
        {
            // no more repetitions, stop
            bsp_buzzer_stop();
            return;
        }
            
        // go back to the first state
        s_current_state = 0;
    }
    
    const bsp_buzzer_state_t* state = &s_states[s_current_state];
    if (state->freq > 0)
    {
        enable_output(s_buzzer,state->freq);
    }
    else
    {
        disable_output(s_buzzer);
    }
    set_timeout(state->ms);        
}
Beispiel #2
0
static int init(struct sd *sd)
{
    struct MPOpts *opts = sd->opts;
    struct sd_ass_priv *ctx = talloc_zero(sd, struct sd_ass_priv);
    sd->priv = ctx;

    char *extradata = sd->codec->extradata;
    int extradata_size = sd->codec->extradata_size;

    if (strcmp(sd->codec->codec, "ass") != 0) {
        ctx->is_converted = true;
        ctx->converter = lavc_conv_create(sd->log, sd->codec->codec, extradata,
                                          extradata_size);
        if (!ctx->converter)
            return -1;
        extradata = lavc_conv_get_extradata(ctx->converter);
        extradata_size = extradata ? strlen(extradata) : 0;

        if (strcmp(sd->codec->codec, "eia_608") == 0)
            ctx->duration_unknown = 1;
    }

    ctx->ass_library = mp_ass_init(sd->global, sd->log);

    add_subtitle_fonts(sd);

    if (opts->ass_style_override)
        ass_set_style_overrides(ctx->ass_library, opts->ass_force_style_list);

    ctx->ass_track = ass_new_track(ctx->ass_library);
    if (!ctx->is_converted)
        ctx->ass_track->track_type = TRACK_TYPE_ASS;

    ctx->shadow_track = ass_new_track(ctx->ass_library);
    ctx->shadow_track->PlayResX = 384;
    ctx->shadow_track->PlayResY = 288;
    mp_ass_add_default_styles(ctx->shadow_track, opts);

    if (extradata)
        ass_process_codec_private(ctx->ass_track, extradata, extradata_size);

    mp_ass_add_default_styles(ctx->ass_track, opts);

#if LIBASS_VERSION >= 0x01302000
    ass_set_check_readorder(ctx->ass_track, sd->opts->sub_clear_on_seek ? 0 : 1);
#endif

    ctx->frame_fps = sd->codec->frame_based;
    update_subtitle_speed(sd);

    enable_output(sd, true);

    ctx->packer = mp_ass_packer_alloc(ctx);

    return 0;
}
Beispiel #3
0
static void uninit(struct sd *sd)
{
    struct sd_ass_priv *ctx = sd->priv;

    if (ctx->converter)
        lavc_conv_uninit(ctx->converter);
    ass_free_track(ctx->ass_track);
    ass_free_track(ctx->shadow_track);
    enable_output(sd, false);
    ass_library_done(ctx->ass_library);
}