Skip to content

Commit 97d68ba

Browse files
committed
A2DPNoVolumeControl: support fixed reduced volume
1 parent 79a3858 commit 97d68ba

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/A2DPVolumeControl.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ struct __attribute__((packed)) Frame {
4444

4545
class A2DPVolumeControl {
4646
public:
47-
A2DPVolumeControl() { volumeFactorMax = 0x1000; }
47+
A2DPVolumeControl() = default;
4848

4949
virtual void update_audio_data(uint8_t* data, uint16_t byteCount) {
5050
update_audio_data((Frame*)data, byteCount / 4);
@@ -86,8 +86,8 @@ class A2DPVolumeControl {
8686
protected:
8787
bool is_volume_used = false;
8888
bool mono_downmix = false;
89-
int32_t volumeFactor;
90-
int32_t volumeFactorMax;
89+
int32_t volumeFactor = 0x1000;
90+
int32_t volumeFactorMax = 0x1000; // max value is 4096
9191

9292
int32_t clip(int32_t value) {
9393
int32_t result = value;
@@ -155,6 +155,12 @@ class A2DPLinearVolumeControl : public A2DPVolumeControl {
155155
*/
156156
class A2DPNoVolumeControl : public A2DPVolumeControl {
157157
public:
158+
A2DPNoVolumeControl(int32_t fixedVolume = 0x1000) {
159+
is_volume_used = fixedVolume != 0x1000;
160+
mono_downmix = false;
161+
volumeFactor = fixedVolume; // fixed volume
162+
volumeFactorMax = 0x1000; // no change
163+
}
158164
void update_audio_data(Frame* data, uint16_t frameCount) override {}
159165
void set_volume(uint8_t volume) override {}
160166
};

0 commit comments

Comments
 (0)