• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ snd_mixer_selem_get_playback_volume_range函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中snd_mixer_selem_get_playback_volume_range函数的典型用法代码示例。如果您正苦于以下问题:C++ snd_mixer_selem_get_playback_volume_range函数的具体用法?C++ snd_mixer_selem_get_playback_volume_range怎么用?C++ snd_mixer_selem_get_playback_volume_range使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了snd_mixer_selem_get_playback_volume_range函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: elem_set_vol_percent

static void elem_set_vol_percent(snd_mixer_elem_t *elem, int vol_percent)
{
	int i;
	long pmin, pmax, value;
	
	//sdbg("%s: set mixer element volume\n", __func__);
	for (i = 0; i <= SND_MIXER_SCHN_LAST; i++) {
		if (snd_mixer_selem_has_playback_channel(elem, i) && 
				!snd_mixer_selem_has_common_volume(elem)) {
			snd_mixer_selem_get_playback_volume_range(elem, &pmin, &pmax);
		/* playback volume */
			if (snd_mixer_selem_has_playback_volume(elem)) {
				value = (int)rint((double)pmin + 0.01 * vol_percent * ((double)pmax - (double)pmin));
				snd_mixer_selem_set_playback_volume(elem, i, value);
			}
		} else if (snd_mixer_selem_has_capture_channel(elem, i) && 
				!snd_mixer_selem_has_common_volume(elem)) {
		/* capture volume */
			snd_mixer_selem_get_capture_volume_range(elem, &pmin, &pmax);
			if (snd_mixer_selem_has_capture_volume(elem)) {
				value = (int)rint((double)pmin + 0.01 * vol_percent * ((double)pmax - (double)pmin));
				snd_mixer_selem_set_capture_volume(elem, i, value);
			}
		} else {
		/* Misc. ex: Boost */
			snd_mixer_selem_get_playback_volume_range(elem, &pmin, &pmax);
			value = (int)rint((double)pmin + 0.01 * vol_percent * ((double)pmax - (double)pmin));
			snd_mixer_selem_set_playback_volume(elem, i, value);

			snd_mixer_selem_get_capture_volume_range(elem, &pmin, &pmax);
			value = (int)rint((double)pmin + 0.01 * vol_percent * ((double)pmax - (double)pmin));
			snd_mixer_selem_set_capture_volume(elem, i, value);
		}
	}
}
开发者ID:daneshih1125,项目名称:sound,代码行数:35,代码来源:sound.c


示例2: elem_get_vol_percent

static int elem_get_vol_percent(snd_mixer_elem_t *elem)
{
	int i, percent; 
	long pmin, pmax, volume;

	for (i = 0; i <= SND_MIXER_SCHN_LAST; i++) {
		/* playback volume */
		if (snd_mixer_selem_has_playback_channel(elem, i) && 
				!snd_mixer_selem_has_common_volume(elem)) {
			snd_mixer_selem_get_playback_volume_range(elem, &pmin, &pmax);
			if (snd_mixer_selem_has_playback_volume(elem))
				snd_mixer_selem_get_playback_volume(elem, i, &volume);

		}
		/* capture volume */
		else if (snd_mixer_selem_has_capture_channel(elem, i) && 
				!snd_mixer_selem_has_common_volume(elem)) {
			snd_mixer_selem_get_capture_volume_range(elem, &pmin, &pmax);
			if (snd_mixer_selem_has_capture_volume(elem))
				snd_mixer_selem_get_capture_volume(elem, i, &volume);
		} else {
		/* Misc. ex: Boost */
			snd_mixer_selem_get_playback_volume_range(elem, &pmin, &pmax);
			snd_mixer_selem_get_playback_volume(elem, i, &volume);
		}
	}

	percent = (int) ((double)(volume - pmin) / (double)(pmax - pmin) * 100);

	return percent;
}
开发者ID:daneshih1125,项目名称:sound,代码行数:31,代码来源:sound.c


示例3: set_volume

void set_volume(GtkAdjustment *adjustment, gpointer user_data)
{
  int value = (int) 100 - gtk_adjustment_get_value(adjustment);
  g_debug("Setting master volume to: %d", value);

  if(value == 0)
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(s_mute), TRUE);
  else
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(s_mute), FALSE);

  long min, max;
  snd_mixer_t *mix;
  snd_mixer_selem_id_t *sid;
  const char *card = "default";
  const char *selem_name = "Master";

  snd_mixer_open(&mix, 0);
  snd_mixer_attach(mix, card);
  snd_mixer_selem_register(mix, NULL, NULL);
  snd_mixer_load(mix);

  snd_mixer_selem_id_alloca(&sid);
  snd_mixer_selem_id_set_index(sid, 0);
  snd_mixer_selem_id_set_name(sid, selem_name);
  snd_mixer_elem_t* elem = snd_mixer_find_selem(mix, sid);

  snd_mixer_selem_get_playback_volume_range(elem, &min, &max);
  snd_mixer_selem_set_playback_volume_all(elem, value * max / 100);

  snd_mixer_close(mix);

}
开发者ID:tom2901,项目名称:desktop,代码行数:32,代码来源:volume.c


示例4: _j4status_alsa_section_elem_callback

static gint
_j4status_alsa_section_elem_callback(snd_mixer_elem_t *elem, guint mask)
{
    J4statusAlsaSection *section = snd_mixer_elem_get_callback_private(elem);
    if ( mask == SND_CTL_EVENT_MASK_REMOVE )
        return 0;

    if ( mask & SND_CTL_EVENT_MASK_INFO )
    {
        glong min, max;
        int error;
        error = snd_mixer_selem_get_playback_dB_range(elem, &min, &max);
        if ( ( error == 0 ) && ( min < max ) )
            section->use_dB = TRUE;
        else
        {
            section->use_dB = FALSE;
            snd_mixer_selem_get_playback_volume_range(elem, &min, &max);
        }
        section->min = min;
        section->max = max;
    }

    if ( mask & SND_CTL_EVENT_MASK_VALUE )
        _j4status_alsa_section_update(section, elem);

    return 0;
}
开发者ID:j4tools,项目名称:j4status-plugins,代码行数:28,代码来源:alsa.c


示例5: get_volume

/**
 *  @brief Get the Volume for the master channel.
 *
 *    This function uses the Alsa API to get the volume
 *    for the master channel.
 *
 *  @param [out] ptr pointer to long, output will be between 0 and 99.
 *  @return Void.
 */
void get_volume(long *ptr){
  long min, max;
  snd_mixer_t *handle;
  snd_mixer_selem_id_t *sid;
  const char *card = "default";
  //const char *selem_name = "Master";
  const char *selem_name = "DAC2 Digital Course";

  snd_mixer_open(&handle, 0);
  snd_mixer_attach(handle, card);
  snd_mixer_selem_register(handle, NULL, NULL);
  snd_mixer_load(handle);

  snd_mixer_selem_id_alloca(&sid);
  snd_mixer_selem_id_set_index(sid, 0);
  snd_mixer_selem_id_set_name(sid, selem_name);
  snd_mixer_elem_t* elem = snd_mixer_find_selem(handle, sid);

  snd_mixer_selem_get_playback_volume_range(elem, &min, &max);
  printd("Volume range <%lu,%lu>\n", min, max);
  snd_mixer_selem_get_playback_volume(elem,0,ptr);
  printd("volume val = %lu\n",*ptr);
  *ptr /= (max / 100);
  snd_mixer_close(handle);
}
开发者ID:jsleeman,项目名称:Embedded-Group-Work,代码行数:34,代码来源:volume.c


示例6: snd_mixer_open

char *getvolume() {
    char *buf;
    int active;
    long volume, min, max;
    snd_mixer_t *handle;
    snd_mixer_selem_id_t *sid;
    snd_mixer_elem_t* elem;
    const char *card = "default";
    const char *selem_name = "Master";

    snd_mixer_open(&handle, 0);
    snd_mixer_attach(handle, card);
    snd_mixer_selem_register(handle, NULL, NULL);
    snd_mixer_load(handle);

    snd_mixer_selem_id_alloca(&sid);
    snd_mixer_selem_id_set_index(sid, 0);
    snd_mixer_selem_id_set_name(sid, selem_name);
    elem = snd_mixer_find_selem(handle, sid);

    snd_mixer_selem_get_playback_volume_range(elem, &min, &max);
    snd_mixer_selem_get_playback_volume(elem, SND_MIXER_SCHN_FRONT_LEFT, &volume);
    snd_mixer_selem_get_playback_switch(elem, SND_MIXER_SCHN_FRONT_LEFT, &active);

    buf = xmalloc(10);
    if (active)
        snprintf(buf, 10, "%0.f%%", (double) volume / (double) max * 100);
    else
        snprintf(buf, 10, "off");

    snd_mixer_close(handle);

    return buf;
}
开发者ID:poljar,项目名称:sucktus,代码行数:34,代码来源:sucktus.c


示例7: volume_up

int volume_up(int vol_min, int vol_max)
{
    long min, max;
    snd_mixer_t *handle;
    snd_mixer_selem_id_t *sid;
    const char *card = "default";
    const char *selem_name = "Master";


    snd_mixer_open(&handle, 0);
    snd_mixer_attach(handle, card);
    snd_mixer_selem_register(handle, NULL, NULL);
    snd_mixer_load(handle);

    snd_mixer_selem_id_alloca(&sid);
    snd_mixer_selem_id_set_index(sid, 0);
    snd_mixer_selem_id_set_name(sid, selem_name);
    snd_mixer_elem_t* elem = snd_mixer_find_selem(handle, sid);

    snd_mixer_selem_get_playback_volume_range(elem, &min, &max);
    
    for (int i = vol_min; i<vol_max; i++) {
      
      int v = i*max /100;
      snd_mixer_selem_set_playback_volume_all(elem, v);
      //printf("min = %d, max= %d, volume = %d\n", min, max, volume);
      usleep(50000);
    }
    snd_mixer_close(handle);
}
开发者ID:alg0hm,项目名称:7x7,代码行数:30,代码来源:volume.c


示例8: volume_set

int volume_set(int volume)
{
    long min, max;
    snd_mixer_t *handle;
    snd_mixer_selem_id_t *sid;
    const char *card = "default";
    //const char *selem_name = "Master";
    const char *selem_name = "Digital";


    snd_mixer_open(&handle, 0);
    snd_mixer_attach(handle, card);
    snd_mixer_selem_register(handle, NULL, NULL);
    snd_mixer_load(handle);

    snd_mixer_selem_id_alloca(&sid);
    snd_mixer_selem_id_set_index(sid, 0);
    snd_mixer_selem_id_set_name(sid, selem_name);
    snd_mixer_elem_t* elem = snd_mixer_find_selem(handle, sid);

    snd_mixer_selem_get_playback_volume_range(elem, &min, &max);
    
      
    int v = volume*max /100;
    snd_mixer_selem_set_playback_volume_all(elem, v);
    snd_mixer_close(handle);
    return v;
}
开发者ID:alg0hm,项目名称:7x7,代码行数:28,代码来源:volume.c


示例9: get_volume_indexed

static PxVolume get_volume_indexed(PxDev *dev, int i, int playback)
{
   snd_mixer_elem_t *elem;
   long vol, min, max;

   if (!dev->handle) {
      return 0.0;
   }

   if (i < 0 || i > dev->numselems) {
      return 0.0;
   }

   elem = dev->selems[i].elem;
   if (playback) {
      snd_mixer_selem_get_playback_volume_range(elem, &min, &max);
      if (snd_mixer_selem_has_playback_channel(elem, SND_MIXER_SCHN_FRONT_LEFT)) {
         snd_mixer_selem_get_playback_volume(elem, SND_MIXER_SCHN_FRONT_LEFT, &vol);
         return (PxVolume) vol / (max - min);
      }
   }
   else {
      snd_mixer_selem_get_capture_volume_range(elem, &min, &max);
      if (snd_mixer_selem_has_capture_channel(elem, SND_MIXER_SCHN_FRONT_LEFT)) {
         snd_mixer_selem_get_capture_volume(elem, SND_MIXER_SCHN_FRONT_LEFT, &vol);
         return (PxVolume) vol / (max - min);
      }
   }
   
   return 0.0;
}
开发者ID:andreipaga,项目名称:audacity,代码行数:31,代码来源:px_linux_alsa.c


示例10: get_master_volume

static long get_master_volume()
{
    snd_mixer_t *handle;
    snd_mixer_open(&handle, 0);
    snd_mixer_attach(handle, Y50_CTL_NAME);
    snd_mixer_selem_register(handle, NULL, NULL);
    snd_mixer_load(handle);

    snd_mixer_selem_id_t *master_sid;
    const char *master_selem_name = "Master";

    snd_mixer_selem_id_alloca(&master_sid);
    snd_mixer_selem_id_set_index(master_sid, 0);
    snd_mixer_selem_id_set_name(master_sid, master_selem_name);
    snd_mixer_elem_t* elem = snd_mixer_find_selem(handle, master_sid);

    long min, max;
    snd_mixer_selem_get_playback_volume_range(elem, &min, &max);

    long volume;
    snd_mixer_selem_get_playback_volume(elem, SND_MIXER_SCHN_MONO, &volume);

    snd_mixer_close(handle);

    return volume * 100 / max;
}
开发者ID:polter-rnd,项目名称:y50-subwoofer,代码行数:26,代码来源:y50-subwoofer.c


示例11: min

SIDInfo::SIDInfo(snd_mixer_t* handle, snd_mixer_selem_id_t* sid) :
	min(0), max(0), globalMax(0), hasMute(false), hasVolume(false),
	_isEmulMuted(false), _lastVol(0), _handle(handle), _sid(sid)
{
	if (!_sid) return;

	snd_mixer_elem_t *elem;

	elem = snd_mixer_find_selem(_handle, _sid);

	if (!elem) return;

	if (snd_mixer_selem_has_playback_volume(elem))
	{
		snd_mixer_selem_get_playback_volume_range(elem, &min, &max);

		if (max > min) hasVolume = true;
		else min = max = 0;
	}

	_lastVol = min;

	if (snd_mixer_selem_has_playback_switch(elem))
	{
		hasMute = true;
	}
}
开发者ID:BackupTheBerlios,项目名称:lapsus-svn,代码行数:27,代码来源:alsa_mixer.cpp


示例12: alsa_mixer_is_muted

static gboolean alsa_mixer_is_muted(snd_mixer_elem_t *elem, gboolean *need_reset) {
  int sw;
  long Rvol, Lvol, min, max;

  if(need_reset)
    *need_reset = FALSE;

  /**if switch is available, get switch status directly*/
  if(snd_mixer_selem_has_playback_switch(elem)) {
    snd_mixer_selem_get_playback_switch(elem, 0, &sw);
    return sw ? FALSE: TRUE;
  } else if(snd_mixer_selem_has_capture_switch(elem)) {
    snd_mixer_selem_get_capture_switch(elem, 0, &sw);
    return sw ? FALSE: TRUE;
  }

  if(snd_mixer_selem_has_playback_volume(elem)) {
    snd_mixer_selem_get_playback_volume(elem, 0, &Rvol);
    snd_mixer_selem_get_playback_volume(elem, 1, &Lvol);
    snd_mixer_selem_get_playback_volume_range(elem, &min, &max);
    if(need_reset)
      *need_reset = !!(max - Rvol);
    return (Rvol + Lvol) ? FALSE: TRUE;
  } else if(snd_mixer_selem_has_capture_volume(elem)) {
    snd_mixer_selem_get_capture_volume_range(elem, &min, &max);
    snd_mixer_selem_get_capture_volume(elem, 0, &Rvol);
    snd_mixer_selem_get_capture_volume(elem, 1, &Lvol);
    if(need_reset)
      *need_reset = !!(max - Rvol);
    return (Rvol + Lvol) ? FALSE: TRUE;
  }
}
开发者ID:wuruxu,项目名称:golc,代码行数:32,代码来源:gtkalsamixer.c


示例13: alsa_mixer_set_muted

static int alsa_mixer_set_muted(snd_mixer_elem_t *elem, gboolean muted) {
  long val, min, max;

  /**if switch is available, get switch status directly*/
  if(snd_mixer_selem_has_playback_switch(elem)) {
    snd_mixer_selem_set_playback_switch(elem, 0, !muted);
    snd_mixer_selem_set_playback_switch(elem, 1, !muted);
    return 0;
  } else if(snd_mixer_selem_has_capture_switch(elem)) {
    snd_mixer_selem_set_capture_switch(elem, 0, !muted);
    snd_mixer_selem_set_capture_switch(elem, 1, !muted);
    return 0;
  }

  if(snd_mixer_selem_has_playback_volume(elem)) {
    snd_mixer_selem_get_playback_volume_range(elem, &min, &max);
    val = muted ? min : max;
    snd_mixer_selem_set_playback_volume(elem, 0, val);
    snd_mixer_selem_set_playback_volume(elem, 1, val);
    return 0;
  } else if(snd_mixer_selem_has_capture_volume(elem)) {
    snd_mixer_selem_get_capture_volume_range(elem, &min, &max);
    val = muted ? min : max;
    snd_mixer_selem_set_capture_volume(elem, 0, val);
    snd_mixer_selem_set_capture_volume(elem, 1, val);
    return 0;
  }

  return -1;
}
开发者ID:wuruxu,项目名称:golc,代码行数:30,代码来源:gtkalsamixer.c


示例14: set_volume

void set_volume(int vol)
{
	long min, max;
	snd_mixer_t *handlev;
	snd_mixer_selem_id_t *sid;
	const char *card = "default";
	const char *selem_name = "Master";

	if (vol < 1 || vol > 100) {
		printf("ERROR: Volume out of range [0,100] %%\n");
		printf("\tSetting volume to 50%%...\n");
		vol = 50;
	}

	snd_mixer_open(&handlev, 0);
	snd_mixer_attach(handlev, card);
	snd_mixer_selem_register(handlev, NULL, NULL);
	snd_mixer_load(handlev);

	snd_mixer_selem_id_alloca(&sid);
	snd_mixer_selem_id_set_index(sid, 0);
	snd_mixer_selem_id_set_name(sid, selem_name);
	snd_mixer_elem_t *elem = snd_mixer_find_selem(handlev, sid);

	snd_mixer_selem_get_playback_volume_range(elem, &min, &max);
	snd_mixer_selem_set_playback_volume_all(elem, vol * max / 100 + min);

	snd_mixer_close(handlev);
}
开发者ID:ivan-gomez,项目名称:drivers-gdl,代码行数:29,代码来源:player.c


示例15: toggle_volume

/* Volume toggler between 0 <--> element default volume.
 * Now excepts new_vol to be in default hardware range of the sound card in use. */
void toggle_volume(
        struct sound_profile* sp,
        long int const new_vol, // If INT_MAX or negative then toggle to sound
                                // profiles default volume
        enum Volume_type volume_type)
{
    // TODO: USE "avolt" SEMAPHORE

    long int current_vol;
    get_vol(sp->volume_cntrl_mixer_element, hardware, &current_vol);
    long int min, _;
    snd_mixer_selem_get_playback_volume_range(sp->volume_cntrl_mixer_element, &min, &_);

    // If current volume is lowest possible
    if (current_vol == min) {
        if (new_vol > 0 && new_vol != INT_MAX)
            set_vol(sp->volume_cntrl_mixer_element, volume_type, new_vol, 0);
        else
            set_vol(sp->volume_cntrl_mixer_element, sp->volume_type, sp->default_volume, 0);
    }
    else {
        // Else zero current volume
        set_vol(sp->volume_cntrl_mixer_element, hardware_percentage, 0, 0);
    }
    return;
}
开发者ID:wor,项目名称:avolt,代码行数:28,代码来源:volume_change.c


示例16: snd_card_get_index

mixerVolume::mixerVolume(const char *name, const char *card, long volume) {
	snd_mixer_selem_id_t *sid = NULL;
	elem = NULL;
	handle = NULL;
	min = 0;
	max = 100;
	char cardId[10];

	if (!name || !card)
		return;

	int cx = snd_card_get_index(card);
	if (cx < 0 || cx > 31)
		return;
	snprintf(cardId, sizeof(cardId), "hw:%i", cx);

	if (0 > snd_mixer_open(&handle, 0))
		return;
	if (0 > snd_mixer_attach(handle, cardId))
		return;
	if (0 > snd_mixer_selem_register(handle, NULL, NULL))
		return;
	if (0 > snd_mixer_load(handle))
		return;
	snd_mixer_selem_id_alloca(&sid);
	if (!sid)
		return;
	snd_mixer_selem_id_set_index(sid, 0);
	snd_mixer_selem_id_set_name(sid, name);
	elem = snd_mixer_find_selem(handle, sid);
	if (elem) {
		snd_mixer_selem_get_playback_volume_range(elem, &min, &max);
		setVolume(volume);
	}
}
开发者ID:FFTEAM,项目名称:DDT-libstb-hal-cst-next,代码行数:35,代码来源:audio_mixer.cpp


示例17: snd_mixer_selem_id_malloc

static snd_mixer_elem_t *alsa_init_mixer_channel (const char *name,
		long *vol_min, long *vol_max)
{
	snd_mixer_selem_id_t *sid;
	snd_mixer_elem_t *elem = NULL;
	
	snd_mixer_selem_id_malloc (&sid);
	snd_mixer_selem_id_set_index (sid, 0);
	snd_mixer_selem_id_set_name (sid, name);

	if (!(elem = snd_mixer_find_selem(mixer_handle, sid)))
		error ("Can't find mixer %s", name);
	else if (!snd_mixer_selem_has_playback_volume(elem)) {
		error ("Mixer device has no playback volume (%s).", name);
		elem = NULL;
	}
	else {
		snd_mixer_selem_get_playback_volume_range (elem, vol_min,
				vol_max);
		logit ("Opened mixer (%s), volume range: %ld-%ld", name,
				*vol_min, *vol_max);
	}

	snd_mixer_selem_id_free (sid);

	return elem;
}
开发者ID:ecthiender,项目名称:mocp-git,代码行数:27,代码来源:alsa.c


示例18: snd_mixer_open

char *get_vol(char *buf) {
	long max = 0, min = 0, vol = 0;
	int mute = 0;

	snd_mixer_t *handle;
	snd_mixer_elem_t *pcm_mixer, *mas_mixer;
	snd_mixer_selem_id_t *vol_info, *mute_info;

	snd_mixer_open(&handle, 0);
	snd_mixer_attach(handle, "default");
	snd_mixer_selem_register(handle, NULL, NULL);
	snd_mixer_load(handle);
	snd_mixer_selem_id_malloc(&vol_info);
	snd_mixer_selem_id_malloc(&mute_info);
	snd_mixer_selem_id_set_name(vol_info, VOL_CH);
	snd_mixer_selem_id_set_name(mute_info, VOL_CH);
	pcm_mixer = snd_mixer_find_selem(handle, vol_info);
	mas_mixer = snd_mixer_find_selem(handle, mute_info);
	snd_mixer_selem_get_playback_volume_range((snd_mixer_elem_t *)pcm_mixer, &min, &max);
	snd_mixer_selem_get_playback_volume((snd_mixer_elem_t *)pcm_mixer, SND_MIXER_SCHN_MONO, &vol);
	snd_mixer_selem_get_playback_switch(mas_mixer, SND_MIXER_SCHN_MONO, &mute);
	sprintf(buf, !(mute) ? VOL_MUTE_S : VOL_S, (int)vol * 100 / (int)max);
	if(vol_info)
		snd_mixer_selem_id_free(vol_info);
	if(mute_info)
		snd_mixer_selem_id_free(mute_info);
	if(handle)
		snd_mixer_close(handle);
	return buf;
}
开发者ID:SushiDesu,项目名称:dwmstat,代码行数:30,代码来源:dwmstat.c


示例19: setvol

/**
 * Adjusts the current volume and sends a notification (if enabled).
 *
 * @param vol new volume value
 * @param dir select direction (-1 = accurate or first bellow, 0 = accurate,
 * 1 = accurate or first above)
 * @param notify whether to send notification
 * @return 0 on success otherwise negative error code
 */
int
setvol(int vol, int dir, gboolean notify)
{
    long min = 0, max = 0, value;
    int cur_perc = getvol();
    double dvol = 0.01 * vol;

    int err = snd_mixer_selem_get_playback_dB_range(elem, &min, &max);
    if (err < 0 || min >= max || !normalize_vol()) {
        err = snd_mixer_selem_get_playback_volume_range(elem, &min, &max);
        value = lrint_dir(dvol * (max - min), dir) + min;
        snd_mixer_selem_set_playback_volume_all(elem, value);
        if (enable_noti && notify && cur_perc != getvol())
            do_notify_volume(getvol(), FALSE);
        // intentionally set twice
        return snd_mixer_selem_set_playback_volume_all(elem, value);
    }

    if (use_linear_dB_scale(min, max)) {
        value = lrint_dir(dvol * (max - min), dir) + min;
        return snd_mixer_selem_set_playback_dB_all(elem, value, dir);
    }

    if (min != SND_CTL_TLV_DB_GAIN_MUTE) {
        double min_norm = exp10((min - max) / 6000.0);
        dvol = dvol * (1 - min_norm) + min_norm;
    }

    value = lrint_dir(6000.0 * log10(dvol), dir) + max;
    snd_mixer_selem_set_playback_dB_all(elem, value, dir);
    if (enable_noti && notify && cur_perc != getvol())
        do_notify_volume(getvol(), FALSE);
    // intentionally set twice
    return snd_mixer_selem_set_playback_dB_all(elem, value, dir);
}
开发者ID:aarizkuren,项目名称:pnmixer,代码行数:44,代码来源:alsa.c


示例20: gam_slider_pan_update_volume

static void
gam_slider_pan_update_volume (GamSliderPan *gam_slider_pan)
{
    GamSliderPanPrivate *priv;

    gint left_chn = 0, right_chn = 0;
    glong pmin, pmax;

    priv = GAM_SLIDER_PAN_GET_PRIVATE (gam_slider_pan);

    if (snd_mixer_selem_has_playback_volume (gam_slider_get_elem (GAM_SLIDER (gam_slider_pan))))
        snd_mixer_selem_get_playback_volume_range (gam_slider_get_elem (GAM_SLIDER (gam_slider_pan)), &pmin, &pmax);
    else
        snd_mixer_selem_get_capture_volume_range (gam_slider_get_elem (GAM_SLIDER (gam_slider_pan)), &pmin, &pmax);

    left_chn = right_chn = rint ((100 - GTK_ADJUSTMENT (priv->vol_adjustment)->value) / (100 / (gfloat)pmax));

    if (!snd_mixer_selem_is_playback_mono (gam_slider_get_elem (GAM_SLIDER (gam_slider_pan)))) {
        if (GTK_ADJUSTMENT (priv->pan_adjustment)->value < 0) {
            right_chn = rint (left_chn - ((gfloat)ABS(GTK_ADJUSTMENT (priv->pan_adjustment)->value) / 100) * left_chn);
        } else if (GTK_ADJUSTMENT (priv->pan_adjustment)->value > 0) {
            left_chn = rint (right_chn - ((gfloat)GTK_ADJUSTMENT (priv->pan_adjustment)->value / 100) * right_chn);
        }
    }

    if (snd_mixer_selem_has_playback_volume (gam_slider_get_elem (GAM_SLIDER (gam_slider_pan)))) {
        snd_mixer_selem_set_playback_volume (gam_slider_get_elem (GAM_SLIDER (gam_slider_pan)), SND_MIXER_SCHN_FRONT_LEFT, left_chn);
        if (!snd_mixer_selem_is_playback_mono (gam_slider_get_elem (GAM_SLIDER (gam_slider_pan))))
            snd_mixer_selem_set_playback_volume (gam_slider_get_elem (GAM_SLIDER (gam_slider_pan)), SND_MIXER_SCHN_FRONT_RIGHT, right_chn);
    } else {
        snd_mixer_selem_set_capture_volume (gam_slider_get_elem (GAM_SLIDER (gam_slider_pan)), SND_MIXER_SCHN_FRONT_LEFT, left_chn);
        if (!snd_mixer_selem_is_playback_mono (gam_slider_get_elem (GAM_SLIDER (gam_slider_pan))))
            snd_mixer_selem_set_capture_volume (gam_slider_get_elem (GAM_SLIDER (gam_slider_pan)), SND_MIXER_SCHN_FRONT_RIGHT, right_chn);
    }
}
开发者ID:GNOME,项目名称:gnome-alsamixer,代码行数:35,代码来源:gam-slider-pan.c



注:本文中的snd_mixer_selem_get_playback_volume_range函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ snd_mixer_selem_id_set_name函数代码示例发布时间:2022-05-30
下一篇:
C++ snd_mixer_selem_get_playback_volume函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap