static void addvolume(struct mixer *mixer, float d) { checkvolume(mixer); mixer_setvolume(mixer, mixer->vol_l + d, mixer->vol_r + d); if (d > 0) mixer_setmute(mixer, false); }
static int fswalk1(Chan *c, char *name) { WIN32_FIND_DATA wfd; HANDLE h; wchar_t *p; Ufsinfo *uif; uif = c->aux; p = catpath(uif->path, name, nil); switch(pathtype(p)){ case TPATH_VOLUME: if(!checkvolume(p)){ free(p); return 0; } case TPATH_ROOT: c->qid = wfdtoqid(p, nil); break; case TPATH_FILE: if((h = FindFirstFile(p, &wfd)) == INVALID_HANDLE_VALUE){ free(p); return 0; } FindClose(h); c->qid = wfdtoqid(p, &wfd); break; } free(uif->path); uif->path = p; return 1; }
void mixer_setvolume(mixer_t *mixer, float l, float r) { checkvolume(mixer); // to check mute status and AO support for volume mixer->vol_l = av_clip(l, 0, 100); mixer->vol_r = av_clip(r, 0, 100); if (!mixer->ao || mixer->muted) return; setvolume_internal(mixer, mixer->vol_l, mixer->vol_r); }
void mixer_setmute(struct mixer *mixer, bool mute) { checkvolume(mixer); if (mute != mixer->muted) { if (!mixer->softvol && !mixer->muted_using_volume && ao_control( mixer->ao, AOCONTROL_SET_MUTE, &mute) == CONTROL_OK) { mixer->muted_using_volume = false; } else { setvolume_internal(mixer, mixer->vol_l*!mute, mixer->vol_r*!mute); mixer->muted_using_volume = mute; } mixer->muted = mute; mixer->muted_by_us = mute; } }
/* Called before uninitializing the audio output. The main purpose is to * turn off mute, in case it's a global/persistent setting which might * otherwise be left enabled even after this player instance exits. */ void mixer_uninit(struct mixer *mixer) { checkvolume(mixer); if (mixer->muted_by_us) { /* Current audio output API combines playing the remaining buffered * audio and uninitializing the AO into one operation, even though * ideally unmute would happen between those two steps. We can't do * volume changes after uninitialization, but we don't want the * remaining audio to play at full volume either. Thus this * workaround to drop remaining audio first. */ ao_reset(mixer->ao); mixer_setmute(mixer, false); /* We remember mute status and re-enable it if we play more audio * in the same process. */ mixer->muted_by_us = true; } mixer->ao = NULL; }
// Called after the audio filter chain is built or rebuilt. void mixer_reinit(struct mixer *mixer, struct ao *ao) { mixer->ao = ao; /* Use checkvolume() to see if softvol needs to be enabled because of * lacking AO support, but first store values it could overwrite. */ float left = mixer->vol_l, right = mixer->vol_r; bool muted = mixer->muted_by_us; checkvolume(mixer); /* Try to avoid restoring volume stored from one control method with * another. Especially, restoring softvol volume (typically high) on * system mixer could have very nasty effects. */ const char *restore_reason = mixer->softvol ? "softvol" : mixer->ao->driver->info->short_name; if (mixer->restore_volume && !strcmp(mixer->restore_volume, restore_reason)) mixer_setvolume(mixer, left, right); /* We turn mute off at AO uninit, so it has to be restored (unless * we're reinitializing filter chain while keeping AO); but we only * enable mute, not turn external mute off. */ if (muted) mixer_setmute(mixer, true); if (mixer->balance != 0) mixer_setbalance(mixer, mixer->balance); }
void mixer_getvolume(mixer_t *mixer, float *l, float *r) { checkvolume(mixer); *l = mixer->vol_l; *r = mixer->vol_r; }
bool mixer_getmute(struct mixer *mixer) { checkvolume(mixer); return mixer->muted; }