|
|
@@ -37,16 +37,6 @@ namespace Ryujinx.Audio
|
|
|
/// </summary>
|
|
|
private Thread _audioPollerThread;
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// The volume of audio renderer
|
|
|
- /// </summary>
|
|
|
- private float _volume = 1.0f;
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// True if the volume of audio renderer have changed
|
|
|
- /// </summary>
|
|
|
- private bool _volumeChanged;
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// True if OpenAL is supported on the device
|
|
|
/// </summary>
|
|
|
@@ -248,6 +238,8 @@ namespace Ryujinx.Audio
|
|
|
AL.SourceQueueBuffer(track.SourceId, bufferId);
|
|
|
|
|
|
StartPlaybackIfNeeded(track);
|
|
|
+
|
|
|
+ track.PlayedSampleCount += (ulong)buffer.Length;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -277,13 +269,6 @@ namespace Ryujinx.Audio
|
|
|
|
|
|
if (State != ALSourceState.Playing && track.State == PlaybackState.Playing)
|
|
|
{
|
|
|
- if (_volumeChanged)
|
|
|
- {
|
|
|
- AL.Source(track.SourceId, ALSourcef.Gain, _volume);
|
|
|
-
|
|
|
- _volumeChanged = false;
|
|
|
- }
|
|
|
-
|
|
|
AL.SourcePlay(track.SourceId);
|
|
|
}
|
|
|
}
|
|
|
@@ -306,21 +291,87 @@ namespace Ryujinx.Audio
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// Get playback volume
|
|
|
+ /// Get track buffer count
|
|
|
/// </summary>
|
|
|
- public float GetVolume() => _volume;
|
|
|
+ /// <param name="trackId">The ID of the track to get buffer count</param>
|
|
|
+ public uint GetBufferCount(int trackId)
|
|
|
+ {
|
|
|
+ if (_tracks.TryGetValue(trackId, out OpenALAudioTrack track))
|
|
|
+ {
|
|
|
+ lock (track)
|
|
|
+ {
|
|
|
+ return track.BufferCount;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
|
|
|
/// <summary>
|
|
|
- /// Set playback volume
|
|
|
+ /// Get track played sample count
|
|
|
/// </summary>
|
|
|
- /// <param name="volume">The volume of the playback</param>
|
|
|
- public void SetVolume(float volume)
|
|
|
+ /// <param name="trackId">The ID of the track to get played sample count</param>
|
|
|
+ public ulong GetPlayedSampleCount(int trackId)
|
|
|
{
|
|
|
- if (!_volumeChanged)
|
|
|
+ if (_tracks.TryGetValue(trackId, out OpenALAudioTrack track))
|
|
|
{
|
|
|
- _volume = volume;
|
|
|
- _volumeChanged = true;
|
|
|
+ lock (track)
|
|
|
+ {
|
|
|
+ return track.PlayedSampleCount;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Flush all track buffers
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="trackId">The ID of the track to flush</param>
|
|
|
+ public bool FlushBuffers(int trackId)
|
|
|
+ {
|
|
|
+ if (_tracks.TryGetValue(trackId, out OpenALAudioTrack track))
|
|
|
+ {
|
|
|
+ lock (track)
|
|
|
+ {
|
|
|
+ track.FlushBuffers();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Set track volume
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="trackId">The ID of the track to set volume</param>
|
|
|
+ /// <param name="volume">The volume of the track</param>
|
|
|
+ public void SetVolume(int trackId, float volume)
|
|
|
+ {
|
|
|
+ if (_tracks.TryGetValue(trackId, out OpenALAudioTrack track))
|
|
|
+ {
|
|
|
+ lock (track)
|
|
|
+ {
|
|
|
+ track.SetVolume(volume);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Get track volume
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="trackId">The ID of the track to get volume</param>
|
|
|
+ public float GetVolume(int trackId)
|
|
|
+ {
|
|
|
+ if (_tracks.TryGetValue(trackId, out OpenALAudioTrack track))
|
|
|
+ {
|
|
|
+ lock (track)
|
|
|
+ {
|
|
|
+ return track.Volume;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return 1.0f;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|