1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 #include "Transmitter.hxx"
12 using namespace osl
; // Sockets etc.
15 Transmitter::Transmitter( IBluetoothSocket
* aSocket
)
16 : pStreamSocket( aSocket
),
25 void SAL_CALL
Transmitter::run()
27 osl_setThreadName("bluetooth Transmitter");
31 mQueuesNotEmpty
.wait();
33 if ( mFinishRequested
.check() )
36 ::osl::MutexGuard
aQueueGuard( mQueueMutex
);
37 if ( !mHighPriority
.empty() )
39 OString
aMessage( mHighPriority
.front() );
41 SAL_INFO( "sdremote.bluetooth", "write high prio line '" << aMessage
<< "'" );
42 pStreamSocket
->write( aMessage
.getStr(), aMessage
.getLength() );
44 else if ( !mLowPriority
.empty() )
46 OString
aMessage( mLowPriority
.front() );
48 SAL_INFO( "sdremote.bluetooth", "write normal line '" << aMessage
<< "'" );
49 pStreamSocket
->write( aMessage
.getStr(), aMessage
.getLength() );
52 if ( mLowPriority
.empty() && mHighPriority
.empty() )
54 mQueuesNotEmpty
.reset();
59 void Transmitter::notifyFinished()
61 mFinishRequested
.set();
62 mQueuesNotEmpty
.set();
65 Transmitter::~Transmitter()
69 void Transmitter::addMessage( const OString
& aMessage
, const Priority aPriority
)
71 ::osl::MutexGuard
aQueueGuard( mQueueMutex
);
75 mLowPriority
.push( aMessage
);
78 mHighPriority
.push( aMessage
);
81 if ( !mQueuesNotEmpty
.check() )
83 mQueuesNotEmpty
.set();
87 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */