Skip to content

Commit

Permalink
Fix notifications without sounds on macOS.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Jan 26, 2025
1 parent db9e60b commit 8287d71
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 3 additions & 6 deletions Telegram/SourceFiles/media/audio/media_audio_local_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ For license and copyright information please follow this link:
namespace Media::Audio {
namespace {

constexpr auto kMaxDuration = 10 * crl::time(1000);
constexpr auto kMaxDuration = 3 * crl::time(1000);
constexpr auto kMaxStreams = 2;
constexpr auto kFrameSize = 4096;

Expand Down Expand Up @@ -121,12 +121,9 @@ constexpr auto kFrameSize = 4096;
}
#endif // DA_FFMPEG_NEW_CHANNEL_LAYOUT
const auto inrate = inCodecContext->sample_rate;
const auto rate = (inrate == 44'100 || inrate == 48'000)
? inrate
: 44'100;
const auto rate = 44'100;
outCodecContext->sample_fmt = AV_SAMPLE_FMT_S16;
outCodecContext->time_base = AVRational{ 1, rate };
outCodecContext->bit_rate = 64 * 1024;
outCodecContext->sample_rate = rate;

error = avcodec_open2(outCodecContext.get(), outCodec, nullptr);
Expand Down Expand Up @@ -342,7 +339,7 @@ QString LocalDiskCache::name(const LocalSound &sound) {
return i->second;
}

auto result = u"TDesktop-%1"_q.arg(sound.id
auto result = u"TD_%1"_q.arg(sound.id
? QString::number(sound.id, 16).toUpper()
: u"Default"_q);
const auto path = _base + u"%1.wav"_q.arg(result);
Expand Down
4 changes: 3 additions & 1 deletion Telegram/SourceFiles/window/notifications_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,9 @@ void NativeManager::doShowNotification(NotificationFields &&fields) {
// #TODO optimize
auto userpicView = item->history()->peer->createUserpicView();
const auto owner = &item->history()->owner();
const auto sound = fields.soundId ? [=, id = *fields.soundId] {
const auto withSound = fields.soundId
&& Core::App().settings().soundNotify();
const auto sound = withSound ? [=, id = *fields.soundId] {
return _localSoundCache.sound(id, [=] {
return Core::App().notifications().lookupSoundBytes(owner, id);
}, [=] {
Expand Down

0 comments on commit 8287d71

Please sign in to comment.