diff options
author | ranma <ranma@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-11-24 23:13:15 +0000 |
---|---|---|
committer | ranma <ranma@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-11-24 23:13:15 +0000 |
commit | 422acb829c967462e4f39da5b05741c30e548ff7 (patch) | |
tree | ad6c0ca46b411dea8720c3514cd5e57f54c0a714 /libao2 | |
parent | fe4ceedf5fff69b0bac664f175cf8b18258bd793 (diff) |
Implement volume setting functionality,
original patch by Nguyen Kim <nguyenk@ie2.u-psud.fr>.
Note that volume changing never worked on my system with NAS, but
that seems to be a nasd problem which I did not try to track down yet...
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@8273 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libao2')
-rw-r--r-- | libao2/ao_nas.c | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/libao2/ao_nas.c b/libao2/ao_nas.c index 1b22f1254b..a558d74e50 100644 --- a/libao2/ao_nas.c +++ b/libao2/ao_nas.c @@ -333,8 +333,53 @@ static unsigned int nas_aformat_to_auformat(unsigned int *format) } // to set/get/query special features/parameters -static int control(int cmd,int arg){ - return -1; +static int control(int cmd, int arg) +{ + AuDeviceAttributes *dattr; + AuFixedPoint fpgain; + AuStatus as; + int gain; + ao_control_vol_t *vol = (ao_control_vol_t *)arg; + + dattr = AuGetDeviceAttributes(nas_data->aud, nas_data->dev, &as); + if (as != AuSuccess) { + nas_print_error(nas_data->aud, + "control(): AuGetDeviceAttributes", as); + return CONTROL_ERROR; + } + gain = AuFixedPointRoundDown(AuDeviceGain(dattr)); + // kn: 0 <= gain <= 100 + + switch (cmd) { + case AOCONTROL_GET_VOLUME: + + vol->right = (float) gain; + vol->left = vol->right; + + return CONTROL_OK; + + case AOCONTROL_SET_VOLUME: + /* + * kn: we should have vol->left == vol->right but i don't + * know if something can change it outside of ao_nas + * so i take the mean of both values. + */ + gain = (int) ((vol->left+vol->right)/2); + + fpgain = AuFixedPointFromSum(gain, 0); + AuDeviceGain(dattr) = fpgain; + AuSetDeviceAttributes(nas_data->aud, nas_data->dev, + AuCompDeviceGainMask, dattr, &as); + if (as != AuSuccess) { + nas_print_error(nas_data->aud, + "control(): AuSetDeviceAttributes", as); + return CONTROL_ERROR; + } + return CONTROL_OK; + + default: + return CONTROL_UNKNOWN; + }; } // open & setup audio device |