LCOV - code coverage report
Current view: top level - sd/source/ui/remotecontrol - Transmitter.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 37 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 6 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  */
       9             : #include "Transmitter.hxx"
      10             : 
      11             : using namespace std;
      12             : using namespace osl; // Sockets etc.
      13             : using namespace sd;
      14             : 
      15           0 : Transmitter::Transmitter( IBluetoothSocket* aSocket )
      16             :   : pStreamSocket( aSocket ),
      17             :     mQueuesNotEmpty(),
      18             :     mFinishRequested(),
      19             :     mQueueMutex(),
      20             :     mLowPriority(),
      21           0 :     mHighPriority()
      22             : {
      23           0 : }
      24             : 
      25           0 : void SAL_CALL Transmitter::run()
      26             : {
      27           0 :     osl_setThreadName("bluetooth Transmitter");
      28             : 
      29             :     while ( true )
      30             :     {
      31           0 :         mQueuesNotEmpty.wait();
      32             : 
      33           0 :         if ( mFinishRequested.check() )
      34           0 :             return;
      35             : 
      36           0 :         ::osl::MutexGuard aQueueGuard( mQueueMutex );
      37           0 :         if ( !mHighPriority.empty() )
      38             :         {
      39           0 :             OString aMessage( mHighPriority.front() );
      40           0 :             mHighPriority.pop();
      41             :             SAL_INFO( "sdremote.bluetooth", "write high prio line '" << aMessage << "'" );
      42           0 :             pStreamSocket->write( aMessage.getStr(), aMessage.getLength() );
      43             :         }
      44           0 :         else if ( !mLowPriority.empty() )
      45             :         {
      46           0 :             OString aMessage( mLowPriority.front() );
      47           0 :             mLowPriority.pop();
      48             :             SAL_INFO( "sdremote.bluetooth", "write normal line '" << aMessage << "'" );
      49           0 :             pStreamSocket->write( aMessage.getStr(), aMessage.getLength() );
      50             :         }
      51             : 
      52           0 :         if ( mLowPriority.empty() && mHighPriority.empty() )
      53             :         {
      54           0 :             mQueuesNotEmpty.reset();
      55             :         }
      56           0 :     }
      57             : }
      58             : 
      59           0 : void Transmitter::notifyFinished()
      60             : {
      61           0 :     mFinishRequested.set();
      62           0 :     mQueuesNotEmpty.set();
      63           0 : }
      64             : 
      65           0 : Transmitter::~Transmitter()
      66             : {
      67           0 : }
      68             : 
      69           0 : void Transmitter::addMessage( const OString& aMessage, const Priority aPriority )
      70             : {
      71           0 :     ::osl::MutexGuard aQueueGuard( mQueueMutex );
      72           0 :     switch ( aPriority )
      73             :     {
      74             :         case PRIORITY_LOW:
      75           0 :             mLowPriority.push( aMessage );
      76           0 :             break;
      77             :         case PRIORITY_HIGH:
      78           0 :             mHighPriority.push( aMessage );
      79           0 :             break;
      80             :     }
      81           0 :     if ( !mQueuesNotEmpty.check() )
      82             :     {
      83           0 :         mQueuesNotEmpty.set();
      84           0 :     }
      85           0 : }
      86             : 
      87             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11