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
7cbd9821
Commit
7cbd9821
authored
Oct 30, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ffmpeg: make ffmpeg_helper() return bool
ffmpeg_try_decode() did not interpret ffmpeg_helper()'s return value properly; migrate everything to bool to make it consistent.
parent
078d83ca
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
24 deletions
+21
-24
ffmpeg_plugin.c
src/decoder/ffmpeg_plugin.c
+21
-24
No files found.
src/decoder/ffmpeg_plugin.c
View file @
7cbd9821
...
...
@@ -134,18 +134,19 @@ static bool ffmpeg_init(void)
return
true
;
}
static
int
ffmpeg_helper
(
struct
input_stream
*
input
,
int
(
*
callback
)(
BasePtrs
*
ptrs
),
static
bool
ffmpeg_helper
(
struct
input_stream
*
input
,
bool
(
*
callback
)(
BasePtrs
*
ptrs
),
BasePtrs
*
ptrs
)
{
AVFormatContext
*
pFormatCtx
;
AVCodecContext
*
aCodecCtx
;
AVCodec
*
aCodec
;
int
ret
,
audioStream
;
int
audioStream
;
unsigned
i
;
FopsHelper
fopshelp
=
{
.
url
=
"mpd://X"
,
/* only the mpd:// prefix matters */
};
bool
ret
;
fopshelp
.
input
=
input
;
if
(
ptrs
&&
ptrs
->
decoder
)
{
...
...
@@ -157,12 +158,12 @@ ffmpeg_helper(struct input_stream *input, int (*callback)(BasePtrs *ptrs),
//ffmpeg works with ours "fileops" helper
if
(
av_open_input_file
(
&
pFormatCtx
,
fopshelp
.
url
,
NULL
,
0
,
NULL
)
!=
0
)
{
ERROR
(
"Open failed!
\n
"
);
return
-
1
;
return
false
;
}
if
(
av_find_stream_info
(
pFormatCtx
)
<
0
)
{
ERROR
(
"Couldn't find stream info!
\n
"
);
return
-
1
;
return
false
;
}
audioStream
=
-
1
;
...
...
@@ -175,7 +176,7 @@ ffmpeg_helper(struct input_stream *input, int (*callback)(BasePtrs *ptrs),
if
(
audioStream
==-
1
)
{
ERROR
(
"No audio stream inside!
\n
"
);
return
-
1
;
return
false
;
}
aCodecCtx
=
pFormatCtx
->
streams
[
audioStream
]
->
codec
;
...
...
@@ -183,12 +184,12 @@ ffmpeg_helper(struct input_stream *input, int (*callback)(BasePtrs *ptrs),
if
(
!
aCodec
)
{
ERROR
(
"Unsupported audio codec!
\n
"
);
return
-
1
;
return
false
;
}
if
(
avcodec_open
(
aCodecCtx
,
aCodec
)
<
0
)
{
ERROR
(
"Could not open codec!
\n
"
);
return
-
1
;
return
false
;
}
if
(
callback
)
{
...
...
@@ -199,7 +200,7 @@ ffmpeg_helper(struct input_stream *input, int (*callback)(BasePtrs *ptrs),
ret
=
(
*
callback
)(
ptrs
);
}
else
ret
=
0
;
ret
=
true
;
avcodec_close
(
aCodecCtx
);
av_close_input_file
(
pFormatCtx
);
...
...
@@ -210,16 +211,11 @@ ffmpeg_helper(struct input_stream *input, int (*callback)(BasePtrs *ptrs),
static
bool
ffmpeg_try_decode
(
struct
input_stream
*
input
)
{
int
ret
;
if
(
input
->
seekable
)
{
ret
=
ffmpeg_helper
(
input
,
NULL
,
NULL
);
}
else
{
ret
=
0
;
}
return
(
ret
==
-
1
?
0
:
1
);
return
input
->
seekable
&&
ffmpeg_helper
(
input
,
NULL
,
NULL
);
}
static
int
ffmpeg_decode_internal
(
BasePtrs
*
base
)
static
bool
ffmpeg_decode_internal
(
BasePtrs
*
base
)
{
struct
decoder
*
decoder
=
base
->
decoder
;
AVCodecContext
*
aCodecCtx
=
base
->
aCodecCtx
;
...
...
@@ -292,7 +288,7 @@ static int ffmpeg_decode_internal(BasePtrs *base)
}
}
while
(
decoder_get_command
(
decoder
)
!=
DECODE_COMMAND_STOP
);
return
0
;
return
true
;
}
static
bool
...
...
@@ -303,10 +299,10 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
base
.
input
=
input
;
base
.
decoder
=
decoder
;
return
ffmpeg_helper
(
input
,
ffmpeg_decode_internal
,
&
base
)
==
0
;
return
ffmpeg_helper
(
input
,
ffmpeg_decode_internal
,
&
base
);
}
static
int
ffmpeg_tag_internal
(
BasePtrs
*
base
)
static
bool
ffmpeg_tag_internal
(
BasePtrs
*
base
)
{
struct
tag
*
tag
=
(
struct
tag
*
)
base
->
tag
;
...
...
@@ -315,7 +311,8 @@ static int ffmpeg_tag_internal(BasePtrs *base)
}
else
{
tag
->
time
=
0
;
}
return
0
;
return
true
;
}
//no tag reading in ffmpeg, check if playable
...
...
@@ -323,7 +320,7 @@ static struct tag *ffmpeg_tag(char *file)
{
struct
input_stream
input
;
BasePtrs
base
;
int
ret
;
bool
ret
;
struct
tag
*
tag
=
NULL
;
if
(
!
input_stream_open
(
&
input
,
file
))
{
...
...
@@ -335,9 +332,9 @@ static struct tag *ffmpeg_tag(char *file)
base
.
decoder
=
NULL
;
base
.
tag
=
tag
;
ret
=
ffmpeg_helper
(
&
input
,
ffmpeg_tag_internal
,
&
base
);
if
(
ret
!=
0
)
{
ret
=
ffmpeg_helper
(
&
input
,
ffmpeg_tag_internal
,
&
base
);
if
(
ret
)
{
free
(
tag
);
tag
=
NULL
;
}
...
...
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