コード例 #1
0
ファイル: rtstutter.c プロジェクト: Distrotech/pulseaudio
int main(int argc, char*argv[]) {
    unsigned n;

    pa_log_set_level(PA_LOG_INFO);

    srand((unsigned) time(NULL));

    if (argc >= 3) {
        msec_lower = atoi(argv[1]);
        msec_upper = atoi(argv[2]);
    } else if (argc >= 2) {
        msec_lower = 0;
        msec_upper = atoi(argv[1]);
    } else {
        msec_lower = 0;
        msec_upper = 1000;
    }

    pa_assert(msec_upper > 0);
    pa_assert(msec_upper >= msec_lower);

    pa_log_notice("Creating random latencies in the range of %ims to %ims.", msec_lower, msec_upper);

    for (n = 1; n < pa_ncpus(); n++) {
        pa_assert_se(pa_thread_new("rtstutter", work, PA_UINT_TO_PTR(n)));
    }

    work(PA_INT_TO_PTR(0));

    return 0;
}
コード例 #2
0
ファイル: reserve-wrap.c プロジェクト: KimT/pulseaudio_kt
static int request_cb(rd_device *d, int forced) {
    pa_reserve_wrapper *r;
    int k;

    pa_assert(d);
    pa_assert_se(r = rd_get_userdata(d));
    pa_assert(PA_REFCNT_VALUE(r) >= 1);

    PA_REFCNT_INC(r);

    k = pa_hook_fire(&r->hook, PA_INT_TO_PTR(forced));
    pa_log_debug("Device unlock of %s has been requested and %s.", r->shared_name, k < 0 ? "failed" : "succeeded");

    pa_reserve_wrapper_unref(r);

    return k < 0 ? -1 : 1;
}
コード例 #3
0
ファイル: reserve-wrap.c プロジェクト: KimT/pulseaudio_kt
static void change_cb(rm_monitor *m) {
    pa_reserve_monitor_wrapper *w;
    int k;

    pa_assert(m);
    pa_assert_se(w = rm_get_userdata(m));
    pa_assert(PA_REFCNT_VALUE(w) >= 1);

    PA_REFCNT_INC(w);

    if ((k = rm_busy(w->monitor)) < 0)
        return;

    pa_hook_fire(&w->hook, PA_INT_TO_PTR(!!k));
    pa_log_debug("Device lock status of %s changed: %s", w->shared_name, k ? "busy" : "not busy");

    pa_reserve_monitor_wrapper_unref(w);
}
コード例 #4
0
static void apply_cork(struct userdata *u, pa_sink *s, pa_sink_input *ignore, pa_bool_t cork) {
    pa_sink_input *j;
    uint32_t idx;

    pa_assert(u);
    pa_sink_assert_ref(s);

    for (j = PA_SINK_INPUT(pa_idxset_first(s->inputs, &idx)); j; j = PA_SINK_INPUT(pa_idxset_next(s->inputs, &idx))) {
        pa_bool_t corked;
        const char *role;

        if (j == ignore)
            continue;

        if (!(role = pa_proplist_gets(j->proplist, PA_PROP_MEDIA_ROLE)))
            continue;

        if (!pa_streq(role, "video") &&
            !pa_streq(role, "music"))
            continue;

        corked = !!pa_hashmap_get(u->cork_state, j);

        if (cork && !corked) {
            pa_hashmap_put(u->cork_state, j, PA_INT_TO_PTR(1));
            pa_sink_input_set_mute(j, TRUE, FALSE);
            pa_sink_input_send_event(j, PA_STREAM_EVENT_REQUEST_CORK, NULL);
        } else if (!cork) {
            pa_hashmap_remove(u->cork_state, j);

            if (corked) {
                pa_sink_input_set_mute(j, FALSE, FALSE);
                pa_sink_input_send_event(j, PA_STREAM_EVENT_REQUEST_UNCORK, NULL);
            }
        }
    }
}