diff options
| author | 2019-06-19 10:29:42 -0400 | |
|---|---|---|
| committer | 2019-06-19 10:29:42 -0400 | |
| commit | 5c665fcc5b3086d8b7d6d84ccdec5356ec58f5fb (patch) | |
| tree | 59fbc197a941e8a363cef85a3f75b2293c3c3bff /src/audio_core | |
| parent | Merge pull request #2562 from ReinUsesLisp/split-cbuf-upload (diff) | |
| parent | Addressed issues (diff) | |
| download | yuzu-5c665fcc5b3086d8b7d6d84ccdec5356ec58f5fb.tar.gz yuzu-5c665fcc5b3086d8b7d6d84ccdec5356ec58f5fb.tar.xz yuzu-5c665fcc5b3086d8b7d6d84ccdec5356ec58f5fb.zip | |
Merge pull request #2584 from ogniK5377/cadence
Impl'd IsUserAccountSwitchLocked, SetAudioOutVolume, GetAudioOutVolume & Partial impl of GetAccumulatedSuspendedTickChangedEvent
Diffstat (limited to 'src/audio_core')
| -rw-r--r-- | src/audio_core/stream.cpp | 10 | ||||
| -rw-r--r-- | src/audio_core/stream.h | 7 |
2 files changed, 14 insertions, 3 deletions
diff --git a/src/audio_core/stream.cpp b/src/audio_core/stream.cpp index 11481a776..982c7af2f 100644 --- a/src/audio_core/stream.cpp +++ b/src/audio_core/stream.cpp | |||
| @@ -51,6 +51,10 @@ void Stream::Stop() { | |||
| 51 | UNIMPLEMENTED(); | 51 | UNIMPLEMENTED(); |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | void Stream::SetVolume(float volume) { | ||
| 55 | game_volume = volume; | ||
| 56 | } | ||
| 57 | |||
| 54 | Stream::State Stream::GetState() const { | 58 | Stream::State Stream::GetState() const { |
| 55 | return state; | 59 | return state; |
| 56 | } | 60 | } |
| @@ -62,8 +66,8 @@ s64 Stream::GetBufferReleaseCycles(const Buffer& buffer) const { | |||
| 62 | return Core::Timing::usToCycles(us); | 66 | return Core::Timing::usToCycles(us); |
| 63 | } | 67 | } |
| 64 | 68 | ||
| 65 | static void VolumeAdjustSamples(std::vector<s16>& samples) { | 69 | static void VolumeAdjustSamples(std::vector<s16>& samples, float game_volume) { |
| 66 | const float volume{std::clamp(Settings::values.volume, 0.0f, 1.0f)}; | 70 | const float volume{std::clamp(Settings::values.volume - (1.0f - game_volume), 0.0f, 1.0f)}; |
| 67 | 71 | ||
| 68 | if (volume == 1.0f) { | 72 | if (volume == 1.0f) { |
| 69 | return; | 73 | return; |
| @@ -97,7 +101,7 @@ void Stream::PlayNextBuffer() { | |||
| 97 | active_buffer = queued_buffers.front(); | 101 | active_buffer = queued_buffers.front(); |
| 98 | queued_buffers.pop(); | 102 | queued_buffers.pop(); |
| 99 | 103 | ||
| 100 | VolumeAdjustSamples(active_buffer->GetSamples()); | 104 | VolumeAdjustSamples(active_buffer->GetSamples(), game_volume); |
| 101 | 105 | ||
| 102 | sink_stream.EnqueueSamples(GetNumChannels(), active_buffer->GetSamples()); | 106 | sink_stream.EnqueueSamples(GetNumChannels(), active_buffer->GetSamples()); |
| 103 | 107 | ||
diff --git a/src/audio_core/stream.h b/src/audio_core/stream.h index 05071243b..8106cea43 100644 --- a/src/audio_core/stream.h +++ b/src/audio_core/stream.h | |||
| @@ -61,6 +61,12 @@ public: | |||
| 61 | /// Returns a vector of recently released buffers specified by tag | 61 | /// Returns a vector of recently released buffers specified by tag |
| 62 | std::vector<Buffer::Tag> GetTagsAndReleaseBuffers(std::size_t max_count); | 62 | std::vector<Buffer::Tag> GetTagsAndReleaseBuffers(std::size_t max_count); |
| 63 | 63 | ||
| 64 | void SetVolume(float volume); | ||
| 65 | |||
| 66 | float GetVolume() const { | ||
| 67 | return game_volume; | ||
| 68 | } | ||
| 69 | |||
| 64 | /// Returns true if the stream is currently playing | 70 | /// Returns true if the stream is currently playing |
| 65 | bool IsPlaying() const { | 71 | bool IsPlaying() const { |
| 66 | return state == State::Playing; | 72 | return state == State::Playing; |
| @@ -94,6 +100,7 @@ private: | |||
| 94 | 100 | ||
| 95 | u32 sample_rate; ///< Sample rate of the stream | 101 | u32 sample_rate; ///< Sample rate of the stream |
| 96 | Format format; ///< Format of the stream | 102 | Format format; ///< Format of the stream |
| 103 | float game_volume = 1.0f; ///< The volume the game currently has set | ||
| 97 | ReleaseCallback release_callback; ///< Buffer release callback for the stream | 104 | ReleaseCallback release_callback; ///< Buffer release callback for the stream |
| 98 | State state{State::Stopped}; ///< Playback state of the stream | 105 | State state{State::Stopped}; ///< Playback state of the stream |
| 99 | Core::Timing::EventType* release_event{}; ///< Core timing release event for the stream | 106 | Core::Timing::EventType* release_event{}; ///< Core timing release event for the stream |