mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-22 10:17:10 +00:00
Added ability to override volume in media audio tracks.
This commit is contained in:
parent
2c34838589
commit
e886ca16ff
@ -142,7 +142,7 @@ void Track::fillFromFile(const QString &filePath) {
|
||||
}
|
||||
}
|
||||
|
||||
void Track::playWithLooping(bool looping) {
|
||||
void Track::playWithLooping(bool looping, float64 volumeOverride) {
|
||||
_active = true;
|
||||
if (failed() || _samples.empty()) {
|
||||
finish();
|
||||
@ -152,7 +152,12 @@ void Track::playWithLooping(bool looping) {
|
||||
alSourceStop(_alSource);
|
||||
_looping = looping;
|
||||
alSourcei(_alSource, AL_LOOPING, _looping ? 1 : 0);
|
||||
alSourcef(_alSource, AL_GAIN, _volume);
|
||||
alSourcef(
|
||||
_alSource,
|
||||
AL_GAIN,
|
||||
(volumeOverride > 0)
|
||||
? volumeOverride
|
||||
: _volume);
|
||||
alSourcePlay(_alSource);
|
||||
_instance->trackStarted(this);
|
||||
}
|
||||
|
@ -30,11 +30,11 @@ public:
|
||||
void fillFromFile(const Core::FileLocation &location);
|
||||
void fillFromFile(const QString &filePath);
|
||||
|
||||
void playOnce() {
|
||||
playWithLooping(false);
|
||||
void playOnce(float64 volumeOverride = -1) {
|
||||
playWithLooping(false, volumeOverride);
|
||||
}
|
||||
void playInLoop() {
|
||||
playWithLooping(true);
|
||||
void playInLoop(float64 volumeOverride = -1) {
|
||||
playWithLooping(true, volumeOverride);
|
||||
}
|
||||
|
||||
bool isLooping() const {
|
||||
@ -61,7 +61,7 @@ public:
|
||||
private:
|
||||
void finish();
|
||||
void ensureSourceCreated();
|
||||
void playWithLooping(bool looping);
|
||||
void playWithLooping(bool looping, float64 volumeOverride);
|
||||
|
||||
not_null<Instance*> _instance;
|
||||
|
||||
|
@ -967,8 +967,11 @@ void System::notifySettingsChanged(ChangeType type) {
|
||||
return _settingsChanged.fire(std::move(type));
|
||||
}
|
||||
|
||||
void System::playSound(not_null<Main::Session*> session, DocumentId id) {
|
||||
lookupSound(&session->data(), id)->playOnce();
|
||||
void System::playSound(
|
||||
not_null<Main::Session*> session,
|
||||
DocumentId id,
|
||||
float64 volumeOverride) {
|
||||
lookupSound(&session->data(), id)->playOnce(volumeOverride);
|
||||
}
|
||||
|
||||
Manager::DisplayOptions Manager::getNotificationOptions(
|
||||
|
@ -124,7 +124,10 @@ public:
|
||||
[[nodiscard]] rpl::producer<ChangeType> settingsChanged() const;
|
||||
void notifySettingsChanged(ChangeType type);
|
||||
|
||||
void playSound(not_null<Main::Session*> session, DocumentId id);
|
||||
void playSound(
|
||||
not_null<Main::Session*> session,
|
||||
DocumentId id,
|
||||
float64 volumeOverride = -1);
|
||||
[[nodiscard]] QByteArray lookupSoundBytes(
|
||||
not_null<Data::Session*> owner,
|
||||
DocumentId id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user