summaryrefslogtreecommitdiffstats
path: root/client/windows
diff options
context:
space:
mode:
authorYonit Halperin <yhalperi@redhat.com>2009-10-20 11:18:56 +0200
committerYaniv Kamay <ykamay@redhat.com>2009-11-09 17:30:49 +0200
commit49f5e5973c5be6ba23f1dbe9c4ef5ab08017e962 (patch)
treeeee0f14f61e2c7209576570de63e1927461b516c /client/windows
parent8d5b738ba169c44d223ab6d99ec12e763ce5bc8e (diff)
downloadspice-49f5e5973c5be6ba23f1dbe9c4ef5ab08017e962.tar.gz
spice-49f5e5973c5be6ba23f1dbe9c4ef5ab08017e962.tar.xz
spice-49f5e5973c5be6ba23f1dbe9c4ef5ab08017e962.zip
spice client: Transfer all channels run loop from EventsLoop class to ProcessLoop class
Diffstat (limited to 'client/windows')
-rw-r--r--client/windows/events_loop_p.cpp158
-rw-r--r--client/windows/events_loop_p.h44
-rw-r--r--client/windows/record.cpp4
-rw-r--r--client/windows/record.h2
-rw-r--r--client/windows/redc.vcproj12
5 files changed, 3 insertions, 217 deletions
diff --git a/client/windows/events_loop_p.cpp b/client/windows/events_loop_p.cpp
deleted file mode 100644
index 7329d161..00000000
--- a/client/windows/events_loop_p.cpp
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- Copyright (C) 2009 Red Hat, Inc.
-
- 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 the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "common.h"
-#include "events_loop.h"
-#include "debug.h"
-#include "utils.h"
-
-
-EventsLoop::EventsLoop()
-{
-}
-
-EventsLoop::~EventsLoop()
-{
-}
-
-void EventsLoop::run()
-{
- for (;;) {
- run_once();
- }
-}
-
-void EventsLoop::run_once(int timeout_milli)
-{
- DWORD wait_res = WaitForMultipleObjects(_handles.size(), &_handles[0], FALSE, timeout_milli);
- if (wait_res == WAIT_FAILED) {
- THROW("wait failed");
- }
- int event_index = wait_res - WAIT_OBJECT_0;
- if (event_index < 0 || event_index >= (int)_events.size()) {
- THROW("invalid event id");
- }
- _events[event_index]->action();
-}
-
-void EventsLoop::add_socket(Socket& socket)
-{
- HANDLE event = CreateEvent(NULL, FALSE, FALSE, NULL);
- if (!event) {
- THROW("create event failed");
- }
- if (WSAEventSelect(socket.get_socket(), event, FD_READ | FD_WRITE | FD_CLOSE) == SOCKET_ERROR) {
- CloseHandle(event);
- THROW("event select failed");
- }
- int size = _events.size();
- _events.resize(size + 1);
- _handles.resize(size + 1);
- _events[size] = &socket;
- _handles[size] = event;
-}
-
-void EventsLoop::remove_socket(Socket& socket)
-{
- int size = _events.size();
- for (int i = 0; i < size; i++) {
- if (_events[i] == &socket) {
- if (WSAEventSelect(socket.get_socket(), NULL, 0) == SOCKET_ERROR) {
- THROW("event select failed");
- }
- u_long arg = 0;
- if (ioctlsocket(socket.get_socket(), FIONBIO, &arg) == SOCKET_ERROR) {
- THROW("set blocking mode failed");
- }
- CloseHandle(_handles[i]);
- for (i++; i < size; i++) {
- _events[i - 1] = _events[i];
- _handles[i - 1] = _handles[i];
- }
- _events.resize(size - 1);
- _handles.resize(size - 1);
- return;
- }
- }
- THROW("socket not found");
-}
-
-void EventsLoop::add_trigger(Trigger& trigger)
-{
- int size = _events.size();
- _events.resize(size + 1);
- _handles.resize(size + 1);
- _events[size] = &trigger;
- _handles[size] = trigger.get_handle();
-}
-
-void EventsLoop::remove_trigger(Trigger& trigger)
-{
- int size = _events.size();
- for (int i = 0; i < size; i++) {
- if (_events[i] == &trigger) {
- for (i++; i < size; i++) {
- _events[i - 1] = _events[i];
- _handles[i - 1] = _handles[i];
- }
- _events.resize(size - 1);
- _handles.resize(size - 1);
- return;
- }
- }
- THROW("trigger not found");
-}
-
-EventsLoop::Trigger::Trigger()
-{
- if (!(event = CreateEvent(NULL, FALSE, FALSE, NULL))) {
- THROW("create event failed");
- }
-}
-
-EventsLoop::Trigger::~Trigger()
-{
- CloseHandle(event);
-}
-
-void EventsLoop::Trigger::trigger()
-{
- if (!SetEvent(event)) {
- THROW("set event failed");
- }
-}
-
-void EventsLoop::Trigger::reset()
-{
- if (!ResetEvent(event)) {
- THROW("set event failed");
- }
-}
-
-void EventsLoop::Trigger::action()
-{
- on_event();
-}
-
-void EventsLoop::add_file(File& file)
-{
-}
-
-void EventsLoop::remove_file(File& file)
-{
-}
-
diff --git a/client/windows/events_loop_p.h b/client/windows/events_loop_p.h
deleted file mode 100644
index 6bac7b94..00000000
--- a/client/windows/events_loop_p.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- Copyright (C) 2009 Red Hat, Inc.
-
- 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 the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _H_EVENTS_LOOP_P
-#define _H_EVENTS_LOOP_P
-
-#include "common.h"
-
-#include <vector>
-
-class EventSourceOld;
-
-class EventsLoop_p {
-public:
- class Trigger_p;
-public:
- std::vector<EventSourceOld*> _events;
- std::vector<HANDLE> _handles;
-};
-
-class EventsLoop_p::Trigger_p {
-public:
- HANDLE get_handle() { return event;}
-
-public:
- HANDLE event;
-};
-
-#endif
-
diff --git a/client/windows/record.cpp b/client/windows/record.cpp
index 52fc478e..bd9bc022 100644
--- a/client/windows/record.cpp
+++ b/client/windows/record.cpp
@@ -61,7 +61,7 @@ WaveRecorder::WaveRecorder(Platform::RecordClinet& client, uint32_t sampels_per_
_frame_pos = _frame;
_frame_end = _frame + frame_bytes;
init_ring(sampels_per_sec, frame_bytes, frame_align);
- _client.add_evnet_sorce(*this);
+ _client.add_event_source(*this);
} catch (...) {
delete[] _ring;
delete[] _frame;
@@ -74,7 +74,7 @@ WaveRecorder::~WaveRecorder()
{
waveInReset(_wave_in);
reclaim();
- _client.remove_evnet_sorce(*this);
+ _client.remove_event_source(*this);
waveInClose(_wave_in);
delete[] _ring;
delete[] _frame;
diff --git a/client/windows/record.h b/client/windows/record.h
index dab69fa0..cd33a2aa 100644
--- a/client/windows/record.h
+++ b/client/windows/record.h
@@ -21,7 +21,7 @@
#include "audio_devices.h"
#include "platform.h"
-class WaveRecorder: public WaveRecordAbstract, public EventsLoop::Trigger {
+class WaveRecorder: public WaveRecordAbstract, public EventSources::Trigger {
public:
WaveRecorder(Platform::RecordClinet& client, uint32_t sampels_per_sec,
uint32_t bits_per_sample, uint32_t channels);
diff --git a/client/windows/redc.vcproj b/client/windows/redc.vcproj
index c63e1f1c..8df2214c 100644
--- a/client/windows/redc.vcproj
+++ b/client/windows/redc.vcproj
@@ -229,10 +229,6 @@
>
</File>
<File
- RelativePath=".\events_loop_p.cpp"
- >
- </File>
- <File
RelativePath="..\gdi_canvas.cpp"
>
</File>
@@ -453,14 +449,6 @@
>
</File>
<File
- RelativePath="..\events_loop.h"
- >
- </File>
- <File
- RelativePath=".\events_loop_p.h"
- >
- </File>
- <File
RelativePath="..\..\common\gdi_canvas.h"
>
</File>