int main( void )
{
	avr_init();
	pulse_init();

	puts( "$Id: tach.c,v 2.0 2002/09/22 02:10:18 tramm Exp $" );
	putnl();

	while( 1 )
	{
		puthex( high_bits );
		puthex( time() );
		putc( ':' );

		puthexs( pulse_0 );
		putc( ' ' );
		puthexs( pulse_1 );
		putnl();

		pulse_1 = pulse_0 = 0;

		msleep( 8192 );
	}

	return 0;
}
static void show( void *parent )
{
	GPIO_InitTypeDef	GPIO_InitStructure;
	uint8_t				i;
	char				buf[64];

	scr_1_idle.parent = (PSCR)parent;

	pulse_init( );
	//ad_init( );

	for( i = 0; i < sizeof( PIN_OUT ) / sizeof( AUX_IO ); i++ )
	{
		GPIO_InitStructure.GPIO_Pin		= PIN_OUT[i].pin;
		GPIO_InitStructure.GPIO_Mode	= GPIO_Mode_OUT;
		GPIO_InitStructure.GPIO_OType	= GPIO_OType_PP;
		GPIO_InitStructure.GPIO_Speed	= GPIO_Speed_100MHz;
		GPIO_InitStructure.GPIO_PuPd	= GPIO_PuPd_NOPULL;
		GPIO_Init( PIN_OUT[i].port, &GPIO_InitStructure );
	}

	GPIO_InitStructure.GPIO_Mode	= GPIO_Mode_IN;
	GPIO_InitStructure.GPIO_PuPd	= GPIO_PuPd_NOPULL;

	for( i = 0; i < sizeof( PIN_IN ) / sizeof( AUX_IO ); i++ )
	{
		GPIO_InitStructure.GPIO_Pin = PIN_IN[i].pin;
		GPIO_Init( PIN_IN[i].port, &GPIO_InitStructure );
	}
/*PA0 速度信号*/

	showinfo();

}
Exemple #3
0
/**
 * Get plugin defaults
 */
static void pulse_defaults(obs_data_t *settings, bool input)
{
	pulse_init();

	pa_server_info_cb_t cb = (input)
		? pulse_input_device : pulse_output_device;
	pulse_get_server_info(cb, (void *) settings);

	pulse_unref();
}
/**
 * Create the plugin object
 */
static void *pulse_create(obs_data_t *settings, obs_source_t *source)
{
	struct pulse_data *data = bzalloc(sizeof(struct pulse_data));

	data->source   = source;

	pulse_init();
	pulse_update(data, settings);

	return data;
}
Exemple #5
0
/**
 * Get plugin properties
 */
static obs_properties_t pulse_properties(const char *locale, bool input)
{
	obs_properties_t props = obs_properties_create(locale);
	obs_property_t devices = obs_properties_add_list(props, "device_id",
		"Device", OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);

	pulse_init();
	pa_source_info_cb_t cb = (input) ? pulse_input_info : pulse_output_info;
	pulse_get_source_info_list(cb, (void *) devices);
	pulse_unref();

	return props;
}
Exemple #6
0
static int pulse_play(void)
{
    if (!pulse_tid)
    {
        if (pulse_init () < 0)
        {
            return -1;
        }
    }

    state = OUTPUT_STATE_PLAYING;
    return 0;
}
Exemple #7
0
/**
 * Get plugin properties
 */
static obs_properties_t *pulse_properties(bool input)
{
	obs_properties_t *props = obs_properties_create();
	obs_property_t *devices = obs_properties_add_list(props, "device_id",
		obs_module_text("Device"), OBS_COMBO_TYPE_LIST,
		OBS_COMBO_FORMAT_STRING);

	pulse_init();
	pa_source_info_cb_t cb = (input) ? pulse_input_info : pulse_output_info;
	pulse_get_source_info_list(cb, (void *) devices);
	pulse_unref();

	return props;
}
Exemple #8
0
static int pulse_unpause(void)
{
    trace ("pulse_unpause\n");
    if (state == OUTPUT_STATE_PAUSED)
    {
        if (pulse_init () < 0)
        {
            return -1;
        }
        state = OUTPUT_STATE_PLAYING;
    }

    return 0;
}
/**
 * Create the plugin object
 */
static void *pulse_create(obs_data_t settings, obs_source_t source)
{
	struct pulse_data *data = bzalloc(sizeof(struct pulse_data));

	data->source   = source;
	data->speakers = SPEAKERS_STEREO;

	pulse_init();
	pulse_update(data, settings);

	if (data->stream)
		return data;

	pulse_destroy(data);
	return NULL;
}
Exemple #10
0
/*
 * Create the plugin object
 */
static void *pulse_create(obs_data_t settings, obs_source_t source)
{
	struct pulse_data *data = bzalloc(sizeof(struct pulse_data));

	data->source   = source;
	data->speakers = SPEAKERS_STEREO;
	data->device   = bstrdup(obs_data_getstring(settings, "device_id"));

	pulse_init();
	if (pulse_start_recording(data) < 0)
		goto fail;

	return data;
fail:
	pulse_destroy(data);
	return NULL;
}
Exemple #11
0
static int pulse_unpause(void)
{
    trace ("pulse_unpause\n");
    deadbeef->mutex_lock (mutex);
    if (state == OUTPUT_STATE_PAUSED)
    {
        if (pulse_init () < 0)
        {
            deadbeef->mutex_unlock (mutex);
            return -1;
        }
        state = OUTPUT_STATE_PLAYING;
    }

    deadbeef->mutex_unlock (mutex);

    return 0;
}
Exemple #12
0
static int pulse_play(void)
{
    trace ("pulse_play\n");
    deadbeef->mutex_lock (mutex);
    if (!pulse_tid)
    {
        if (pulse_init () < 0)
        {
            deadbeef->mutex_unlock (mutex);
            return -1;
        }
    }

    pa_simple_flush (s, NULL);
    state = OUTPUT_STATE_PLAYING;
    deadbeef->mutex_unlock (mutex);

    return 0;
}
Exemple #13
0
static int pulse_setformat (ddb_waveformat_t *fmt)
{
    int st = state;
    memcpy (&requested_fmt, fmt, sizeof (ddb_waveformat_t));
    if (!s
        || !memcmp (fmt, &plugin.fmt, sizeof (ddb_waveformat_t))) {
        return 0;
    }

    pulse_free ();
    pulse_init ();
    int res = 0;
    if (st == OUTPUT_STATE_PLAYING) {
        res = pulse_play ();
    }
    else if (st == OUTPUT_STATE_PAUSED) {
        res = pulse_pause ();
    }

    return res;
}
Exemple #14
0
int main()
{
	int ret;
	u8 id = 2;
	u32 get_num;
	//环境初始化
	inittest();
	pulse_init();
	//测试用例1
	ret = pulse_get(id, &get_num);
	assert((ret == 0) && (get_num == 0),"pulse_get error");

	//测试用例2

	//测试用例3

	//测试用例4

	finaltest();
	return 0;
}
Exemple #15
0
/**
 * Get plugin properties
 */
static obs_properties_t *pulse_properties(bool input)
{
	obs_properties_t *props = obs_properties_create();
	obs_property_t *devices = obs_properties_add_list(props, "device_id",
		obs_module_text("Device"), OBS_COMBO_TYPE_LIST,
		OBS_COMBO_FORMAT_STRING);

	pulse_init();
	if (input)
		pulse_get_source_info_list(pulse_input_info, (void *) devices);
	else
		pulse_get_sink_info_list(pulse_output_info, (void *) devices);
	pulse_unref();

	size_t count = obs_property_list_item_count(devices);

	if (count > 0)
		obs_property_list_insert_string(devices, 0,
				obs_module_text("Default"), "default");

	return props;
}
Exemple #16
0
int main(int argc, char * argv[]) {
    struct pulseaudio_t pulse = {0};
    int relative = 0, percentage = 0;
    double max_vol = 2.*PA_VOLUME_NORM;
    double num = 0;

    int want_percentage = 0;

    pulse_init(&pulse);

    pulse_get_default_sink(&pulse);
    pulse_get_default_sink_volume(&pulse);

    /* Parse command line */
    /* Can be a string of "m*" "u*" "t*" "+/-number" "f" */
    for (int a = 1; a < argc; a ++) {
        if (strncasecmp("h", argv[a], 1) == 0 || strcasecmp("-h", argv[a]) == 0 || strcasecmp("--help", argv[a]) == 0) {
            /* print usage */
            printf("usage: %s ARG ...\n", argv[0]);
            printf("\n");
            printf("ARG can be one of:\n");
            printf("  MUTING\n");
            printf("      m[ute]      : enable mute\n");
            printf("      u[nmute]    : disable mute\n");
            printf("      t[oggle]    : toggle mute\n");
            printf("\n");
            printf("  VOLUME\n");
            printf("      +           : increase the volume by %d%%\n", DEFAULT_RELATIVE_VOLUME);
            printf("      -           : decrease the volume by %d%%\n", DEFAULT_RELATIVE_VOLUME);
            printf("      NUM         : set the volume to an amount\n");
            printf("\n");
            printf("  OTHER\n");
            printf("       f          : double the maximum-settable volume\n");
            printf("       p          : output the mute status and volume as a percent\n");
            printf("\n");
            printf("NUM can be interpreted in different ways:\n");
            printf("    if NUM contains a radix (decimal point, '.'), it is interpreted as a percentage; otherwise it is an absolute value.\n");
            printf("    if NUM contains a sign ('+' or '-'), then it is interpreted as a relative value.\n");
            printf("\n");
            printf("The output is four space separated integers:\n");
            printf("    <muted> <absolute volume> <100%% volume> <maximum settable volume>\n");
            printf("If ARG 'p' is given, then the output is two integers:\n");
            printf("    <muted> <volume as a percent>\n");
            printf("\n");
            printf("EXAMPLES\n");
            printf("    set the volume to 50%%\n");
            printf("        %s 50.\n", argv[0]);
            printf("    increase the volume by 20%%\n");
            printf("        %s +20.\n", argv[0]);
            printf("    toggle mute\n");
            printf("        %s t\n", argv[0]);
            printf("    unmute and decrease volume to 10%%\n");
            printf("        %s u 10.\n", argv[0]);
            printf("    print out the mute status and current volume as a percent\n");
            printf("        %s p\n", argv[0]);
            continue;
        } if (strncasecmp("m", argv[a], 1) == 0) {
            /* Mute on */
            pulse_set_default_sink_mute(&pulse, 1);
            continue;
        } else if (strncasecmp("u", argv[a], 1) == 0) {
            /* Mute off */
            pulse_set_default_sink_mute(&pulse, 0);
            continue;
        } else if (strncasecmp("t", argv[a], 1) == 0) {
            /* Mute toggle */
            pulse_set_default_sink_mute(&pulse, !pulse.muted);
            continue;

        } else if (strncasecmp("f", argv[a], 1) == 0) {
            /* Enable loud volumes (up to 4 times instead of 2) */
            max_vol *= 2;
            continue;

        } else if (strncasecmp("p", argv[a], 1) == 0) {
            /* Enable loud volumes (up to 4 times instead of 2) */
            want_percentage = 1;
            continue;

        } else if (strcmp("+", argv[a]) == 0) {
            /* Default relative volume increase */
            max_vol *= 2;
            relative = 1;
            num = DEFAULT_RELATIVE_VOLUME;
            percentage = 1;
        } else if (strcmp("-", argv[a]) == 0) {
            /* Default relative volume decrease */
            max_vol *= 2;
            relative = -1;
            num = DEFAULT_RELATIVE_VOLUME;
            percentage = 1;
        } else {
            /* Interpret as volume change */
            num = parse_number(argv[a], &relative, &percentage);
        }
        double v = (double)pulse.volume;
        if (relative) {
            if (percentage) {
                v += relative * num/100. * (double)PA_VOLUME_NORM;
            } else {
                v += relative * num;
            }
        } else {
            if (percentage) {
                v = num/100.*(double)PA_VOLUME_NORM;
            } else {
                v = num;
            }
        }
        if (v < 0) {
            v = 0;
        } else if (v > max_vol) {
            v = max_vol;
        }
        pulse_set_default_sink_volume(&pulse, (pa_volume_t)v);
    }

    pulse_get_default_sink_volume(&pulse);
    if (want_percentage) {
        printf("%d %d\n", pulse.muted, pulse.volume * 100 / PA_VOLUME_NORM);
    } else {
        printf("%d %d %d %d\n", pulse.muted, pulse.volume, PA_VOLUME_NORM, (int)max_vol);
    }

    pulse_deinit(&pulse);
    return 0;
}