X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fpbd%2Fcrossthread.win.cc;h=5eca5fb4e8daa70ebe6c01230488bbafd2a4a136;hb=a0558694dfdb2a89d54e22d30916ea0118b39301;hp=73ff74ddcfea7ca4e834a19eac89ba3371f9cc77;hpb=91fac4c96dc6210dcc056da70dc608700d7eb570;p=ardour.git diff --git a/libs/pbd/crossthread.win.cc b/libs/pbd/crossthread.win.cc index 73ff74ddcf..5eca5fb4e8 100644 --- a/libs/pbd/crossthread.win.cc +++ b/libs/pbd/crossthread.win.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2009 Paul Davis + Copyright (C) 2009 Paul Davis This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,7 +18,7 @@ */ CrossThreadChannel::CrossThreadChannel (bool non_blocking) - : receive_channel (0) + : receive_channel (0) , receive_source (0) , receive_slot () , send_socket() @@ -32,7 +32,7 @@ CrossThreadChannel::CrossThreadChannel (bool non_blocking) send_address.sin_family = AF_INET; send_address.sin_addr.s_addr = inet_addr("127.0.0.1"); send_address.sin_port = htons(0); - int status = bind(send_socket, (SOCKADDR*)&send_address, + int status = bind(send_socket, (SOCKADDR*)&send_address, sizeof(send_address)); if (status != 0) { @@ -43,7 +43,7 @@ CrossThreadChannel::CrossThreadChannel (bool non_blocking) // make the socket non-blockable if required u_long mode = (u_long)non_blocking; int otp_result = 0; - + otp_result = ioctlsocket(send_socket, FIONBIO, &mode); if (otp_result != NO_ERROR) { std::cerr << "CrossThreadChannel::CrossThreadChannel() Send socket cannot be set to non blocking mode with error: " << WSAGetLastError() << std::endl; @@ -54,9 +54,9 @@ CrossThreadChannel::CrossThreadChannel (bool non_blocking) recv_address.sin_family = AF_INET; recv_address.sin_addr.s_addr = inet_addr("127.0.0.1"); recv_address.sin_port = htons(0); - status = bind(receive_socket, (SOCKADDR*)&recv_address, + status = bind(receive_socket, (SOCKADDR*)&recv_address, sizeof(recv_address)); - + if (status != 0) { std::cerr << "CrossThreadChannel::CrossThreadChannel() Receive socket binding failed with error: " << WSAGetLastError() << std::endl; return; @@ -67,15 +67,15 @@ CrossThreadChannel::CrossThreadChannel (bool non_blocking) // get assigned port number for Receive Socket int recv_addr_len = sizeof(recv_address); status = getsockname(receive_socket, (SOCKADDR*)&recv_address, &recv_addr_len); - + if (status != 0) { std::cerr << "CrossThreadChannel::CrossThreadChannel() Setting receive socket address to local failed with error: " << WSAGetLastError() << std::endl; return; } - + // construct IOChannel receive_channel = g_io_channel_win32_new_socket((gint)receive_socket); - + // set binary data type GIOStatus g_status = g_io_channel_set_encoding (receive_channel, NULL, NULL); if (G_IO_STATUS_NORMAL != g_status ) { @@ -104,7 +104,7 @@ CrossThreadChannel::wakeup () { char c = 0; - // write one byte to wake up a thread which is listening our IOS + // write one byte to wake up a thread which is listening our IOS sendto(send_socket, &c, sizeof(c), 0, (SOCKADDR*)&recv_address, sizeof(recv_address) ); } @@ -125,7 +125,7 @@ CrossThreadChannel::drain () if (G_IO_STATUS_NORMAL != g_status) { std::cerr << "CrossThreadChannel::CrossThreadChannel() Cannot drain from read buffer! " << g_status << std::endl; - + if (g_error) { std::cerr << "Error is Domain: " << g_error->domain << " Code: " << g_error->code << std::endl; g_clear_error(&g_error); @@ -173,7 +173,7 @@ CrossThreadChannel::poll_for_request() return false; } -int +int CrossThreadChannel::receive (char& msg, bool wait) { gsize read = 0; @@ -184,7 +184,7 @@ CrossThreadChannel::receive (char& msg, bool wait) return -1; } } - + // fetch the message from the channel. GIOStatus g_status = g_io_channel_read_chars (receive_channel, &msg, sizeof(msg), &read, &g_error);