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
cad37b2e
Commit
cad37b2e
authored
Nov 10, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder: wrapper functions for methods stream_decode() and file_decode()
Added lots of assertions to the wrapper functions.
parent
84b540f4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
5 deletions
+66
-5
decoder_thread.c
src/decoder_thread.c
+66
-5
No files found.
src/decoder_thread.c
View file @
cad37b2e
...
@@ -45,6 +45,65 @@ decoder_try_decode(const struct decoder_plugin *plugin,
...
@@ -45,6 +45,65 @@ decoder_try_decode(const struct decoder_plugin *plugin,
return
ret
;
return
ret
;
}
}
static
bool
decoder_stream_decode
(
const
struct
decoder_plugin
*
plugin
,
struct
decoder
*
decoder
,
struct
input_stream
*
input_stream
)
{
bool
ret
;
assert
(
plugin
!=
NULL
);
assert
(
plugin
->
stream_decode
!=
NULL
);
assert
(
decoder
!=
NULL
);
assert
(
!
decoder
->
stream_tag_sent
);
assert
(
input_stream
!=
NULL
);
assert
(
input_stream
->
ready
);
assert
(
dc
.
state
==
DECODE_STATE_START
);
ret
=
plugin
->
stream_decode
(
decoder
,
input_stream
);
if
(
ret
)
{
/* if the method has succeeded, the plugin must have
called decoder_initialized() */
assert
(
dc
.
state
==
DECODE_STATE_DECODE
);
}
else
{
/* no decoder_initialized() allowed when the plugin
hasn't recognized the file format */
assert
(
dc
.
state
==
DECODE_STATE_START
);
}
return
ret
;
}
static
bool
decoder_file_decode
(
const
struct
decoder_plugin
*
plugin
,
struct
decoder
*
decoder
,
const
char
*
path
)
{
bool
ret
;
assert
(
plugin
!=
NULL
);
assert
(
plugin
->
stream_decode
!=
NULL
);
assert
(
decoder
!=
NULL
);
assert
(
!
decoder
->
stream_tag_sent
);
assert
(
path
!=
NULL
);
assert
(
path
[
0
]
==
'/'
);
assert
(
dc
.
state
==
DECODE_STATE_START
);
ret
=
plugin
->
file_decode
(
decoder
,
path
);
if
(
ret
)
{
/* if the method has succeeded, the plugin must have
called decoder_initialized() */
assert
(
dc
.
state
==
DECODE_STATE_DECODE
);
}
else
{
/* no decoder_initialized() allowed when the plugin
hasn't recognized the file format */
assert
(
dc
.
state
==
DECODE_STATE_START
);
}
return
ret
;
}
static
void
decoder_run
(
void
)
static
void
decoder_run
(
void
)
{
{
struct
song
*
song
=
dc
.
next_song
;
struct
song
*
song
=
dc
.
next_song
;
...
@@ -112,7 +171,8 @@ static void decoder_run(void)
...
@@ -112,7 +171,8 @@ static void decoder_run(void)
continue
;
continue
;
if
(
!
decoder_try_decode
(
plugin
,
&
input_stream
))
if
(
!
decoder_try_decode
(
plugin
,
&
input_stream
))
continue
;
continue
;
ret
=
plugin
->
stream_decode
(
&
decoder
,
&
input_stream
);
ret
=
decoder_stream_decode
(
plugin
,
&
decoder
,
&
input_stream
);
break
;
break
;
}
}
...
@@ -125,7 +185,7 @@ static void decoder_run(void)
...
@@ -125,7 +185,7 @@ static void decoder_run(void)
continue
;
continue
;
if
(
!
decoder_try_decode
(
plugin
,
&
input_stream
))
if
(
!
decoder_try_decode
(
plugin
,
&
input_stream
))
continue
;
continue
;
ret
=
plugin
->
stream_decode
(
&
decoder
,
ret
=
decoder_stream_decode
(
plugin
,
&
decoder
,
&
input_stream
);
&
input_stream
);
break
;
break
;
}
}
...
@@ -137,7 +197,7 @@ static void decoder_run(void)
...
@@ -137,7 +197,7 @@ static void decoder_run(void)
/* we already know our mp3Plugin supports streams, no
/* we already know our mp3Plugin supports streams, no
* need to check for stream{Types,DecodeFunc} */
* need to check for stream{Types,DecodeFunc} */
if
((
plugin
=
decoder_plugin_from_name
(
"mp3"
)))
{
if
((
plugin
=
decoder_plugin_from_name
(
"mp3"
)))
{
ret
=
plugin
->
stream_decode
(
&
decoder
,
ret
=
decoder_stream_decode
(
plugin
,
&
decoder
,
&
input_stream
);
&
input_stream
);
}
}
}
}
...
@@ -151,10 +211,11 @@ static void decoder_run(void)
...
@@ -151,10 +211,11 @@ static void decoder_run(void)
if
(
plugin
->
file_decode
!=
NULL
)
{
if
(
plugin
->
file_decode
!=
NULL
)
{
input_stream_close
(
&
input_stream
);
input_stream_close
(
&
input_stream
);
close_instream
=
false
;
close_instream
=
false
;
ret
=
plugin
->
file_decode
(
&
decoder
,
uri
);
ret
=
decoder_file_decode
(
plugin
,
&
decoder
,
uri
);
break
;
break
;
}
else
if
(
plugin
->
stream_decode
!=
NULL
)
{
}
else
if
(
plugin
->
stream_decode
!=
NULL
)
{
ret
=
plugin
->
stream_decode
(
&
decoder
,
ret
=
decoder_stream_decode
(
plugin
,
&
decoder
,
&
input_stream
);
&
input_stream
);
break
;
break
;
}
}
...
...
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