Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
29241c4f
Commit
29241c4f
authored
Sep 16, 2011
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
input_plugin: add method check()
To check for errors without reading. The decoder thread wants to do that, before it passes the input stream to the plugin.
parent
6f655eb9
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
78 additions
and
0 deletions
+78
-0
curl_input_plugin.c
src/input/curl_input_plugin.c
+18
-0
rewind_input_plugin.c
src/input/rewind_input_plugin.c
+9
-0
soup_input_plugin.c
src/input/soup_input_plugin.c
+18
-0
input_plugin.h
src/input_plugin.h
+8
-0
input_stream.c
src/input_stream.c
+10
-0
input_stream.h
src/input_stream.h
+9
-0
run_input.c
test/run_input.c
+6
-0
No files found.
src/input/curl_input_plugin.c
View file @
29241c4f
...
...
@@ -774,6 +774,23 @@ input_curl_free(struct input_curl *c)
g_free
(
c
);
}
static
bool
input_curl_check
(
struct
input_stream
*
is
,
GError
**
error_r
)
{
struct
input_curl
*
c
=
(
struct
input_curl
*
)
is
;
g_mutex_lock
(
c
->
mutex
);
bool
success
=
c
->
postponed_error
==
NULL
;
if
(
!
success
)
{
g_propagate_error
(
error_r
,
c
->
postponed_error
);
c
->
postponed_error
=
NULL
;
}
g_mutex_unlock
(
c
->
mutex
);
return
success
;
}
static
struct
tag
*
input_curl_tag
(
struct
input_stream
*
is
)
{
...
...
@@ -1318,6 +1335,7 @@ const struct input_plugin input_plugin_curl = {
.
open
=
input_curl_open
,
.
close
=
input_curl_close
,
.
check
=
input_curl_check
,
.
tag
=
input_curl_tag
,
.
buffer
=
input_curl_buffer
,
.
read
=
input_curl_read
,
...
...
src/input/rewind_input_plugin.c
View file @
29241c4f
...
...
@@ -107,6 +107,14 @@ input_rewind_close(struct input_stream *is)
g_free
(
r
);
}
static
bool
input_rewind_check
(
struct
input_stream
*
is
,
GError
**
error_r
)
{
struct
input_rewind
*
r
=
(
struct
input_rewind
*
)
is
;
return
input_stream_check
(
r
->
input
,
error_r
);
}
static
void
input_rewind_update
(
struct
input_stream
*
is
)
{
...
...
@@ -221,6 +229,7 @@ input_rewind_seek(struct input_stream *is, goffset offset, int whence,
static
const
struct
input_plugin
rewind_input_plugin
=
{
.
close
=
input_rewind_close
,
.
check
=
input_rewind_check
,
.
update
=
input_rewind_update
,
.
tag
=
input_rewind_tag
,
.
buffer
=
input_rewind_buffer
,
...
...
src/input/soup_input_plugin.c
View file @
29241c4f
...
...
@@ -320,6 +320,23 @@ input_soup_close(struct input_stream *is)
g_free
(
s
);
}
static
bool
input_soup_check
(
struct
input_stream
*
is
,
GError
**
error_r
)
{
struct
input_soup
*
s
=
(
struct
input_soup
*
)
is
;
g_mutex_lock
(
s
->
mutex
);
bool
success
=
s
->
postponed_error
==
NULL
;
if
(
!
success
)
{
g_propagate_error
(
error_r
,
s
->
postponed_error
);
s
->
postponed_error
=
NULL
;
}
g_mutex_unlock
(
s
->
mutex
);
return
success
;
}
static
int
input_soup_buffer
(
struct
input_stream
*
is
,
GError
**
error_r
)
{
...
...
@@ -444,6 +461,7 @@ const struct input_plugin input_plugin_soup = {
.
open
=
input_soup_open
,
.
close
=
input_soup_close
,
.
check
=
input_soup_check
,
.
buffer
=
input_soup_buffer
,
.
read
=
input_soup_read
,
.
eof
=
input_soup_eof
,
...
...
src/input_plugin.h
View file @
29241c4f
...
...
@@ -52,6 +52,14 @@ struct input_plugin {
void
(
*
close
)(
struct
input_stream
*
is
);
/**
* Check for errors that may have occurred in the I/O thread.
* May be unimplemented for synchronous plugins.
*
* @return false on error
*/
bool
(
*
check
)(
struct
input_stream
*
is
,
GError
**
error_r
);
/**
* Update the public attributes. Call before access. Can be
* NULL if the plugin always keeps its attributes up to date.
*/
...
...
src/input_stream.c
View file @
29241c4f
...
...
@@ -67,6 +67,16 @@ input_stream_open(const char *url, GError **error_r)
return
NULL
;
}
bool
input_stream_check
(
struct
input_stream
*
is
,
GError
**
error_r
)
{
assert
(
is
!=
NULL
);
assert
(
is
->
plugin
!=
NULL
);
return
is
->
plugin
->
check
==
NULL
||
is
->
plugin
->
check
(
is
,
error_r
);
}
void
input_stream_update
(
struct
input_stream
*
is
)
{
...
...
src/input_stream.h
View file @
29241c4f
...
...
@@ -91,6 +91,15 @@ void
input_stream_close
(
struct
input_stream
*
is
);
/**
* Check for errors that may have occurred in the I/O thread.
*
* @return false on error
*/
gcc_nonnull
(
1
)
bool
input_stream_check
(
struct
input_stream
*
is
,
GError
**
error_r
);
/**
* Update the public attributes. Call before accessing attributes
* such as "ready" or "offset".
*/
...
...
test/run_input.c
View file @
29241c4f
...
...
@@ -100,6 +100,12 @@ dump_input_stream(struct input_stream *is)
break
;
}
if
(
!
input_stream_check
(
is
,
&
error
))
{
g_warning
(
"%s"
,
error
->
message
);
g_error_free
(
error
);
return
EXIT_FAILURE
;
}
return
0
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment