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

C++ snd_mixer_selem_get_playback_volume函数代码示例

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

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



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

示例1: balance_volumes

static void balance_volumes(void)
{
	struct control *control;
	long left, right;
	int err;

	control = get_focus_control(TYPE_PVOLUME | TYPE_CVOLUME);
	if (!control || !(control->flags & HAS_VOLUME_1))
		return;
	if (control->flags & TYPE_PVOLUME) {
		err = snd_mixer_selem_get_playback_volume(control->elem, control->volume_channels[0], &left);
		if (err < 0)
			return;
		err = snd_mixer_selem_get_playback_volume(control->elem, control->volume_channels[1], &right);
		if (err < 0)
			return;
	} else {
		err = snd_mixer_selem_get_capture_volume(control->elem, control->volume_channels[0], &left);
		if (err < 0)
			return;
		err = snd_mixer_selem_get_capture_volume(control->elem, control->volume_channels[1], &right);
		if (err < 0)
			return;
	}
	left = (left + right) / 2;
	if (control->flags & TYPE_PVOLUME) {
		snd_mixer_selem_set_playback_volume(control->elem, control->volume_channels[0], left);
		snd_mixer_selem_set_playback_volume(control->elem, control->volume_channels[1], left);
	} else {
		snd_mixer_selem_set_capture_volume(control->elem, control->volume_channels[0], left);
		snd_mixer_selem_set_capture_volume(control->elem, control->volume_channels[1], left);
	}
	display_controls();
}
开发者ID:Aceofzeroz,项目名称:android_kernel_asus_ze55xml,代码行数:34,代码来源:mixer_widget.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: 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


示例4: gam_slider_pan_get_volume

static gint
gam_slider_pan_get_volume (GamSliderPan *gam_slider_pan)
{
    glong left_chn, right_chn, pmin, pmax;

    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);

    if (snd_mixer_selem_has_playback_volume (gam_slider_get_elem (GAM_SLIDER (gam_slider_pan))))
        snd_mixer_selem_get_playback_volume (gam_slider_get_elem (GAM_SLIDER (gam_slider_pan)), SND_MIXER_SCHN_FRONT_LEFT, &left_chn);
    else
        snd_mixer_selem_get_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)))) {
        return rint (100 - (left_chn * (100 / (gfloat)pmax)));
    } else {
        if (snd_mixer_selem_has_playback_volume (gam_slider_get_elem (GAM_SLIDER (gam_slider_pan))))
            snd_mixer_selem_get_playback_volume (gam_slider_get_elem (GAM_SLIDER (gam_slider_pan)), SND_MIXER_SCHN_FRONT_RIGHT, &right_chn);
        else
            snd_mixer_selem_get_capture_volume (gam_slider_get_elem (GAM_SLIDER (gam_slider_pan)), SND_MIXER_SCHN_FRONT_RIGHT, &right_chn);

        return rint (100 - (MAX(left_chn, right_chn) * (100 / (gfloat)pmax)));
    }
}
开发者ID:GNOME,项目名称:gnome-alsamixer,代码行数:26,代码来源:gam-slider-pan.c


示例5: lamixer_volbox_show

void lamixer_volbox_show(VolBox *volumebox, snd_mixer_elem_t *elem, GtkWidget *mixerbox)
{
	long rangevalue_left,rangevalue_right;
	int mute, *bCols;

	if (volumebox->type == 1) {
		snd_mixer_selem_get_playback_volume (elem, SND_MIXER_SCHN_FRONT_LEFT, &rangevalue_left);
		bCols = &pCols;
	}
	else if (volumebox->type == 2) {
		snd_mixer_selem_get_capture_volume (elem, SND_MIXER_SCHN_FRONT_LEFT, &rangevalue_left);
		bCols = &cCols;
	}

	volumebox->curval = rangevalue_left;
	
	gtk_table_attach(GTK_TABLE(mixerbox), volumebox->vollabel, *bCols-1, *bCols, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
	
	gtk_range_set_value(GTK_RANGE(volumebox->volbar), rangevalue_left);
	gtk_box_pack_start(GTK_BOX(volumebox->volbarbox), volumebox->volbar, TRUE, TRUE, 0);

	volumebox->hsignalid = g_signal_connect(G_OBJECT(volumebox->volbar), "value-changed", G_CALLBACK(lamixer_volbox_changed), volumebox);

	if (volumebox->rvolbar != NULL) {
		if (volumebox->type == 1) {
			snd_mixer_selem_get_playback_volume (elem, SND_MIXER_SCHN_FRONT_RIGHT, &rangevalue_right);
		}
		else if (volumebox->type == 2) {
			snd_mixer_selem_get_capture_volume (elem, SND_MIXER_SCHN_FRONT_RIGHT, &rangevalue_right);
		}

		volumebox->rcurval = rangevalue_right;

		gtk_box_pack_start(GTK_BOX(volumebox->volbarbox), volumebox->rvolbar, TRUE, TRUE, 0);
		gtk_range_set_value(GTK_RANGE(volumebox->rvolbar), rangevalue_right);

		volumebox->hsignalidr = g_signal_connect(G_OBJECT(volumebox->rvolbar), "value-changed", G_CALLBACK(lamixer_volboxr_changed), volumebox);
	}

	gtk_table_attach(GTK_TABLE(mixerbox), volumebox->volbarbox, *bCols-1, *bCols, 1, 2, GTK_FILL | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0);

	if (volumebox->lockswitch != NULL) {
		gtk_table_attach(GTK_TABLE(mixerbox), volumebox->lockswitch, *bCols-1, *bCols, 2, 3, GTK_FILL | GTK_SHRINK, GTK_FILL | GTK_SHRINK, 0, 0);
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(volumebox->lockswitch), TRUE);
	}

	if (volumebox->muteswitch != NULL) {
		snd_mixer_selem_get_playback_switch (elem, SND_MIXER_SCHN_FRONT_LEFT, &mute);
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(volumebox->muteswitch), !mute);
		volumebox->hmutesignalid = g_signal_connect(G_OBJECT(volumebox->muteswitch), "toggled", G_CALLBACK(lamixer_muteswitch_changed), elem);
		gtk_table_attach(GTK_TABLE(mixerbox), volumebox->muteswitch, *bCols-1, *bCols, 3, 4, GTK_SHRINK, GTK_SHRINK, 0, 0);
	}
	
	gtk_table_resize(GTK_TABLE(mixerbox), mRows, ++(*bCols));
	gtk_table_attach(GTK_TABLE(mixerbox), gtk_vseparator_new (), *bCols-1, *bCols, 0, 5, GTK_FILL | GTK_SHRINK, GTK_FILL | GTK_SHRINK, 4, 0);
	gtk_table_resize(GTK_TABLE(mixerbox), mRows, ++(*bCols));
}
开发者ID:metsger,项目名称:lamixer,代码行数:57,代码来源:lamixer.c


示例6: snd_mixer_handle_events

int AlsaMixer::get_volume()
{
    int value;
    long left, right;
    snd_mixer_handle_events(this->handle);
    snd_mixer_selem_get_playback_volume(this->active_elem, LEFT, &left);
    snd_mixer_selem_get_playback_volume(this->active_elem, RIGHT, &right);
    value = (int)(((left + (right - left)/2)*100) / (this->max - this->min));
    return value;
}
开发者ID:darvid,项目名称:tudor-volumed,代码行数:10,代码来源:alsamixer.cpp


示例7: snd_mixer_handle_events

int AmeSystemSound::volume()
{
	if (!mixer_element)
		return 0;
	
	long l, r;
	snd_mixer_handle_events(mixer);
	snd_mixer_selem_get_playback_volume(mixer_element, SND_MIXER_SCHN_FRONT_LEFT, &l);
	snd_mixer_selem_get_playback_volume(mixer_element, SND_MIXER_SCHN_FRONT_RIGHT, &r);

	return (l+r)/2;
}
开发者ID:admiral0,项目名称:Antico-Deluxe,代码行数:12,代码来源:sound.cpp


示例8: alsa_mixer_get_volume

static int alsa_mixer_get_volume(int *l, int *r)
{
	long lv, rv;

	if (mixer_elem == NULL)
		return -1;
	snd_mixer_handle_events(alsa_mixer_handle);
	snd_mixer_selem_get_playback_volume(mixer_elem, SND_MIXER_SCHN_FRONT_LEFT, &lv);
	snd_mixer_selem_get_playback_volume(mixer_elem, SND_MIXER_SCHN_FRONT_RIGHT, &rv);
	*l = lv - mixer_vol_min;
	*r = rv - mixer_vol_min;
	return 0;
}
开发者ID:cojocar,项目名称:cmus-dbus,代码行数:13,代码来源:mixer_alsa.c


示例9: on_mixer_elem_event

static int on_mixer_elem_event(snd_mixer_elem_t *elem, unsigned int mask) {
  snd_mixer_selem_id_t *sid;
  void *data = NULL;

  if(elem)
    data = snd_mixer_elem_get_callback_private(elem);

  if(data) {
    long min, max, Rvol, Lvol;

    snd_mixer_selem_id_alloca(&sid);
    snd_mixer_selem_get_id(elem, sid);
    DEBUG("mixer elem control = %s, mask = %x, data = %x\n", snd_mixer_selem_id_get_name(sid), mask, data);
    if(mask & SND_CTL_EVENT_MASK_VALUE) {
      char path[1024] = {0};
      alsa_mixer_t *mixer = (alsa_mixer_t *)g_object_get_data(G_OBJECT(data), "mixer-obj");
      GtkWidget *img = (GtkWidget *)g_object_get_data(G_OBJECT(data), "image-obj");

      DEBUG("mixer = %x, img = %x\n", mixer, img);
      if(snd_mixer_selem_has_playback_volume(elem)) {
        if(mixer->pcm_muted != alsa_mixer_is_muted(elem, NULL)) {
          mixer->pcm_muted = !mixer->pcm_muted;
          g_snprintf(path, 1024, DVM_CONFIG_PATH"/%s", g_playback_iconset[mixer->pcm_muted ? 3: 0]);
          DEBUG("playback switch detected, image path = %s\n", path);
          gtk_image_set_from_file(GTK_IMAGE(img), path);
        }

        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);
        DEBUG("new val = %d, %d, min = %d, max = %d\n", Rvol, Lvol, min, max);
      } else if(snd_mixer_selem_has_capture_volume(elem)) {
        if(mixer->mic_muted != alsa_mixer_is_muted(elem, NULL)) {
          mixer->mic_muted = !mixer->mic_muted;
          g_snprintf(path, 1024, DVM_CONFIG_PATH"/%s", g_capture_iconset[mixer->mic_muted ? 3: 0]);
          DEBUG("capture switch detected, image path = %s\n", path);
          gtk_image_set_from_file(GTK_IMAGE(img), path);
        }

        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);
        DEBUG("new val = %d, %d, min = %d, max = %d\n", Rvol, Lvol, min, max);
      }
      g_mixer_ui_updated = TRUE;
      gtk_adjustment_set_value(GTK_ADJUSTMENT(data), ((gdouble)(Rvol+Lvol)*50)/(max-min));
    }
  }

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


示例10: qDebug

int AmeSystemSound::setupMixer(QString card, QString device)
{
    char *name;
    long int a, b;
    long alsa_min_vol = 0, alsa_max_vol = 100;
    int err, index;
    mixer_element = 0;

    qDebug("AmeSystemSound::SoundOutput: setupMixer()");

    if ((err = getMixer(&mixer, card)) < 0)
        return err;

    parseMixerName(device.toAscii().data(), &name, &index);

    mixer_element = getMixerElem(mixer, name, index);

    free(name);

    if (!mixer_element)
    {
        qWarning("SoundOutput: Failed to find mixer element");
        return -1;
    }

    /* This hack was copied from xmms.
     * Work around a bug in alsa-lib up to 1.0.0rc2 where the
     * new range don't take effect until the volume is changed.
     * This hack should be removed once we depend on Alsa 1.0.0.
     */
    snd_mixer_selem_get_playback_volume(mixer_element, SND_MIXER_SCHN_FRONT_LEFT, &a);
    snd_mixer_selem_get_playback_volume(mixer_element, SND_MIXER_SCHN_FRONT_RIGHT, &b);

    snd_mixer_selem_get_playback_volume_range(mixer_element,
            &alsa_min_vol, &alsa_max_vol);
    snd_mixer_selem_set_playback_volume_range(mixer_element, 0, 100);

    if (alsa_max_vol == 0)
    {
	mixer_element = NULL;
        return -1;
    }

    setVolume(a * 100 / alsa_max_vol);

    qDebug("SoundOutput: setupMixer() success");

    return 0;
}
开发者ID:admiral0,项目名称:Antico-Deluxe,代码行数:49,代码来源:sound.cpp


示例11: snd_mixer_selem_get_playback_volume

/**
 * Returns the currently set volume.
 *
 * @param   dfCard  [in]    get the volume directly from card?
 *
 * @return Volume in percent
 */
int MMSAudioCtrl::getVolume(bool dfCard) {
    long    lval, rval;
    int     retval = this->volume;

    if ((!this->muteFlag)||(dfCard)) {
        /* get the current volume settings */
        snd_mixer_selem_get_playback_volume(elem, SND_MIXER_SCHN_FRONT_LEFT, &lval);
        snd_mixer_selem_get_playback_volume(elem, SND_MIXER_SCHN_FRONT_RIGHT, &rval);
        if ((lval != this->xval)||(rval != this->xval))
            retval = (int)(((lval + (rval - lval) / 2) * 100) / (this->pmax - this->pmin));
        if (!this->muteFlag) this->volume = retval;
        return retval;
    }
    return this->volume;
}
开发者ID:RomTok,项目名称:disco-light,代码行数:22,代码来源:mmsaudioctrl.cpp


示例12: brightside_volume_alsa_get_volume

static int
brightside_volume_alsa_get_volume (BrightsideVolume *vol)
{
	BrightsideVolumeAlsa *self = (BrightsideVolumeAlsa *) vol;
	long lval, rval;
	int tmp;
	
	snd_mixer_selem_get_playback_volume(self->_priv->elem,
			SND_MIXER_SCHN_FRONT_LEFT, &lval);
	snd_mixer_selem_get_playback_volume(self->_priv->elem,
			SND_MIXER_SCHN_FRONT_RIGHT, &rval);

	tmp = brightside_volume_alsa_vol_check (self, (int) (lval + rval) / 2);
	return (tmp * 100 / self->_priv->pmax);
}
开发者ID:rswarbrick,项目名称:brightside,代码行数:15,代码来源:brightside-volume-alsa.c


示例13: snd_mixer_handle_events

VolumeSettings VolumeALSA::volume() const
{
    VolumeSettings vol;

    if(pcm_element)
    {
        long value = 0;
        snd_mixer_handle_events(m_mixer);
        snd_mixer_selem_get_playback_volume(pcm_element, SND_MIXER_SCHN_FRONT_LEFT, &value);
        vol.left = value;
        snd_mixer_selem_get_playback_volume(pcm_element, SND_MIXER_SCHN_FRONT_RIGHT, &value);
        vol.right = value;
    }
    return vol;
}
开发者ID:Greedysky,项目名称:qmmp,代码行数:15,代码来源:outputalsa.cpp


示例14: 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


示例15: 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


示例16: 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


示例17: mpg321_alsa_get_volume

long mpg321_alsa_get_volume(void)
{
	long volume;
	if(mixerelem)
	      	snd_mixer_selem_get_playback_volume(mixerelem,SND_MIXER_SCHN_FRONT_RIGHT,&volume);
	return volume;
}
开发者ID:Ledest,项目名称:mpg321,代码行数:7,代码来源:volume.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: 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


示例20: _get_volume

static void _get_volume(snd_mixer_elem_t *elem, int playback, int n, long *val)
{
	if (playback)
		snd_mixer_selem_get_playback_volume(elem, n, val);
	else
		snd_mixer_selem_get_capture_volume(elem, n, val);
}
开发者ID:pzanoni,项目名称:tray,代码行数:7,代码来源:mixer.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ snd_mixer_selem_get_playback_volume_range函数代码示例发布时间:2022-05-30
下一篇:
C++ snd_mixer_open函数代码示例发布时间: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