mirror of
https://github.com/badaix/snapcast.git
synced 2025-07-26 04:47:37 +02:00
configurable volume for OpenSL player
This commit is contained in:
parent
0f90f05e9d
commit
abc1488cd3
5 changed files with 32 additions and 22 deletions
|
@ -61,6 +61,25 @@ void Player::stop()
|
|||
}
|
||||
|
||||
|
||||
void Player::adjustVolume(char* buffer, size_t frames)
|
||||
{
|
||||
double volume = volume_;
|
||||
if (muted_)
|
||||
volume = 0.;
|
||||
|
||||
const msg::SampleFormat& sampleFormat = stream_->getFormat();
|
||||
|
||||
if (volume < 1.0)
|
||||
{
|
||||
if (sampleFormat.bits == 8)
|
||||
adjustVolume<int8_t>(buffer, frames*sampleFormat.channels, volume);
|
||||
else if (sampleFormat.bits == 16)
|
||||
adjustVolume<int16_t>(buffer, frames*sampleFormat.channels, volume);
|
||||
else if (sampleFormat.bits == 32)
|
||||
adjustVolume<int32_t>(buffer, frames*sampleFormat.channels, volume);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Player::setVolume(double volume)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue