示例#1
0
/* an entry point for an address book or the like */
void dialer_dial( char * number )
{
    int x = 0;
    int ret;
    dsp_st dspz;

    if( !number ) return;

#ifdef __linux__
    ret = dsp_open(&dspz, DSP_LINEOUT);
    if( ret < 0 ) {
        pz_error( "/dev/dsp" );
        return;
    }
    ret = dsp_setup(&dspz, 1, 44100);
#else
    ret = ret;
#endif

    while ( number[x] != '\0' )
    {
        dtmf_play( &dspz, number[x++] );
    }

#ifdef __linux__
    dsp_close(&dspz);
#endif
}
示例#2
0
int main(int argc, const char **argv)
{
	struct dsp_node *node;
	int ret = 0;
	unsigned i;

	signal(SIGINT, signal_handler);

#ifdef DEBUG
	debug_level = 3;
#endif
	ntimes = 1000;

	argc--; argv++;
	handle_options(&argc, &argv);

	dsp_handle = dsp_open();

	if (dsp_handle < 0) {
		pr_err("dsp open failed");
		return -1;
	}

	if (!dsp_attach(dsp_handle, 0, NULL, &proc)) {
		pr_err("dsp attach failed");
		ret = -1;
		goto leave;
	}

	node = create_node();
	if (!node) {
		pr_err("dsp node creation failed");
		ret = -1;
		goto leave;
	}

	run_task(node, ntimes);
	destroy_node(node);

leave:
	if (proc) {
		if (!dsp_detach(dsp_handle, proc)) {
			pr_err("dsp detach failed");
			ret = -1;
		}
		proc = NULL;
	}

	for (i = 0; i < ARRAY_SIZE(events); i++)
		free(events[i]);

	if (dsp_handle > 0) {
		if (dsp_close(dsp_handle) < 0) {
			pr_err("dsp close failed");
			return -1;
		}
	}

	return ret;
}
示例#3
0
static int audio_open()
{
	if (video_useAudio) {

		audio_alloc();
		dsp_open(&dspz, 1); /* DSP_LINEOUT); */
		dsp_setup(&dspz, wavHeader.nChannels, wavHeader.nSamplesPerSec); 
	}
	return 0;
}
示例#4
0
static void start_mp3_playback(char *filename)
{
	FILE *file;
	int ret;

	ret = dsp_open(&dspz, DSP_LINEOUT);
	if (ret < 0) {
		pz_perror("/dev/dsp");
		pz_close_window(mp3_wid);
		return;
	}

	do {
		pz_draw_header(_("Buffering..."));
		total_time = remaining_time = next_song_time;
		mp3_do_draw(0);

		file = fopen(filename, "r");
		if (file == 0) {
			pz_close_window(mp3_wid);
			pz_perror(filename);
			dsp_close(&dspz);
			return;
		}

		fseek(file, 0, SEEK_END);
		audiobuf_len = ftell(file);
		audiobufpos = 0;
		audiobuf = malloc(audiobuf_len);
		if (audiobuf == 0) {
			pz_close_window(mp3_wid);
			dsp_close(&dspz);
			fclose(file);

			new_message_window(_("malloc failed"));
			return;
		}

		fseek(file, 0, SEEK_SET);
		fread(audiobuf, audiobuf_len, 1, file);
		fclose(file);

		pz_draw_header(_("MP3 Playback"));

		decode_mp3();

		free(audiobuf);

		filename = next_song;
	}
	while (next_song_queued);

	dsp_close(&dspz);
	pz_close_window(mp3_wid);
}
int main(int argc, const char **argv)
{
	struct dsp_node *node;
	int ret = 0;

	signal(SIGINT, signal_handler);

#ifdef DEBUG
	debug_level = 3;
#endif

	dsp_handle = dsp_open();

	if (dsp_handle < 0) {
		pr_err("dsp open failed");
		return -1;
	}

	if (!dsp_attach(dsp_handle, 0, NULL, &proc)) {
		pr_err("dsp attach failed");
		ret = -1;
		goto leave;
	}

	node = create_node();
	if (!node) {
		pr_err("dsp node creation failed");
		ret = -1;
		goto leave;
	}

	run_task(node);
	
	destroy_node(node);

leave:
	if (proc) {
		if (!dsp_detach(dsp_handle, proc)) {
			pr_err("dsp detach failed");
			ret = -1;
		}
		proc = NULL;
	}

	if (dsp_handle > 0) {
		if (dsp_close(dsp_handle) < 0) {
			pr_err("dsp close failed");
			return -1;
		}
	}

	return ret;
}
示例#6
0
void generator_construct()
{
	int frag;
	dsp_open(&dspz, DSP_LINEOUT);
    	frag = (16 << 16) | 8;	// 16 fragments of 256 bytes each : Not sure if this is implemented for ipod
    	ioctl (dspz.dsp, SNDCTL_DSP_SETFRAGMENT, &frag);	//for better realtime response 
	dsp_setup(&dspz, 1, SAMPLING_RATE);

	generator_freq = START_FREQ;
	generator_mode = GENERATOR_MODE_FREQ;
	generator_quit_app = 0 ;
	generator_paused = 1;
	make_lookup_table();	//make fast_sine() table
	generator_display_refresh();
}
示例#7
0
void sound_open(int outp)
{
    switch (outp) {
        case ALSA:
            alsa_open(DEVALSA);
            break;
        case DSP:
            dsp_open(DEVDSP);
            break;
        case STDOUT:
            stdout_open(DEVDSP);
            break;
        default:
            fprintf(stderr, "Unknown output method\n");
    }
}
示例#8
0
static gboolean
dsp_init(GstDspDummy *self)
{
	int dsp_handle;

	self->dsp_handle = dsp_handle = dsp_open();

	if (dsp_handle < 0) {
		GST_ERROR("dsp open failed");
		return FALSE;
	}

	if (!dsp_attach(dsp_handle, 0, NULL, &self->proc)) {
		GST_ERROR("dsp attach failed");
		goto fail;
	}

	self->node = create_node(dsp_handle, self->proc);
	if (!self->node) {
		GST_ERROR("dsp node creation failed");
		goto fail;
	}

	return TRUE;

fail:
	if (self->proc) {
		if (!dsp_detach(dsp_handle, self->proc))
			GST_ERROR("dsp detach failed");
		self->proc = NULL;
	}

	if (self->dsp_handle >= 0) {
		if (dsp_close(dsp_handle) < 0)
			GST_ERROR("dsp close failed");
		self->dsp_handle = -1;
	}

	return FALSE;
}
示例#9
0
/* the entry point for the menu system */
void new_dialer_window()
{
    int ret = 0;

#ifdef __linux__
    ret = dsp_open(&dspz, DSP_LINEOUT);
#endif
    if (ret < 0) {
        pz_perror("/dev/dsp");
        return;
    }
#ifdef __linux__
    ret = dsp_setup(&dspz, 1, 44100);
#endif

    dialer_gc = pz_get_gc(1);
    GrSetGCUseBackground(dialer_gc, GR_FALSE);
    GrSetGCForeground(dialer_gc, GR_RGB(0,0,0));

    if (screen_info.cols < 160) { //mini
        cxgap = 3;
        cygap = 2;
        cbw = 22;
        cbh = 15;
    }

    dialer_wid = pz_new_window(0, HEADER_TOPLINE + 1,
                               screen_info.cols,
                               screen_info.rows - (HEADER_TOPLINE + 1),
                               dialer_do_draw, dialer_do_keystroke);

    GrSelectEvents(dialer_wid, GR_EVENT_MASK_EXPOSURE |
                   GR_EVENT_MASK_KEY_UP | GR_EVENT_MASK_KEY_DOWN);

    GrMapWindow(dialer_wid);
}
示例#10
0
DLL_EXPORT void *emc_ui_open(const char *home, const char *ini_file)
{
   struct emc_session *ret = NULL, *ps = &session;
   char inistring[LINELEN];
   int i;

   DBG("[%d] emc_ui_open() ini=%s\n", getpid(), ini_file);

   strncpy(USER_HOME_DIR, home, sizeof(USER_HOME_DIR));
   USER_HOME_DIR[sizeof(USER_HOME_DIR)-1] = 0;  /* force zero termination */

   strncpy(ps->ini_file, ini_file, sizeof(ps->ini_file));
   ps->ini_file[sizeof(ps->ini_file)-1] = 0;  /* force zero termination */

   iniGetKeyValue("TASK", "SERIAL_NUMBER", ps->serial_num, sizeof(ps->serial_num));
   ps->input0_abort_enabled = 0;
   if (iniGetKeyValue("TASK", "INPUT0_ABORT", inistring, sizeof(inistring)) > 0)
      ps->input0_abort_enabled = strtod(inistring, NULL);
   ps->input1_abort_enabled = 0;
   if (iniGetKeyValue("TASK", "INPUT1_ABORT", inistring, sizeof(inistring)) > 0)
      ps->input1_abort_enabled = strtod(inistring, NULL);
   ps->input2_abort_enabled = 0;
   if (iniGetKeyValue("TASK", "INPUT2_ABORT", inistring, sizeof(inistring)) > 0)
      ps->input2_abort_enabled = strtod(inistring, NULL);

   ps->axes = 4;        /* default to XYZA */
   if (iniGetKeyValue("TRAJ", "AXES", inistring, sizeof(inistring)) > 0)
   {
      ps->axes = strtod(inistring, NULL);
   }
   if (ps->axes > EMC_MAX_JOINTS)
   {
      BUG("Invalid ini file setting: axes=%d\n", ps->axes);
      ps->axes = 4;
   }
   ps->axes_mask = _map_axes_mask[ps->axes];

   if (iniGetKeyValue("TRAJ", "LINEAR_UNITS", inistring, sizeof(inistring)) > 0)
      ps->linearUnits = _map_linear_units(inistring);

   if (iniGetKeyValue("TRAJ", "ANGULAR_UNITS", inistring, sizeof(inistring)) > 0)
      ps->angularUnits = _map_angular_units(inistring);

   ps->maxVelocity = 1e99;      // by default, use AXIS limit
   if (iniGetKeyValue("TRAJ", "MAX_VELOCITY", inistring, sizeof(inistring)) > 0)
      ps->maxVelocity = strtod(inistring, NULL);

   ps->maxAcceleration = 1e99;      // by default, use AXIS limit
   if (iniGetKeyValue("TRAJ", "MAX_ACCELERATION", inistring, sizeof(inistring)) > 0)
      ps->maxAcceleration = strtod(inistring, NULL);

   if (iniGetKeyValue("EMC", "TOOL_TABLE", inistring, sizeof(inistring)) > 0)
      _load_tool_table(inistring, ps->toolTable);

   for (i=0; i < ps->axes; i++)
      _load_axis(ps, i);

   ps->cycle_time = RTSTEPPER_PERIOD * 1e-9;  /* convert ns to sec */
   ps->cycle_freq = 1 / ps->cycle_time;

   INIT_LIST_HEAD(&ps->head.list);

   emc_post_position_cb(0, ps->position);

   if (dsp_open(ps) != EMC_R_OK || rtstepper_open(ps) != EMC_R_OK)
      emc_post_estop_cb(ps);

   ret = ps;

   return ret;  /* return an opaque handle */
}       /* emc_ui_open() */
示例#11
0
int main(int argc, const char **argv)
{
	int ret = 0;
	int dsp_handle;
	void *proc;
	char *cmd[1];

	if (argc != 2) {
		pr_err("Wrong arguments: %s <dsp_program>", argv[0]);
		return -1;
	}

	dsp_handle = dsp_open();

	if (dsp_handle < 0) {
		pr_err("dsp open failed");
		return -1;
	}

	if (!dsp_attach(dsp_handle, 0, NULL, &proc)) {
		pr_err("dsp attach failed");
		ret = -1;
		goto leave;
	}

	if (!dsp_stop(dsp_handle, proc)) {
		pr_err("dsp stop failed");
		ret = -1;
		goto leave;
	}

	cmd[0] = (char *) argv[1];
	if (!dsp_load(dsp_handle, proc, 1, cmd, NULL)) {
		pr_err("dsp load failed");
		ret = -1;
		goto leave;
	}

	if (!dsp_start(dsp_handle, proc)) {
		pr_err("dsp start failed");
		ret = -1;
	}

leave:
	if (proc) {
		if (!dsp_detach(dsp_handle, proc)) {
			pr_err("dsp detach failed");
			ret = -1;
		}
		proc = NULL;
	}

	if (dsp_handle > 0) {
		if (dsp_close(dsp_handle) < 0) {
			pr_err("dsp close failed");
			return -1;
		}
	}

	return ret;
}