From 3740e2ff46536accd2e4288fe2d4130843abc312 Mon Sep 17 00:00:00 2001 From: Dorian Johnson <2012@dorianj.net> Date: Tue, 7 Aug 2012 17:42:45 -0500 Subject: [PATCH] tsmf: add ability for tsmf audio players to get volume change notifications, even when the decoder doesn't support it. --- channels/drdynvc/tsmf/tsmf_audio.h | 2 ++ channels/drdynvc/tsmf/tsmf_media.c | 11 ++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/channels/drdynvc/tsmf/tsmf_audio.h b/channels/drdynvc/tsmf/tsmf_audio.h index af0075927..5492cb88a 100644 --- a/channels/drdynvc/tsmf/tsmf_audio.h +++ b/channels/drdynvc/tsmf/tsmf_audio.h @@ -34,6 +34,8 @@ struct _ITSMFAudioDevice boolean (*Play) (ITSMFAudioDevice* audio, uint8* data, uint32 data_size); /* Get the latency of the last written sample, in 100ns */ uint64 (*GetLatency) (ITSMFAudioDevice* audio); + /* Change the playback volume level */ + void (*ChangeVolume) (ITSMFAudioDevice* audio, uint32 newVolume, uint32 muted); /* Flush queued audio data */ void (*Flush) (ITSMFAudioDevice* audio); /* Free the audio device */ diff --git a/channels/drdynvc/tsmf/tsmf_media.c b/channels/drdynvc/tsmf/tsmf_media.c index 3bda3d04a..87cc4e74b 100644 --- a/channels/drdynvc/tsmf/tsmf_media.c +++ b/channels/drdynvc/tsmf/tsmf_media.c @@ -735,14 +735,15 @@ static void tsmf_stream_change_volume(TSMF_STREAM* stream, uint32 newVolume, uin { if (!stream) return; - - if (!stream->decoder) - return; - - if (stream->decoder->ChangeVolume) + + if (stream->decoder != NULL && stream->decoder->ChangeVolume) { stream->decoder->ChangeVolume(stream->decoder, newVolume, muted); } + else if (stream->audio != NULL && stream->audio->ChangeVolume) + { + stream->audio->ChangeVolume(stream->audio, newVolume, muted); + } } void tsmf_presentation_volume_changed(TSMF_PRESENTATION* presentation, uint32 newVolume, uint32 muted)