@@ -109,13 +109,16 @@ int PaPulseAudio_updateTimeInfo( pa_stream * s,
109109void PaPulseAudio_ReleaseOperation (PaPulseAudio_HostApiRepresentation * hostapi ,
110110 pa_operation * * operation )
111111{
112- unsigned int wait = 1000 ;
112+ unsigned int wait = 10 ;
113113 pa_operation * localOperation = (* operation );
114114 pa_operation_state_t localOperationState = PA_OPERATION_RUNNING ;
115115
116- /* Since the primary operations are conducted locally, a wait time
117- * of 1 to 3 seconds, followed by an additional 1000 milliseconds,
118- * is deemed sufficient to to detect successful completion or to detect an error.
116+ /* Functions blocks main thread wait maximum ~1 seconds.
117+ *
118+ * Normally release operation should happen at once
119+ *
120+ * This because Pulseaudio server can vanish middle of
121+ * operation and loop just waits for reply from server
119122 */
120123 while ( wait > 0 )
121124 {
@@ -139,6 +142,7 @@ void PaPulseAudio_ReleaseOperation(PaPulseAudio_HostApiRepresentation *hostapi,
139142 PaPulseAudio_UnLock ( hostapi -> mainloop );
140143
141144 wait -- ;
145+ usleep (100 );
142146 }
143147
144148 /* Do not wait if operation is DONE or CANCELLED */
@@ -286,8 +290,9 @@ static int _PaPulseAudio_ProcessAudio(PaPulseAudio_Stream *stream,
286290 }
287291 }
288292
289- /* If input is desired without output (non-duplex operation),
290- * the following calculation should be utilized.
293+ /* If there is input stream available then calculate Portaudio
294+ * needed bytes per request as Pulseaudio can ask mainly any amount
295+ * of bytes also check callback availability.
291296 */
292297 if ( stream -> inputStream )
293298 {
@@ -843,10 +848,6 @@ PaError PaPulseAudio_StartStreamCb( PaStream * s )
843848 {
844849 /* The tlength parameter functions similarly to fragsize in
845850 * the recording process, as explained in the preceding comments.
846- *
847- * In the future, this should be adjusted as necessary when
848- * conditions change; currently, it serves as a satisfactory
849- * default.
850851 */
851852 stream -> outputBufferAttr .tlength = pa_usec_to_bytes ( pulseaudioReqFrameSize ,
852853 & stream -> outputSampleSpec );
@@ -943,9 +944,6 @@ PaError PaPulseAudio_StartStreamCb( PaStream * s )
943944 goto startstreamcb_error ;
944945 }
945946
946- /* It must be ensured that no errors are encountered during
947- * initialization.
948- */
949947 ret = paNoError ;
950948
951949 /* Stream is now active */
0 commit comments