Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/mumblekit.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMikkel Krautz <mikkel@krautz.dk>2013-02-10 02:07:32 +0400
committerMikkel Krautz <mikkel@krautz.dk>2013-02-10 02:07:32 +0400
commite01752296c6ab26e3957ca97fe563bbd99190c7d (patch)
tree89247a64d84815610a0e3e4ca38819243af155da /src
parent178ff98af76ee4e0048ceb9beb05550ab0d73a43 (diff)
MKConnection: serialize sendVoiceData onto the MKConnection thread.
Diffstat (limited to 'src')
-rw-r--r--src/MKConnection.m14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/MKConnection.m b/src/MKConnection.m
index c100699..992b4bd 100644
--- a/src/MKConnection.m
+++ b/src/MKConnection.m
@@ -100,6 +100,7 @@
- (void) _udpDataReady:(NSData *)data;
- (void) _udpMessageReceived:(NSData *)data;
- (void) _sendUDPMessage:(NSData *)data;
+- (void) _sendVoiceDataOnConnectionThread:(NSData *)data;
// Error handling
- (void) _handleError:(NSError *)streamError;
@@ -723,7 +724,20 @@ out:
// Send a voice packet to the server. The method will automagically figure
// out whether it should be sent via UDP or TCP depending on the current
// connection conditions.
+//
+// This is a wrapper that ensures the actual call will be made on the connection thread.
- (void) sendVoiceData:(NSData *)data {
+ NSLog(@"sendVoiceData; thread = %i", [NSThread currentThread] == self);
+ if ([NSThread currentThread] == self) {
+ [self _sendVoiceDataOnConnectionThread:data];
+ } else {
+ [self performSelector:@selector(_sendVoiceDataOnConnectionThread:) onThread:self withObject:data waitUntilDone:NO];
+ }
+}
+
+// Send a voice packet. Must only be called on the MKConnection thread.
+// Internal MKConnection method. Use sendVoiceData to send actual voice data.
+- (void) _sendVoiceDataOnConnectionThread:(NSData *)data {
if (!_readyVoice || !_connectionEstablished)
return;
if (!_forceTCP && _udpAvailable) {