Kaydet (Commit) 6ce04df2 authored tarafından Tor Lillqvist's avatar Tor Lillqvist

Handle gracefully the remote end closing the RFCOMM channel

Avoids a crash if one presses the "back" key on the Android remote
control.

Change-Id: Icc7562676a79910b77c7f95d76ce07c348ec2b22
üst 7c6b4285
......@@ -189,6 +189,10 @@ sal_Int32 OSXBluetoothWrapper::write( const void* pBuffer, sal_uInt32 n )
char* ptr = (char*)pBuffer;
sal_uInt32 nBytesWritten = 0;
if (mpChannel == nil)
return 0;
while( nBytesWritten < n )
{
int toWrite = n - nBytesWritten;
......@@ -222,6 +226,13 @@ void OSXBluetoothWrapper::appendData(void* pBuffer, size_t len)
}
}
void OSXBluetoothWrapper::channelClosed()
{
SAL_INFO( "sdremote.bluetooth", "OSXBluetoothWrapper::channelClosed()" );
mpChannel = nil;
}
void incomingCallback( void *userRefCon,
IOBluetoothUserNotificationRef inRef,
IOBluetoothObjectRef objectRef )
......
......@@ -37,7 +37,12 @@
{
(void) rfcommChannel;
// TODO: broadcast premature closing of data channel
SAL_INFO( "sdremote.bluetooth", "ChannelDelegate::rfcommChannelClosed()\n");
if ( pSocket )
{
pSocket->channelClosed();
}
pCommunicator = NULL;
pSocket = NULL;
}
......
......@@ -32,6 +32,7 @@ namespace sd
virtual sal_Int32 readLine( rtl::OString& aLine );
virtual sal_Int32 write( const void* pBuffer, sal_uInt32 len );
void appendData(void* pBuffer, size_t len );
void channelClosed();
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment