Пример #1
0
int TSocket::ReceiveSomeMoreSocketData(char *data,unsigned int len,unsigned int new_len,unsigned int max_len)
{
	if(p_read_data_buf!=NULL)
	{
		delete [] p_read_data_buf;
		p_read_data_buf=NULL;
	}

	// Append any new data to this existing data already read in
	m_receiving_some_socket_data=true;
	m_read_data_buf_len=max_len;
	m_num_read=len;
	p_read_data_buf=new char[max_len];
	memcpy(p_read_data_buf,data,len);

	// If there was data waiting there, try to receive some more, else wait for next OnReceive
	if(new_len > 0)
	{
		return ReceiveBuffer();
	}
	else
	{
		return 0;
	}
}
Пример #2
0
void *ThreadedUsbReceiver::Run() {
  DmxBuffer buffer;
  buffer.Blackout();
  if (!m_usb_handle) {
    return NULL;
  }

  while (1) {
    {
      ola::thread::MutexLocker locker(&m_term_mutex);
      if (m_term) {
        break;
      }
    }

    bool buffer_updated = false;
    if (!ReceiveBuffer(m_usb_handle, &buffer, &buffer_updated)) {
      OLA_WARN << "Receive failed, stopping thread...";
      break;
    }

    if (buffer_updated) {
      {
        ola::thread::MutexLocker locker(&m_data_mutex);
        m_buffer.Set(buffer);
      }
      if (m_receive_callback.get()) {
        m_plugin_adaptor->Execute(m_receive_callback.get());
      }
    }
  }
  libusb_release_interface(m_usb_handle, m_interface_number);
  libusb_close(m_usb_handle);
  return NULL;
}
Пример #3
0
/*
====================
T_PipeReceive
====================
*/
t_bool T_PipeReceive( t_pipe_t *const pipe, void ( *iterate )( void * ) ) {
	if ( mtx_trylock( &pipe->mutex ) != thrd_success ) {
		return t_false;
	}

	mtx_lock( &pipe->mutexBuffer );
	ReceiveBuffer( pipe );
	mtx_unlock( &pipe->mutexBuffer );

	__T_PipeReceive_iterate( pipe->linked, iterate );
	pipe->linked = NULL;

	mtx_unlock( &pipe->mutex );
	return t_true;
}
Пример #4
0
//
// Called by the user when they get an OnReceive and they don't know how much data they want to read, so the buf_len is the max
//
int TSocket::ReceiveSomeSocketData(unsigned int buf_len)
{
	if(p_read_data_buf!=NULL)
	{
		delete p_read_data_buf;
		p_read_data_buf=NULL;
	}

	// Initialize the receiving data buffers
	m_receiving_some_socket_data=true;
	m_read_data_buf_len=buf_len;
	p_read_data_buf=new char[buf_len];
	memset(p_read_data_buf,0,buf_len);
	return ReceiveBuffer();
}
Пример #5
0
//
// Called by the user when they get an OnReceive and they know how much data they want to read
//
int WSocket::ReceiveSocketData(unsigned int buf_len)
{
	if(p_read_data_buf!=NULL)
	{
		OutputDebugString("p_read_data_buf != NULL in WSocket::ReceiveSocketData()\n");
		delete p_read_data_buf;
		p_read_data_buf=NULL;
	}

	// Initialize the receiving data buffers
	m_receiving_socket_data=true;
	m_read_data_buf_len=buf_len;
	p_read_data_buf=new char[buf_len];
	memset(p_read_data_buf,0,buf_len);
	return ReceiveBuffer();
}
Пример #6
0
int TSocket::ReceiveSomeMoreSocketData(char *data,unsigned int len,unsigned int max_len)
{
    if(p_read_data_buf!=NULL)
    {
        delete [] p_read_data_buf;
        p_read_data_buf=NULL;
    }

    // Append any new data to this existing data already read in
    m_receiving_some_socket_data=true;
    m_read_data_buf_len=max_len;
    m_num_read=len;
    p_read_data_buf=new char[max_len];
    memcpy(p_read_data_buf,data,len);

    return ReceiveBuffer();
}
Пример #7
0
//
// Called by the user when they get an OnReceive
//
int WSocket::ReceiveData(unsigned int buf_len)
{
	// Initialize the receiving data buffers
	m_receiving_data=true;
	m_num_read=0;
	m_read_data_buf_len=buf_len;

	if(p_read_data_buf!=NULL)
	{
		delete [] p_read_data_buf;
		p_read_data_buf=NULL;
	}

	p_read_data_buf=new unsigned char[buf_len];
	memset(p_read_data_buf,0,buf_len);

	return ReceiveBuffer();
}
Пример #8
0
int TSocket::ContinueToReceiveSocketData()
{
	return ReceiveBuffer();
}
Пример #9
0
int WSocket::ContinueToReceiveData()
{
	return ReceiveBuffer();
}
Пример #10
0
int WSocket::ContinueToReceiveSocketData()
{
//	OutputDebugString("WSocket::ContinueToReceiveSocketData()\n");

	return ReceiveBuffer();
}