コード例 #1
0
void phi_4(const double * p, const double ** v, void * value)
{
  double * val = (double *)value;
  double volume = get_volume(v[0], v[1], v[2], v[3]);
  val[0] = get_volume(v[0], v[1], v[2], p);
  val[0] /= volume;
  val[0] = val[0]*(2*val[0] - 1);
}
コード例 #2
0
void get_lambda(const double * p, const double ** v, double * lambda, double * volume)
{
  volume[0] = get_volume(v[0], v[1], v[2], v[3]);
  lambda[0] = get_volume(p, v[1], v[2], v[3])/volume[0];
  lambda[1] = get_volume(v[0], p, v[2], v[3])/volume[0];
  lambda[2] = get_volume(v[0], v[1], p, v[3])/volume[0];
  lambda[3] = get_volume(v[0], v[1], v[2], p)/volume[0];
}
コード例 #3
0
ファイル: mincio.c プロジェクト: BIC-MNI/BEaST
int write_volume(char *name, VIO_Volume vol, float *data){
  int i,j,k,index,sizes[5];
  float min=FLT_MAX,max=FLT_MIN;

  fprintf(stderr,"Writing %s\n",name);

  get_volume_sizes(vol,sizes);

  for (i=0;i<sizes[0];i++){
    for (j=0;j<sizes[1];j++){
      for (k=0;k<sizes[2];k++){	  
	index=i*sizes[2]*sizes[1] + j*sizes[2] + k;
	min=MIN(min,data[index]);
	max=MAX(max,data[index]);
      }
    }
  }
  
  set_volume_real_range(vol,min,max);

  get_volume(data, vol, sizes);

  output_volume( name, NC_FLOAT,FALSE,min,max,vol,NULL, (minc_output_options *)NULL);

  return STATUS_OK;
}
コード例 #4
0
market_ticker market_history_api_impl::get_ticker() const
{
   market_ticker result;

   auto db = app.chain_database();
   const auto& bucket_idx = db->get_index_type< bucket_index >().indices().get< by_bucket >();
   auto itr = bucket_idx.lower_bound( boost::make_tuple( 86400, db->head_block_time() - 86400 ) );

   if( itr != bucket_idx.end() )
   {
      auto open = ( asset( itr->open_sbd, SBD_SYMBOL ) / asset( itr->open_steem, STEEM_SYMBOL ) ).to_real();
      result.latest = ( asset( itr->close_sbd, SBD_SYMBOL ) / asset( itr->close_steem, STEEM_SYMBOL ) ).to_real();
      result.percent_change = ( ( result.latest - open ) / open ) * 100;
   }
   else
   {
      result.latest = 0;
      result.percent_change = 0;
   }

   auto orders = get_order_book( 1 );
   if( orders.bids.size() )
      result.highest_bid = orders.bids[0].price;
   if( orders.asks.size() )
      result.lowest_ask = orders.asks[0].price;

   auto volume = get_volume();
   result.steem_volume = volume.steem_volume;
   result.sbd_volume = volume.sbd_volume;

   return result;
}
コード例 #5
0
ファイル: cuse-vol.c プロジェクト: Themaister/libmaru
int main(int argc, char *argv[])
{
   if (argc < 3)
   {
      fprintf(stderr, "Usage: <dsp> <get|set|delta> <vol (0-100)>\n");
      return 1;
   }

   int fd = open(argv[1], O_WRONLY);
   if (fd < 0)
   {
      perror("open");
      return 1;
   }

   if (strcmp(argv[2], "get") == 0)
      return get_volume(fd);
   else if (strcmp(argv[2], "set") == 0)
      return set_volume(fd, argc, argv);
   else if (strcmp(argv[2], "delta") == 0)
      return delta_volume(fd, argc, argv);
   else
   {
      fprintf(stderr, "Invalid command \"%s\", needs \"get\" or \"set\" ...\n",
            argv[2]);
      return 1;
   }
}
コード例 #6
0
ファイル: load-git.c プロジェクト: AresDice/subsurface
static void parse_cylinder_keyvalue(void *_cylinder, const char *key, const char *value)
{
	cylinder_t *cylinder = _cylinder;
	if (!strcmp(key, "vol")) {
		cylinder->type.size = get_volume(value);
		return;
	}
	if (!strcmp(key, "workpressure")) {
		cylinder->type.workingpressure = get_pressure(value);
		return;
	}
	/* This is handled by the "get_utf8()" */
	if (!strcmp(key, "description"))
		return;
	if (!strcmp(key, "o2")) {
		cylinder->gasmix.o2 = get_fraction(value);
		return;
	}
	if (!strcmp(key, "he")) {
		cylinder->gasmix.he = get_fraction(value);
		return;
	}
	if (!strcmp(key, "start")) {
		cylinder->start = get_pressure(value);
		return;
	}
	if (!strcmp(key, "end")) {
		cylinder->end = get_pressure(value);
		return;
	}
	report_error("Unknown cylinder key/value pair (%s/%s)", key, value);
}
コード例 #7
0
int cx25840_audio_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
{
	struct i2c_client *client = v4l2_get_subdevdata(sd);

	switch (ctrl->id) {
	case V4L2_CID_AUDIO_VOLUME:
		ctrl->value = get_volume(client);
		break;
	case V4L2_CID_AUDIO_BASS:
		ctrl->value = get_bass(client);
		break;
	case V4L2_CID_AUDIO_TREBLE:
		ctrl->value = get_treble(client);
		break;
	case V4L2_CID_AUDIO_BALANCE:
		ctrl->value = get_balance(client);
		break;
	case V4L2_CID_AUDIO_MUTE:
		ctrl->value = get_mute(client);
		break;
	default:
		return -EINVAL;
	}
	return 0;
}
コード例 #8
0
ファイル: dwmstatus.c プロジェクト: iambetmen/dotfiles
int
main(void) {
	char *status;
	char *tmchicago;
	char *alsavolume;
	char *mpdinfo;
	char *mailinfo;
	char *networkinfo;
	char *layoutinfo;
	static unsigned long long int rec, sent;
	time_t count5min = time(NULL);

	/*
	if (!(dpy = XOpenDisplay(NULL))) {
		fprintf(stderr, "dwmstatus: cannot open display.\n");
		return 1;
	}
	*/

	xkblayoutSetup();

	parse_netdev(&rec,&sent);
	mailinfo = getMailCount();
	for (;;sleep(1)) {
		/* Put together the pieces of our status */
		tmchicago = mktimes("%a, %b %d %I:%M", tzchicago);
		alsavolume = get_volume();
		mpdinfo = getmpdstat();
		networkinfo = get_netusage(&rec,&sent);
		layoutinfo = getKeyboardLayout();

		if(runevery(&count5min, 300)) {
			free(mailinfo);
			mailinfo = getMailCount();
		}

		/* Build the status string from our pieces */
		status = smprintf("%s %s %s %s %s[%s%s%%%s] %s[%s%s%s]", mpdinfo, networkinfo, mailinfo, layoutinfo, colcyan, colgreen, alsavolume, colcyan, colcyan, colyellow, tmchicago, colcyan);

		/* Send it to the wm for display */
		setstatus(status);

		/* Clean up our pieces */
		free(layoutinfo);
		free(tmchicago);
		free(alsavolume);
		free(mpdinfo);
		free(networkinfo);
		free(status);
	}

	free(mailinfo);

	xkblayoutCleanup();

	XCloseDisplay(dpy);

	return 0;
}
コード例 #9
0
ファイル: sndboard.cpp プロジェクト: Blonder/WinUAE
static void calculate_volume_toccata(void)
{
	struct toccata_data *data = &toccata;
	data->left_volume = (100 - currprefs.sound_volume_board) * 32768 / 100;
	data->right_volume = (100 - currprefs.sound_volume_board) * 32768 / 100;

	data->left_volume = get_volume(data->ad1848_regs[6]) * data->left_volume / 32768;
	data->right_volume = get_volume(data->ad1848_regs[7]) * data->right_volume / 32768;

	if (currprefs.sound_toccata_mixer) {
		sound_paula_volume[0] = get_volume_in(data->ad1848_regs[4]);
		sound_paula_volume[1] = get_volume_in(data->ad1848_regs[5]);

		sound_cd_volume[0] = get_volume_in(data->ad1848_regs[2]);
		sound_cd_volume[1] = get_volume_in(data->ad1848_regs[3]);
	}
}
コード例 #10
0
ファイル: util.c プロジェクト: 4ZM/Slic3r
void stl_calculate_volume(stl_file *stl)
{
	stl->stats.volume = get_volume(stl);
	if(stl->stats.volume < 0.0){
		stl_reverse_all_facets(stl);
		stl->stats.volume = -stl->stats.volume;
	}
}
コード例 #11
0
int cx25840_audio(struct i2c_client *client, unsigned int cmd, void *arg)
{
	struct v4l2_control *ctrl = arg;

	switch (cmd) {
	case VIDIOC_INT_AUDIO_CLOCK_FREQ:
		return set_audclk_freq(client, *(u32 *)arg);

	case VIDIOC_G_CTRL:
		switch (ctrl->id) {
		case V4L2_CID_AUDIO_VOLUME:
			ctrl->value = get_volume(client);
			break;
		case V4L2_CID_AUDIO_BASS:
			ctrl->value = get_bass(client);
			break;
		case V4L2_CID_AUDIO_TREBLE:
			ctrl->value = get_treble(client);
			break;
		case V4L2_CID_AUDIO_BALANCE:
			ctrl->value = get_balance(client);
			break;
		case V4L2_CID_AUDIO_MUTE:
			ctrl->value = get_mute(client);
			break;
		default:
			return -EINVAL;
		}
		break;

	case VIDIOC_S_CTRL:
		switch (ctrl->id) {
		case V4L2_CID_AUDIO_VOLUME:
			set_volume(client, ctrl->value);
			break;
		case V4L2_CID_AUDIO_BASS:
			set_bass(client, ctrl->value);
			break;
		case V4L2_CID_AUDIO_TREBLE:
			set_treble(client, ctrl->value);
			break;
		case V4L2_CID_AUDIO_BALANCE:
			set_balance(client, ctrl->value);
			break;
		case V4L2_CID_AUDIO_MUTE:
			set_mute(client, ctrl->value);
			break;
		default:
			return -EINVAL;
		}
		break;

	default:
		return -EINVAL;
	}

	return 0;
}
コード例 #12
0
ファイル: tank.cpp プロジェクト: demise712/Alphabet
 double  mixing_tank::draw( double quantity )
 {
   assert (quantity >= 0.0);
   double temp; // keeps track of what the volume is 
   temp = get_volume() - quantity;
   quantity_a -=  ((get_mix())*quantity);
   quantity_b =  temp - quantity_a;
   return quantity;
 }
コード例 #13
0
ファイル: mincio.c プロジェクト: BIC-MNI/BEaST
int write_minc(char *filename, float *image, image_metadata *meta,VIO_BOOL binary_mask){
  VIO_Volume volume;
  int i,j,k,index;
  float min=FLT_MAX,max=FLT_MIN;
  VIO_Real dummy[3];

  if(binary_mask)
  {
    volume = create_volume(3,NULL,NC_BYTE,FALSE,0.0,1.0);
    printf("Writing a binary volume...\n");
  }
  else 
    volume = create_volume(3,NULL,NC_FLOAT,FALSE,FLT_MIN,FLT_MAX);
  
  if(!volume)
    return STATUS_ERR;
  
  if(!binary_mask)
  {
    for (i=0;i<meta->length[0];i++){
      for (j=0;j<meta->length[1];j++){
        for (k=0;k<meta->length[2];k++){	  
          index=i*meta->length[2]*meta->length[1] + j*meta->length[2] + k;
          min=MIN(min,image[index]);
          max=MAX(max,image[index]);
        }
      }
    }
    set_volume_real_range(volume,min,max);
  } else {
    set_volume_real_range(volume,0.0,1.0);
  }
  
  set_volume_sizes(volume,meta->length);
  dummy[0]=meta->start[0];
  dummy[1]=meta->start[1];
  dummy[2]=meta->start[2];
  set_volume_starts(volume,dummy);
  dummy[0]=meta->step[0];
  dummy[1]=meta->step[1];
  dummy[2]=meta->step[2];
  set_volume_separations(volume,dummy);

  alloc_volume_data(volume);
    
  get_volume(image, volume, meta->length);

  if(!binary_mask)
    output_volume( filename, NC_FLOAT,FALSE,min, max,volume,meta->history,(minc_output_options *)NULL);
  else
    output_volume( filename, NC_BYTE,FALSE,0, 1.0,volume,meta->history,(minc_output_options *)NULL);
    
  delete_volume(volume);

  return STATUS_OK;
}
コード例 #14
0
ファイル: AC97.c プロジェクト: AgamAgarwal/minix
static int AC97_get_volume(struct volume_level *level) {
	int cmd;
	u8_t left;
	u8_t right;

	switch(level->device) {
		case Master:
			cmd = AC97_MASTER_VOLUME;
			get_volume(&left, &right, cmd);
			convert(left, right, 0x1f, 
					&(level->left), &(level->right), 0x1f, 0);
			break;
		case Dac:
			return EINVAL;
			break;
		case Fm:
			cmd = AC97_PCM_OUT_VOLUME;
			get_volume(&left, &right, cmd);
			convert(left, right, 0x1f, 
					&(level->left), &(level->right), 0x1f, 0);
			break;
		case Cd:
			cmd = AC97_CD_VOLUME;
			get_volume(&left, &right, cmd);
			convert(left, right, 0x1f, 
					&(level->left), &(level->right), 0x1f, 0);
			break;
		case Line:
			cmd = AC97_LINE_IN_VOLUME;
			get_volume(&left, &right, cmd);
			convert(left, right, 0x1f, 
					&(level->left), &(level->right), 0x1f, 0);
			break;
		case Mic:
			cmd = AC97_MIC_VOLUME;
			get_volume(&left, &right, cmd);
			convert(left, right, 0x1f, 
					&(level->left), &(level->right), 0x1f, 1);
			break;
		case Speaker:
			return EINVAL;
		case Treble:
			cmd = AC97_MASTER_TONE;
			get_volume(&left, &right, cmd);
			convert(left, right, 0xf, 
					&(level->left), &(level->right), 0xf, 1);
			break;
		case Bass:  
			cmd = AC97_MASTER_TONE;
			get_volume(&left, &right, cmd);
			convert(left, right, 0xf, 
					&(level->left), &(level->right), 0xf, 1);
			break;
		default:     
			return EINVAL;
	}
	return OK;
}
コード例 #15
0
ファイル: VolumeControl.cpp プロジェクト: sumitbirla/carpc
VolumeControl::VolumeControl() : QObject( 0, 0 )
{
   isMute = 0;

   if ( (mixer_fd=open(DEV_MIXER, O_RDWR, 0)) < 0 ) 
   {
      fprintf(stderr, "Can't open %s: \n", DEV_MIXER);
   }
   get_volume();
}
コード例 #16
0
ファイル: Music.cpp プロジェクト: Maxs1789/solarus
/**
 * \brief Sets the volume of musics.
 * \param volume the new volume (0 to 100)
 */
void Music::set_volume(int volume) {

  volume = std::min(100, std::max(0, volume));
  Music::volume = volume / 100.0;

  if (current_music != nullptr) {
    alSourcef(current_music->source, AL_GAIN, Music::volume);
  }

  Logger::info(std::string("Music volume: ") + String::to_string(get_volume()));
}
コード例 #17
0
ファイル: spm_invdef.c プロジェクト: Ascronia/fieldtrip
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
	float  *y0=0,  *y1=0,  *y2=0, *iy0=0, *iy1=0, *iy2=0;
	int dim_g[3], dim_f[3];
	REAL U[4][3], V[4][3];

        if (nrhs != 6 || nlhs > 3) mexErrMsgTxt("Incorrect usage.");

	y0 = get_volume(prhs[0], dim_g);
	y1 = get_volume(prhs[1], dim_f);
	if (dim_g[0] != dim_f[0] || dim_g[1] != dim_f[1] || dim_g[2] != dim_f[2])
		mexErrMsgTxt("Incompatible dimensions.");
	y2 = get_volume(prhs[2], dim_f);
	if (dim_g[0] != dim_f[0] || dim_g[1] != dim_f[1] || dim_g[2] != dim_f[2])
		mexErrMsgTxt("Incompatible dimensions.");

	if (!mxIsNumeric(prhs[3]) || mxIsComplex(prhs[3]) ||
		mxIsComplex(prhs[3]) || !mxIsDouble(prhs[3]) || mxGetM(prhs[3]) * mxGetN(prhs[3]) != 3)
		mexErrMsgTxt("Output dimensions must be numeric, real, full, double and contain three elements.");

	dim_f[0] = mxGetPr(prhs[3])[0];
	dim_f[1] = mxGetPr(prhs[3])[1];
	dim_f[2] = mxGetPr(prhs[3])[2];

	get_mat(prhs[4],U);
	get_mat(prhs[5],V);

	plhs[0] = mxCreateNumericArray(3, dim_f,mxSINGLE_CLASS,mxREAL);
	plhs[1] = mxCreateNumericArray(3, dim_f,mxSINGLE_CLASS,mxREAL);
	plhs[2] = mxCreateNumericArray(3, dim_f,mxSINGLE_CLASS,mxREAL);

	iy0 = (float *)mxGetPr(plhs[0]);
	iy1 = (float *)mxGetPr(plhs[1]);
	iy2 = (float *)mxGetPr(plhs[2]);

	setnan(iy0, dim_f[0]*dim_f[1]*dim_f[2]);
	setnan(iy1, dim_f[0]*dim_f[1]*dim_f[2]);
	setnan(iy2, dim_f[0]*dim_f[1]*dim_f[2]);

	invert_field(dim_g, y0, y1, y2, dim_f, iy0, iy1, iy2, U, V);
}
コード例 #18
0
ファイル: ao_coreaudio.c プロジェクト: BILIHUBSU/mpv
static int control(struct ao *ao, enum aocontrol cmd, void *arg)
{
    switch (cmd) {
    case AOCONTROL_GET_VOLUME:
        return get_volume(ao, arg);
    case AOCONTROL_SET_VOLUME:
        return set_volume(ao, arg);
    case AOCONTROL_HAS_SOFT_VOLUME:
        return CONTROL_TRUE;
    }
    return CONTROL_UNKNOWN;
}
コード例 #19
0
ファイル: fsfn_sound.c プロジェクト: timfel/sonyfsfn
int volume_down()
{
    int value = 0;

    get_volume(&value);

    if (value > 0x0a0a)
        value -= 0x0a0a;
    else
        value = 0;

    set_volume(&value);

    return 0;
}
コード例 #20
0
ファイル: fsfn_sound.c プロジェクト: timfel/sonyfsfn
int volume_up()
{
    int value = 0;

    get_volume(&value);

    if (value < 0x5a5a)
        value += 0x0a0a;
    else
        value = 0x6464;

    set_volume(&value);

    return 0;
}
コード例 #21
0
ファイル: dwmstatus.c プロジェクト: Mariappan/dwm
int
main(void)
{
	char *status = NULL;
	char *tmprs = NULL;
	char *avgs = NULL;
    time_t count60 = 0;
    char *uptm = NULL;
    char *vol = NULL;
	char *netstats = NULL;
    char *ram = NULL;
	static unsigned long long int rec, sent;

	if (!(dpy = XOpenDisplay(NULL))) {
		fprintf(stderr, "dwmstatus: cannot open display.\n");
		return 1;
	}

	parse_netdev(&rec, &sent);
	for (;;sleep(1)) {
	    /* checks every minutes */
	    if ( runevery(&count60, 60) )
        {
            free(tmprs);
            free(uptm);
            tmprs = mktimes("\x06\uf073 %b-%d   %I:%M  %p", tz);
            uptm = up();

            free(ram);
            ram = get_ram();
        }
        /* checks every second */
		avgs = loadavg();
        vol = get_volume();
		netstats = get_netusage(&rec, &sent);

		status = smprintf("%s%s %s %s%s%s",
				 netstats, avgs, ram, uptm, vol, tmprs);
		setstatus(status);
        free(vol);
		free(avgs);
		free(status);
	}

	XCloseDisplay(dpy);

	return 0;
}
コード例 #22
0
ファイル: cx25840-audio.c プロジェクト: PennPanda/linux-repo
static void set_mute(struct i2c_client *client, int mute)
{
	struct cx25840_state *state = i2c_get_clientdata(client);

	if (mute && state->unmute_volume == -1) {
		int vol = get_volume(client);

		set_volume(client, 0);
		state->unmute_volume = vol;
	}
	else if (!mute && state->unmute_volume != -1) {
		int vol = state->unmute_volume;

		state->unmute_volume = -1;
		set_volume(client, vol);
	}
}
コード例 #23
0
ファイル: md.c プロジェクト: SahanGH/psi4public
static double get_invariant_npt(const struct md *md)
{
	struct npt_data *data = (struct npt_data *)md->data;

	double t_tau = cfg_get_double(md->state->cfg, "thermostat_tau");
	double t_target = cfg_get_double(md->state->cfg, "temperature");
	double p_tau = cfg_get_double(md->state->cfg, "barostat_tau");
	double p_target = cfg_get_double(md->state->cfg, "pressure");

	double kbt = BOLTZMANN * t_target;
	double volume = get_volume(md);

	double t_virt = kbt * md->n_freedom * (data->chi_dt +
				data->chi * data->chi * t_tau * t_tau / 2.0);

	double p_virt = p_target * volume + 3.0 * md->n_bodies * kbt *
				data->eta * data->eta * p_tau * p_tau / 2.0;

	return md->potential_energy + get_kinetic_energy(md) + t_virt + p_virt;
}
コード例 #24
0
ファイル: md.c プロジェクト: SahanGH/psi4public
static double get_pressure(const struct md *md)
{
	double volume = get_volume(md);
	vec_t pressure = vec_zero;

	for (size_t i = 0; i < md->n_bodies; i++) {
		const struct body *body = md->bodies + i;

		pressure.x += body->mass * body->vel.x * body->vel.x;
		pressure.y += body->mass * body->vel.y * body->vel.y;
		pressure.z += body->mass * body->vel.z * body->vel.z;
	}

	mat_t stress;
	check_fail(efp_get_stress_tensor(md->state->efp, (double *)&stress));

	pressure.x = (pressure.x + stress.xx) / volume;
	pressure.y = (pressure.y + stress.yy) / volume;
	pressure.z = (pressure.z + stress.zz) / volume;

	return (pressure.x + pressure.y + pressure.z) / 3.0;
}
コード例 #25
0
ファイル: fsfn_sound.c プロジェクト: timfel/sonyfsfn
int mute()
{
    int value;
   
    get_volume(&value);
   
    if (value) {
       oldvalue=value;
       value=0;
       set_volume(&value);
    }
    else {
       if (!oldvalue) {
      volume_up();       
       }
       else {
          set_volume(&oldvalue);
       }
    }

    return 0;
}
コード例 #26
0
int cx18_av_audio_g_ctrl(struct cx18 *cx, struct v4l2_control *ctrl)
{
	switch (ctrl->id) {
	case V4L2_CID_AUDIO_VOLUME:
		ctrl->value = get_volume(cx);
		break;
	case V4L2_CID_AUDIO_BASS:
		ctrl->value = get_bass(cx);
		break;
	case V4L2_CID_AUDIO_TREBLE:
		ctrl->value = get_treble(cx);
		break;
	case V4L2_CID_AUDIO_BALANCE:
		ctrl->value = get_balance(cx);
		break;
	case V4L2_CID_AUDIO_MUTE:
		ctrl->value = get_mute(cx);
		break;
	default:
		return -EINVAL;
	}
	return 0;
}
コード例 #27
0
void print_points(n_points){
  int i;
  float radius;
  float volume;
  float surface;
  
  /*initialization*/
  radius = 0.0;
  volume = 0.0;
  surface = 0.0;

  printf("Radius Surface Volume\n");
  /*loop over n_points different values for the radius*/
  for(i=0; i<n_points; i++){
    radius = 1.0*i;

    surface = get_surface(radius); /*call to the function radius*/
    volume = get_volume(radius);  /*call to the function volume*/

    /*output the values to the screen*/
    printf("%f %f %f\n", radius, surface, volume);
  }  
}
コード例 #28
0
static int submenu_restoreonevolume(const Volume* volume)
{
	char**			headers = NULL;		// UI menu headers
	const Volume*	sdvolume;			// SDCARD volume
	int 			sdmounted;			// Flag if SDCARD was mounted
	char 			filter[256];		// Directory browse filter string
	char 			imgfile[256];		// Selected image file to restore
	int 			nav;				// Menu navigation code
	int 			result;				// Result from function call
	
	// Allocate a standard header
	headers = alloc_standard_header(SUBHEADER_RESTOREVOLUMES);
	if(headers == NULL) { LOGE("submenu_restoreonevolume: Cannot allocate menu headers"); return NAVIGATE_ERROR; }
	
	// Grab a reference to the SDCARD volume
	sdvolume = get_volume("SDCARD");
	if(sdvolume == NULL) { LOGE("submenu_restoreonevolume: Cannot locate SDCARD volume entry in fstab"); return NAVIGATE_ERROR; }
	
	// The SDCARD volume has to be mounted before we can browse it (obviously)
	result = mount_volume(sdvolume, &sdmounted);
	if(result != 0) { LOGE("submenu_restoreonevolume: Cannot mount SDCARD volume"); return NAVIGATE_ERROR; }
	
	// Generate the directory browse filter string.  Backup files can have a number of different
	// extensions, but if they were created by this recovery they will have the volume name in
	// ALL CAPS as the base file name
	snprintf(filter, 256, "%s*.*", volume->name);
	
	// Invoke the directory browser against the root of the SDCARD ...
	nav = navigate_menu_browse(headers, sdvolume->mount_point, filter, imgfile, 256);
	if(nav == NAVIGATE_SELECT) nav = submenu_restoreonevolume_confirm(volume, imgfile);
	
	// Unmount the SDCARD volume if it was mounted by this function
	if(sdmounted) unmount_volume(sdvolume, NULL);
	
	free_menu_list(headers);			// Release the string array
	return nav;							// Return navigation code
}
コード例 #29
0
ファイル: digiamp.c プロジェクト: transistorgrab/digiamp
/** this function loads the settings for volume and source from the eeprom
 * and restores the settings. sets volume and source to the last saved state	*/
void restore_settings(void)
{
	AMP_ENABLE = 0;	/** mute power amplifier	*/

	uint8_t temp;//, temp1;
	temp = recall_source();
	if ((temp == 0xFF)||(temp<SOURCE_MIN)||(temp>SOURCE_MAX))	/** default value from empty eeprom or illegal value	*/
		temp = SOURCE_MIN;	/** set useful value	*/

	set_source(temp);	/** if there is a value stored, restore it	*/
	get_source(temp);	/** send restored value to the source switching function	*/

	temp = recall_volume(1);	/** used twice	*/
	if ((temp == 0xFF)||(temp<VOLUME_MAX)||(temp>VOLUME_MIN))	/** default value from empty eeprom	or illegal value	*/
		temp = VOLUME_MIN;	/** set useful value	*/

//	temp1=recall_volume(0);	/** recall value for left volume; currently not in use	*/
//	if (temp1 == 0xFF)	/** default value from empty eeprom	*/
//		temp1 = VOLUME_MIN;	/** set useful value	*/

	set_volume(temp,temp);	/** set recalled volume value			*/
	get_volume(0,temp);		/** send volume setting to volume changing function	*/

}
コード例 #30
0
ファイル: esddsp.c プロジェクト: TravisKraatz/cinelerra
int
mixctl (int fd, request_t request, void *argp)
{
  static int esd = -1, player = -1;
  static int left, right;

  int *arg = (int *) argp;

  DPRINTF ("hijacking /dev/mixer ioctl, and sending it to esd "
	   "(%d : %x - %p)\n", fd, request, argp);

  switch (request)
    {
    case SOUND_MIXER_READ_DEVMASK:
      *arg = 5113;
      break;

    case SOUND_MIXER_READ_PCM:
      mix_init (&esd, &player);

      if (player > 0)
	{
	  esd_info_t *all_info;

	  all_info  = esd_get_all_info (esd);
	  if (all_info)
	    {
	      esd_player_info_t *player_info;

	      for (player_info = all_info->player_list; player_info;
		   player_info = player_info->next)
		if (player_info->source_id == player)
		  {
		    *arg = ESD_VOL_TO_OSS (player_info->left_vol_scale,
					   player_info->right_vol_scale);
		  }

	      esd_free_all_info (all_info);
	    }
	  else
	    return -1;
	}
      else
	{
          get_volume (&left, &right);
	  *arg = ESD_VOL_TO_OSS (left, right);
	}

      break;

    case SOUND_MIXER_WRITE_PCM:
      mix_init (&esd, &player);

      left  = OSS_VOL_TO_ESD_LEFT  (*arg);
      right = OSS_VOL_TO_ESD_RIGHT (*arg);

      set_volume (left, right);

      if (player > 0)
	{
	  DPRINTF ("panning %d - %d %d\n", player, left, right);
	  esd_set_stream_pan (esd, player, left, right);
	}

      break;

    default:
      DPRINTF ("unhandled /dev/mixer ioctl (%x - %p)\n", request, argp);
      break;
    }

  return 0;
}