mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-20 16:50:14 +00:00
fix smoothfade for osx.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6153 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
36
muted.c
36
muted.c
@@ -378,30 +378,46 @@ static float oldvol = 0;
|
|||||||
static float mutevol = 0;
|
static float mutevol = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __Darwin__
|
||||||
static int mutedlevel(int orig, int mutelevel)
|
static int mutedlevel(int orig, int mutelevel)
|
||||||
{
|
{
|
||||||
int l = orig >> 8;
|
int l = orig >> 8;
|
||||||
int r = orig & 0xff;
|
int r = orig & 0xff;
|
||||||
l = (float)(mutelevel) * (float)(l) / 100.0;
|
l = (float)(mutelevel) * (float)(l) / 100.0;
|
||||||
r = (float)(mutelevel) * (float)(r) / 100.0;
|
r = (float)(mutelevel) * (float)(r) / 100.0;
|
||||||
|
|
||||||
return (l << 8) | r;
|
return (l << 8) | r;
|
||||||
|
#else
|
||||||
|
static float mutedlevel(float orig, float mutelevel)
|
||||||
|
{
|
||||||
|
float master = orig;
|
||||||
|
master = mutelevel * master / 100.0;
|
||||||
|
return master;
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mute(void)
|
static void mute(void)
|
||||||
{
|
{
|
||||||
#ifndef __Darwin__
|
#ifndef __Darwin__
|
||||||
int vol;
|
int vol;
|
||||||
#else
|
|
||||||
float vol;
|
|
||||||
#endif
|
|
||||||
int start;
|
int start;
|
||||||
int x;
|
int x;
|
||||||
|
#else
|
||||||
|
float vol;
|
||||||
|
float start = 1.0;
|
||||||
|
float x;
|
||||||
|
#endif
|
||||||
vol = getvol();
|
vol = getvol();
|
||||||
oldvol = vol;
|
oldvol = vol;
|
||||||
if (smoothfade)
|
if (smoothfade)
|
||||||
|
#ifdef __Darwin__
|
||||||
|
start = mutelevel;
|
||||||
|
#else
|
||||||
start = 100;
|
start = 100;
|
||||||
else
|
else
|
||||||
start = mutelevel;
|
start = mutelevel;
|
||||||
|
#endif
|
||||||
for (x=start;x>=mutelevel;x-=stepsize) {
|
for (x=start;x>=mutelevel;x-=stepsize) {
|
||||||
mutevol = mutedlevel(vol, x);
|
mutevol = mutedlevel(vol, x);
|
||||||
setvol(mutevol);
|
setvol(mutevol);
|
||||||
@@ -423,23 +439,31 @@ static void unmute(void)
|
|||||||
{
|
{
|
||||||
#ifdef __Darwin__
|
#ifdef __Darwin__
|
||||||
float vol;
|
float vol;
|
||||||
|
float start;
|
||||||
|
float x;
|
||||||
#else
|
#else
|
||||||
int vol;
|
int vol;
|
||||||
#endif
|
|
||||||
int start;
|
int start;
|
||||||
int x;
|
int x;
|
||||||
|
#endif
|
||||||
vol = getvol();
|
vol = getvol();
|
||||||
if (debug)
|
if (debug)
|
||||||
#ifdef __Darwin__
|
#ifdef __Darwin__
|
||||||
printf("Unmute from '%f' (should be '%f') to '%f'!\n", vol, mutevol, oldvol);
|
printf("Unmute from '%f' (should be '%f') to '%f'!\n", vol, mutevol, oldvol);
|
||||||
|
mutevol = vol;
|
||||||
|
if (vol == mutevol) {
|
||||||
#else
|
#else
|
||||||
printf("Unmute from '%04x' (should be '%04x') to '%04x'!\n", vol, mutevol, oldvol);
|
printf("Unmute from '%04x' (should be '%04x') to '%04x'!\n", vol, mutevol, oldvol);
|
||||||
#endif
|
|
||||||
if ((int)vol == mutevol) {
|
if ((int)vol == mutevol) {
|
||||||
|
#endif
|
||||||
if (smoothfade)
|
if (smoothfade)
|
||||||
start = mutelevel;
|
start = mutelevel;
|
||||||
else
|
else
|
||||||
|
#ifdef __Darwin__
|
||||||
|
start = 1.0;
|
||||||
|
#else
|
||||||
start = 100;
|
start = 100;
|
||||||
|
#endif
|
||||||
for (x=start;x<100;x+=stepsize) {
|
for (x=start;x<100;x+=stepsize) {
|
||||||
mutevol = mutedlevel(oldvol, x);
|
mutevol = mutedlevel(oldvol, x);
|
||||||
setvol(mutevol);
|
setvol(mutevol);
|
||||||
|
|||||||
Reference in New Issue
Block a user