summaryrefslogtreecommitdiffstats
path: root/libao2/ao_macosx.c
diff options
context:
space:
mode:
authorulion <ulion@b3059339-0415-0410-9bf9-f77b7e298cf2>2007-11-11 02:54:57 +0000
committerulion <ulion@b3059339-0415-0410-9bf9-f77b7e298cf2>2007-11-11 02:54:57 +0000
commit8fef9b88207c575626057329ef164ecfcb70ddfb (patch)
treed6271e04919f5320d4c8305ca35ef9db41958d3c /libao2/ao_macosx.c
parentd0f85146baaba44f77c00e33e75d615c6c5e7f3d (diff)
downloadmpv-8fef9b88207c575626057329ef164ecfcb70ddfb.tar.bz2
mpv-8fef9b88207c575626057329ef164ecfcb70ddfb.tar.xz
Support mute when passthrough to digital output.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25018 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libao2/ao_macosx.c')
-rw-r--r--libao2/ao_macosx.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/libao2/ao_macosx.c b/libao2/ao_macosx.c
index e22b648938..5ac0dd3e68 100644
--- a/libao2/ao_macosx.c
+++ b/libao2/ao_macosx.c
@@ -77,6 +77,7 @@ typedef struct ao_macosx_s
AudioDeviceID i_selected_dev; /* Keeps DeviceID of the selected device. */
int b_supports_digital; /* Does the currently selected device support digital mode? */
int b_digital; /* Are we running in digital mode? */
+ int b_muted; /* Are we muted in digital mode? */
/* AudioUnit */
AudioUnit theOutputUnit;
@@ -163,11 +164,13 @@ static int read_buffer(unsigned char* data,int len){
if (len > buffered) len = buffered;
if (first_len > len) first_len = len;
// till end of buffer
+ if (data) {
memcpy (data, &ao->buffer[ao->buf_read_pos], first_len);
if (len > first_len) { // we have to wrap around
// remaining part from beginning of buffer
memcpy (&data[first_len], ao->buffer, len - first_len);
}
+ }
ao->buf_read_pos = (ao->buf_read_pos + len) % ao->buffer_len;
return len;
}
@@ -212,13 +215,22 @@ Float32 vol;
}
case AOCONTROL_SET_VOLUME:
- if (ao->b_digital)
+ control_vol = (ao_control_vol_t*)arg;
+
+ if (ao->b_digital) {
// Digital output can not set volume. Here we have to return true
// to make mixer forget it. Else mixer will add a soft filter,
// that's not we expected and the filter not support ac3 stream
// will cause mplayer die.
+
+ // Although not support set volume, but at least we support mute.
+ // MPlayer set mute by set volume to zero, we handle it.
+ if (control_vol->left == 0 && control_vol->right == 0)
+ ao->b_muted = 1;
+ else
+ ao->b_muted = 0;
return CONTROL_TRUE;
- control_vol = (ao_control_vol_t*)arg;
+ }
vol=(control_vol->left+control_vol->right)*4.0/200.0;
err = AudioUnitSetParameter(ao->theOutputUnit, kHALOutputParam_Volume, kAudioUnitScope_Global, 0, vol, 0);
@@ -299,6 +311,7 @@ int b_alive;
ao->i_selected_dev = 0;
ao->b_supports_digital = 0;
ao->b_digital = 0;
+ ao->b_muted = 0;
ao->b_stream_format_changed = 0;
ao->i_hog_pid = -1;
ao->i_stream_id = 0;
@@ -944,7 +957,7 @@ static OSStatus RenderCallbackSPDIF( AudioDeviceID inDevice,
if (amt > req)
amt = req;
if (amt)
- read_buffer((unsigned char *)outOutputData->mBuffers[ao->i_stream_index].mData, amt);
+ read_buffer(ao->b_muted ? NULL : (unsigned char *)outOutputData->mBuffers[ao->i_stream_index].mData, amt);
return noErr;
}