From 278c40f301b7adddc6a40c0b9061356b49909ed8 Mon Sep 17 00:00:00 2001 From: Yonit Halperin Date: Mon, 9 Nov 2009 17:20:30 +0200 Subject: spice client: cosmetic changes --- client/audio_channels.h | 2 +- client/platform.h | 9 ++++----- client/process_loop.cpp | 32 +++++++++++++++++++------------- client/process_loop.h | 5 +++++ client/red_channel.h | 1 - client/windows/platform.cpp | 2 +- client/windows/record.cpp | 2 +- client/windows/record.h | 4 ++-- client/x11/platform.cpp | 2 +- client/x11/record.cpp | 2 +- client/x11/record.h | 4 ++-- 11 files changed, 37 insertions(+), 28 deletions(-) (limited to 'client') diff --git a/client/audio_channels.h b/client/audio_channels.h index 6a1c3a80..798917c3 100644 --- a/client/audio_channels.h +++ b/client/audio_channels.h @@ -58,7 +58,7 @@ private: uint32_t _frame_count; }; -class RecordChannel: public RedChannel, private Platform::RecordClinet { +class RecordChannel: public RedChannel, private Platform::RecordClient { public: RecordChannel(RedClient& client, uint32_t id); ~RecordChannel(void); diff --git a/client/platform.h b/client/platform.h index ef527d38..fec3244d 100644 --- a/client/platform.h +++ b/client/platform.h @@ -65,8 +65,8 @@ public: static void set_thread_priority(void *thread, ThreadPriority priority); - class RecordClinet; - static WaveRecordAbstract* create_recorder(RecordClinet& client, + class RecordClient; + static WaveRecordAbstract* create_recorder(RecordClient& client, uint32_t sampels_per_sec, uint32_t bits_per_sample, uint32_t channels); @@ -114,10 +114,9 @@ public: virtual void on_monitors_change() = 0; }; -// TODO: tmp till all channels work with ProcessLoop -class Platform::RecordClinet { +class Platform::RecordClient { public: - virtual ~RecordClinet() {} + virtual ~RecordClient() {} virtual void add_event_source(EventSources::File& evnet_source) = 0; virtual void remove_event_source(EventSources::File& evnet_source) = 0; virtual void add_event_source(EventSources::Trigger& evnet_source) = 0; diff --git a/client/process_loop.cpp b/client/process_loop.cpp index 41aac43e..66f676f3 100644 --- a/client/process_loop.cpp +++ b/client/process_loop.cpp @@ -97,7 +97,7 @@ int EventsQueue::push_event(Event* event) { Lock lock(_events_lock); _events.push_back(event); - event->_generation = _events_gen; + event->set_generation(_events_gen); event->ref(); #ifdef RED_DEBUG event->set_process_loop(&_owner); @@ -116,7 +116,7 @@ void EventsQueue::process_events() return; } event = _events.front(); - if (event->_generation == _events_gen) { + if (event->get_generation() == _events_gen) { return; } _events.pop_front(); @@ -160,6 +160,22 @@ void Timer::disarm() _is_armed = false; } +#define TIMER_COMPENSATION + +void Timer::calc_next_expiration_time(uint64_t now) +{ +#ifndef TIMER_COMPENSATION + _expiratoin = now; +#endif + calc_next_expiration_time(); +#ifdef TIMER_COMPENSATION + if (_expiration <= now) { + _expiration = now; + calc_next_expiration_time(); + } +#endif +} + uint64_t Timer::get_now() { return (Platform::get_monolithic_time() / 1000 / 1000); @@ -226,7 +242,6 @@ int TimersQueue::get_soonest_timeout() return (int)(next_time - now); } -#define TIMER_COMPENSATION void TimersQueue::timers_action() { @@ -238,16 +253,7 @@ void TimersQueue::timers_action() ((*iter)->get_expiration() <= now)) { Timer* timer = *iter; _armed_timers.erase(iter); -#ifndef TIMER_COMPENSATION - timer->_experatoin = now; -#endif - timer->calc_next_expiration_time(); -#ifdef TIMER_COMPENSATION - if (timer->_expiration <= now) { - timer->_expiration = now; - timer->calc_next_expiration_time(); - } -#endif + timer->calc_next_expiration_time(now); _armed_timers.insert(timer); timer->response(_owner); } diff --git a/client/process_loop.h b/client/process_loop.h index 0b052522..df8650dc 100644 --- a/client/process_loop.h +++ b/client/process_loop.h @@ -64,6 +64,10 @@ protected: AbstractProcessLoop* _process_loop; #endif +private: + void set_generation(uint32_t gen) { _generation = gen;} + uint32_t get_generation() { return _generation;} + private: uint32_t _generation; @@ -127,6 +131,7 @@ private: void disarm(); uint64_t get_expiration() const { return _expiration;} void calc_next_expiration_time() { _expiration += _interval;} + void calc_next_expiration_time(uint64_t now); static uint64_t get_now(); diff --git a/client/red_channel.h b/client/red_channel.h index 670d6521..c2f94bd7 100644 --- a/client/red_channel.h +++ b/client/red_channel.h @@ -108,7 +108,6 @@ struct SyncInfo { class RedChannel: public RedChannelBase { public: - friend class RedCannel; class MessageHandler; class OutMessage; diff --git a/client/windows/platform.cpp b/client/windows/platform.cpp index b5faf758..d93283e5 100644 --- a/client/windows/platform.cpp +++ b/client/windows/platform.cpp @@ -405,7 +405,7 @@ void Platform::set_process_loop(ProcessLoop& main_process_loop) main_loop = &main_process_loop; } -WaveRecordAbstract* Platform::create_recorder(RecordClinet& client, +WaveRecordAbstract* Platform::create_recorder(RecordClient& client, uint32_t sampels_per_sec, uint32_t bits_per_sample, uint32_t channels) diff --git a/client/windows/record.cpp b/client/windows/record.cpp index bd9bc022..d962fb7d 100644 --- a/client/windows/record.cpp +++ b/client/windows/record.cpp @@ -29,7 +29,7 @@ static void CALLBACK in_proc(HWAVEIN handle, UINT msg, DWORD user_data, DWORD pa recorder->trigger(); } -WaveRecorder::WaveRecorder(Platform::RecordClinet& client, uint32_t sampels_per_sec, +WaveRecorder::WaveRecorder(Platform::RecordClient& client, uint32_t sampels_per_sec, uint32_t bits_per_sample, uint32_t channels) : _client (client) , _ring (NULL) diff --git a/client/windows/record.h b/client/windows/record.h index cd33a2aa..283f2824 100644 --- a/client/windows/record.h +++ b/client/windows/record.h @@ -23,7 +23,7 @@ class WaveRecorder: public WaveRecordAbstract, public EventSources::Trigger { public: - WaveRecorder(Platform::RecordClinet& client, uint32_t sampels_per_sec, + WaveRecorder(Platform::RecordClient& client, uint32_t sampels_per_sec, uint32_t bits_per_sample, uint32_t channels); virtual ~WaveRecorder(); @@ -42,7 +42,7 @@ private: void push_frames(); private: - Platform::RecordClinet& _client; + Platform::RecordClient& _client; HWAVEIN _wave_in; uint8_t* _ring; uint32_t _ring_item_size; diff --git a/client/x11/platform.cpp b/client/x11/platform.cpp index 8f318f2d..2c9a646a 100644 --- a/client/x11/platform.cpp +++ b/client/x11/platform.cpp @@ -2212,7 +2212,7 @@ void Platform::set_keyboard_modifiers(uint32_t modifiers) } } -WaveRecordAbstract* Platform::create_recorder(RecordClinet& client, +WaveRecordAbstract* Platform::create_recorder(RecordClient& client, uint32_t sampels_per_sec, uint32_t bits_per_sample, uint32_t channels) diff --git a/client/x11/record.cpp b/client/x11/record.cpp index a220878c..46abb29e 100644 --- a/client/x11/record.cpp +++ b/client/x11/record.cpp @@ -42,7 +42,7 @@ void WaveRecorder::EventTrigger::on_event() _recorder.on_event(); } -WaveRecorder::WaveRecorder(Platform::RecordClinet& client, +WaveRecorder::WaveRecorder(Platform::RecordClient& client, uint32_t sampels_per_sec, uint32_t bits_per_sample, uint32_t channels) diff --git a/client/x11/record.h b/client/x11/record.h index 540f1d2f..753665f0 100644 --- a/client/x11/record.h +++ b/client/x11/record.h @@ -26,7 +26,7 @@ class WaveRecorder: public WaveRecordAbstract { public: - WaveRecorder(Platform::RecordClinet& client, + WaveRecorder(Platform::RecordClient& client, uint32_t sampels_per_sec, uint32_t bits_per_sample, uint32_t channels); @@ -44,7 +44,7 @@ private: void on_event(); private: - Platform::RecordClinet& _client; + Platform::RecordClient& _client; snd_pcm_t* _pcm; snd_pcm_hw_params_t* _hw_params; snd_pcm_sw_params_t* _sw_params; -- cgit