本文整理汇总了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函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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;
}
示例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;
}
}
示例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)));
}
}
示例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));
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}