File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -258,27 +258,34 @@ class A2DPStream : public AudioStream, public VolumeSupport {
258
258
return result;
259
259
}
260
260
261
+ // / Provides the number of bytes available to read
261
262
int available () override {
262
263
// only supported in tx mode
263
264
if (config.mode !=RX_MODE) return 0 ;
264
265
return a2dp_buffer.available ();
265
266
}
266
267
268
+ // / Provides the number of bytes available to write
267
269
int availableForWrite () override {
268
270
// only supported in tx mode
269
271
if (config.mode !=TX_MODE ) return 0 ;
270
272
// return infor from buffer
271
273
return a2dp_buffer.availableForWrite ();
272
274
}
273
275
274
- // Define the volme (values between 0.0 and 1.0)
276
+ // / Define the volume (values between 0.0 and 1.0)
275
277
bool setVolume (float volume) override {
276
278
VolumeSupport::setVolume (volume);
277
279
// 128 is max volume
278
280
if (a2dp!=nullptr ) a2dp->set_volume (volume * A2DP_MAX_VOL);
279
281
return true ;
280
282
}
281
283
284
+ // / Provides access to the buffer
285
+ BaseBuffer<uint8_t > &buffer () {
286
+ return a2dp_buffer;
287
+ }
288
+
282
289
protected:
283
290
A2DPConfig config;
284
291
BluetoothA2DPSource *a2dp_source = nullptr ;
Original file line number Diff line number Diff line change @@ -144,6 +144,13 @@ class BaseBuffer {
144
144
145
145
virtual size_t size () = 0;
146
146
147
+ // / Returns the level of the buffer in %
148
+ virtual float levelPercent () {
149
+ // prevent div by 0.
150
+ if (size ()==0 ) return 0.0 ;
151
+ return 100.0 * static_cast <float >(available ()) / static_cast <float >(size ());
152
+ }
153
+
147
154
protected:
148
155
void setWritePos (int pos){};
149
156
You can’t perform that action at this time.
0 commit comments