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

Fix deadlock due to not '_isSendingAudio' back to false #269

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
36 changes: 28 additions & 8 deletions src/Custom/RealtimeConversation/RealtimeConversationSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,20 @@ public virtual async Task SendInputAudioAsync(BinaryData audio, CancellationToke
}
_isSendingAudio = true;
}
// TODO: consider automatically limiting/breaking size of chunk (as with streaming)
InternalRealtimeClientEventInputAudioBufferAppend internalCommand = new(audio);
BinaryData requestData = ModelReaderWriter.Write(internalCommand);
await SendCommandAsync(requestData, cancellationToken.ToRequestOptions()).ConfigureAwait(false);
try
{
// TODO: consider automatically limiting/breaking size of chunk (as with streaming)
InternalRealtimeClientEventInputAudioBufferAppend internalCommand = new(audio);
BinaryData requestData = ModelReaderWriter.Write(internalCommand);
await SendCommandAsync(requestData, cancellationToken.ToRequestOptions()).ConfigureAwait(false);
}
finally
{
lock (_sendingAudioLock)
{
_isSendingAudio = false;
}
}
}

/// <summary>
Expand All @@ -162,10 +172,20 @@ public virtual void SendInputAudio(BinaryData audio, CancellationToken cancellat
}
_isSendingAudio = true;
}
// TODO: consider automatically limiting/breaking size of chunk (as with streaming)
InternalRealtimeClientEventInputAudioBufferAppend internalCommand = new(audio);
BinaryData requestData = ModelReaderWriter.Write(internalCommand);
SendCommand(requestData, cancellationToken.ToRequestOptions());
try
{
// TODO: consider automatically limiting/breaking size of chunk (as with streaming)
InternalRealtimeClientEventInputAudioBufferAppend internalCommand = new(audio);
BinaryData requestData = ModelReaderWriter.Write(internalCommand);
SendCommand(requestData, cancellationToken.ToRequestOptions());
}
finally
{
lock (_sendingAudioLock)
{
_isSendingAudio = false;
}
}
}

public virtual async Task ClearInputAudioAsync(CancellationToken cancellationToken = default)
Expand Down