File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,8 @@ class A2DPConfig {
5454 int delay_ms = 1 ;
5555 // / when a2dp source is active but has no data we generate silence data
5656 bool silence_on_nodata = false ;
57+ // / write timeout in ms: -1 is blocking write
58+ int tx_write_timeout_ms = -1 ; // no timeout
5759};
5860
5961
@@ -229,10 +231,16 @@ class A2DPStream : public AudioStream, public VolumeSupport {
229231 }
230232
231233 // blocking write: if buffer is full we wait
234+ int timeout = config.tx_write_timeout_ms ;
235+ int wait_time = 5 ;
232236 size_t free = a2dp_buffer.availableForWrite ();
233237 while (len > free){
234238 LOGD (" Waiting for buffer: writing %d > available %d" , (int ) len, (int ) free);
235- delay (5 );
239+ if (timeout > 0 ) {
240+ timeout -= wait_time;
241+ if (timeout <= 0 ) return 0 ;
242+ }
243+ delay (wait_time);
236244 free = a2dp_buffer.availableForWrite ();
237245 }
238246 }
You can’t perform that action at this time.
0 commit comments