diff options
author | Tor Lillqvist <tml@iki.fi> | 2013-02-18 22:13:03 +0200 |
---|---|---|
committer | Tor Lillqvist <tml@iki.fi> | 2013-02-18 22:13:03 +0200 |
commit | 6ce04df28c8b5d6043340efe6fdc229b51dd8c36 (patch) | |
tree | 42cc518756bb99787d79cea803cc7ccb1a66ee76 /sd | |
parent | 7c6b42851bc0a94f6aa8c3e28892d1ab4b297c25 (diff) |
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
Diffstat (limited to 'sd')
-rw-r--r-- | sd/source/ui/remotecontrol/BluetoothServer.cxx | 11 | ||||
-rw-r--r-- | sd/source/ui/remotecontrol/OSXBluetooth.mm | 7 | ||||
-rw-r--r-- | sd/source/ui/remotecontrol/OSXBluetoothWrapper.hxx | 1 |
3 files changed, 18 insertions, 1 deletions
diff --git a/sd/source/ui/remotecontrol/BluetoothServer.cxx b/sd/source/ui/remotecontrol/BluetoothServer.cxx index b9736a20a746..ad6dadf14a61 100644 --- a/sd/source/ui/remotecontrol/BluetoothServer.cxx +++ b/sd/source/ui/remotecontrol/BluetoothServer.cxx @@ -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 ) diff --git a/sd/source/ui/remotecontrol/OSXBluetooth.mm b/sd/source/ui/remotecontrol/OSXBluetooth.mm index ef1b7000eab4..f364389df78e 100644 --- a/sd/source/ui/remotecontrol/OSXBluetooth.mm +++ b/sd/source/ui/remotecontrol/OSXBluetooth.mm @@ -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; } diff --git a/sd/source/ui/remotecontrol/OSXBluetoothWrapper.hxx b/sd/source/ui/remotecontrol/OSXBluetoothWrapper.hxx index 6a61a24bc97b..cecaa7a8b1e5 100644 --- a/sd/source/ui/remotecontrol/OSXBluetoothWrapper.hxx +++ b/sd/source/ui/remotecontrol/OSXBluetoothWrapper.hxx @@ -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(); }; } |