Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable intentional restart of endless streaming. #67

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/endless_streaming_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,17 @@ class EndlessStreamingService {
_endlessStream.addError(error);
});

_resetTimer = Timer(_restartTime, _restart);
_resetTimer = Timer(_restartTime, restart);
}

Future<void> _restart() async {
Future<void> restart() async {
_transitioning = true;
await Future.delayed(_transitionBufferTime);
await _audioStreamSubscription?.cancel();
_audioStreamSubscription = null;
await _streamingRecognizeSubscription.cancel();
await _request.close();
_resetTimer?.cancel();
if (!_audioStreamIsFinished) {
_startStream();
}
Expand Down
5 changes: 3 additions & 2 deletions lib/endless_streaming_service_beta.dart
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,17 @@ class EndlessStreamingServiceBeta {
_endlessStream.addError(error);
});

_resetTimer = Timer(_restartTime, _restart);
_resetTimer = Timer(_restartTime, restart);
}

Future<void> _restart() async {
Future<void> restart() async {
_transitioning = true;
await Future.delayed(_transitionBufferTime);
await _audioStreamSubscription?.cancel();
_audioStreamSubscription = null;
await _streamingRecognizeSubscription.cancel();
await _request.close();
_resetTimer?.cancel();
if (!_audioStreamIsFinished) {
_startStream();
}
Expand Down
5 changes: 3 additions & 2 deletions lib/endless_streaming_service_v2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -181,16 +181,17 @@ class EndlessStreamingServiceV2 {
_endlessStream.addError(error);
});

_resetTimer = Timer(_restartTime, _restart);
_resetTimer = Timer(_restartTime, restart);
}

Future<void> _restart() async {
Future<void> restart() async {
_transitioning = true;
await Future.delayed(_transitionBufferTime);
await _audioStreamSubscription?.cancel();
_audioStreamSubscription = null;
await _streamingRecognizeSubscription.cancel();
await _request.close();
_resetTimer?.cancel();
if (!_audioStreamIsFinished) {
_startStream();
}
Expand Down