mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 02:01:40 -05:00
Ask OpenAL to use kDefaultFrequency (48 kHz).
This commit is contained in:
parent
2161858088
commit
a495de7cf8
3 changed files with 10 additions and 6 deletions
|
@ -140,7 +140,11 @@ bool CreatePlaybackDevice() {
|
|||
return false;
|
||||
}
|
||||
|
||||
ALCint attributes[] = { ALC_STEREO_SOURCES, 128, 0 };
|
||||
ALCint attributes[] = {
|
||||
ALC_STEREO_SOURCES, 128,
|
||||
ALC_FREQUENCY, Media::Player::kDefaultFrequency,
|
||||
0
|
||||
};
|
||||
AudioContext = alcCreateContext(AudioDevice, attributes);
|
||||
alcMakeContextCurrent(AudioContext);
|
||||
if (ContextErrorHappened()) {
|
||||
|
@ -256,7 +260,7 @@ namespace Player {
|
|||
namespace {
|
||||
|
||||
constexpr auto kVolumeRound = 10000;
|
||||
constexpr auto kPreloadSamples = 2LL * 48000; // preload next part if less than 2 seconds remains
|
||||
constexpr auto kPreloadSamples = 2LL * kDefaultFrequency; // preload next part if less than 2 seconds remains
|
||||
constexpr auto kFadeDuration = TimeMs(500);
|
||||
constexpr auto kCheckPlaybackPositionTimeout = TimeMs(100); // 100ms per check audio position
|
||||
constexpr auto kCheckPlaybackPositionDelta = 2400LL; // update position called each 2400 samples
|
||||
|
|
|
@ -252,7 +252,7 @@ bool FFMpegLoader::open(qint64 &position) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (_samplesFrequency != 44100 && _samplesFrequency != 48000) {
|
||||
if (_samplesFrequency != Media::Player::kDefaultFrequency) {
|
||||
sampleSize = -1; // convert needed
|
||||
}
|
||||
|
||||
|
@ -265,7 +265,7 @@ bool FFMpegLoader::open(qint64 &position) {
|
|||
int64_t src_ch_layout = layout, dst_ch_layout = AudioToChannelLayout;
|
||||
srcRate = _samplesFrequency;
|
||||
AVSampleFormat src_sample_fmt = inputFormat, dst_sample_fmt = AudioToFormat;
|
||||
dstRate = (_samplesFrequency != 44100 && _samplesFrequency != 48000) ? Media::Player::kDefaultFrequency : _samplesFrequency;
|
||||
dstRate = Media::Player::kDefaultFrequency;
|
||||
|
||||
av_opt_set_int(swrContext, "in_channel_layout", src_ch_layout, 0);
|
||||
av_opt_set_int(swrContext, "in_sample_rate", srcRate, 0);
|
||||
|
|
|
@ -76,7 +76,7 @@ bool ChildFFMpegLoader::open(qint64 &position) {
|
|||
_sampleSize = -1; // convert needed
|
||||
break;
|
||||
}
|
||||
if (_parentData->frequency != 44100 && _parentData->frequency != 48000) {
|
||||
if (_parentData->frequency != Media::Player::kDefaultFrequency) {
|
||||
_sampleSize = -1; // convert needed
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ bool ChildFFMpegLoader::open(qint64 &position) {
|
|||
int64_t src_ch_layout = layout, dst_ch_layout = AudioToChannelLayout;
|
||||
_srcRate = _parentData->frequency;
|
||||
AVSampleFormat src_sample_fmt = _inputFormat, dst_sample_fmt = AudioToFormat;
|
||||
_dstRate = (_parentData->frequency != 44100 && _parentData->frequency != 48000) ? Media::Player::kDefaultFrequency : _parentData->frequency;
|
||||
_dstRate = Media::Player::kDefaultFrequency;
|
||||
|
||||
av_opt_set_int(_swrContext, "in_channel_layout", src_ch_layout, 0);
|
||||
av_opt_set_int(_swrContext, "in_sample_rate", _srcRate, 0);
|
||||
|
|
Loading…
Add table
Reference in a new issue