event/MultiSocketMonitor: PrepareSockets() returns timeout
Simplify the API, don't use GLib specific integer type.
This commit is contained in:
		| @@ -101,7 +101,10 @@ public: | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| protected: | protected: | ||||||
| 	virtual void PrepareSockets(gcc_unused gint *timeout_r) {} | 	/** | ||||||
|  | 	 * @return timeout [ms] or -1 for no timeout | ||||||
|  | 	 */ | ||||||
|  | 	virtual int PrepareSockets() = 0; | ||||||
| 	virtual bool CheckSockets() const { return false; } | 	virtual bool CheckSockets() const { return false; } | ||||||
| 	virtual void DispatchSockets() = 0; | 	virtual void DispatchSockets() = 0; | ||||||
|  |  | ||||||
| @@ -114,7 +117,7 @@ public: | |||||||
|  |  | ||||||
| private: | private: | ||||||
| 	bool Prepare(gint *timeout_r) { | 	bool Prepare(gint *timeout_r) { | ||||||
| 		PrepareSockets(timeout_r); | 		*timeout_r = PrepareSockets(); | ||||||
| 		return false; | 		return false; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|   | |||||||
| @@ -204,7 +204,7 @@ public: | |||||||
| private: | private: | ||||||
| 	void UpdateSockets(); | 	void UpdateSockets(); | ||||||
|  |  | ||||||
| 	virtual void PrepareSockets(gcc_unused gint *timeout_r) override; | 	virtual int PrepareSockets() override; | ||||||
| 	virtual bool CheckSockets() const override; | 	virtual bool CheckSockets() const override; | ||||||
| 	virtual void DispatchSockets() override; | 	virtual void DispatchSockets() override; | ||||||
| }; | }; | ||||||
| @@ -536,8 +536,8 @@ input_curl_perform(void) | |||||||
| 	return true; | 	return true; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | int | ||||||
| CurlSockets::PrepareSockets(gint *timeout_r) | CurlSockets::PrepareSockets() | ||||||
| { | { | ||||||
| 	UpdateSockets(); | 	UpdateSockets(); | ||||||
|  |  | ||||||
| @@ -556,12 +556,13 @@ CurlSockets::PrepareSockets(gint *timeout_r) | |||||||
| 			   Let's use a lower limit of 10ms. */ | 			   Let's use a lower limit of 10ms. */ | ||||||
| 			timeout2 = 10; | 			timeout2 = 10; | ||||||
|  |  | ||||||
| 		*timeout_r = timeout2; |  | ||||||
|  |  | ||||||
| 		have_timeout = timeout2 >= 0; | 		have_timeout = timeout2 >= 0; | ||||||
| 	} else | 		return timeout2; | ||||||
|  | 	} else { | ||||||
| 		g_warning("curl_multi_timeout() failed: %s\n", | 		g_warning("curl_multi_timeout() failed: %s\n", | ||||||
| 			  curl_multi_strerror(mcode)); | 			  curl_multi_strerror(mcode)); | ||||||
|  | 		return -1; | ||||||
|  | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| bool | bool | ||||||
|   | |||||||
| @@ -44,7 +44,7 @@ public: | |||||||
| 		:MultiSocketMonitor(_loop), mixer(_mixer) {} | 		:MultiSocketMonitor(_loop), mixer(_mixer) {} | ||||||
|  |  | ||||||
| private: | private: | ||||||
| 	virtual void PrepareSockets(gcc_unused gint *timeout_r) override; | 	virtual int PrepareSockets() override; | ||||||
| 	virtual void DispatchSockets() override; | 	virtual void DispatchSockets() override; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| @@ -83,8 +83,8 @@ alsa_mixer_quark(void) | |||||||
| 	return g_quark_from_static_string("alsa_mixer"); | 	return g_quark_from_static_string("alsa_mixer"); | ||||||
| } | } | ||||||
|  |  | ||||||
| void | int | ||||||
| AlsaMixerMonitor::PrepareSockets(gcc_unused gint *timeout_r) | AlsaMixerMonitor::PrepareSockets() | ||||||
| { | { | ||||||
| 	int count = snd_mixer_poll_descriptors_count(mixer); | 	int count = snd_mixer_poll_descriptors_count(mixer); | ||||||
| 	if (count < 0) | 	if (count < 0) | ||||||
| @@ -113,6 +113,8 @@ AlsaMixerMonitor::PrepareSockets(gcc_unused gint *timeout_r) | |||||||
| 	for (auto i = pfds; i != end; ++i) | 	for (auto i = pfds; i != end; ++i) | ||||||
| 		if (i->events != 0) | 		if (i->events != 0) | ||||||
| 			AddSocket(i->fd, i->events); | 			AddSocket(i->fd, i->events); | ||||||
|  |  | ||||||
|  | 	return -1; | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Max Kellermann
					Max Kellermann