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
1be91059
Commit
1be91059
authored
May 18, 2004
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ok, after starting good, this is a little less blocky for playing streams
git-svn-id:
https://svn.musicpd.org/mpd/trunk@1073
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
e9ace463
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
19 deletions
+29
-19
configure.ac
configure.ac
+1
-0
mp3_decode.c
src/mp3_decode.c
+28
-19
No files found.
configure.ac
View file @
1be91059
...
...
@@ -21,6 +21,7 @@ AC_SUBST(MPD_CFLAGS)
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LIBTOOL
AC_PROG_MAKE_SET
AM_CONFIG_HEADER(config.h)
...
...
src/mp3_decode.c
View file @
1be91059
...
...
@@ -134,6 +134,7 @@ typedef struct _mp3DecodeData {
int
flush
;
unsigned
long
bitRate
;
InputStream
*
inStream
;
int
bufferReset
;
}
mp3DecodeData
;
void
initMp3DecodeData
(
mp3DecodeData
*
data
,
InputStream
*
inStream
)
{
...
...
@@ -147,6 +148,7 @@ void initMp3DecodeData(mp3DecodeData * data, InputStream * inStream) {
data
->
currentFrame
=
0
;
data
->
flush
=
1
;
data
->
inStream
=
inStream
;
data
->
bufferReset
=
0
;
mad_stream_init
(
&
data
->
stream
);
data
->
stream
.
options
|=
MAD_OPTION_IGNORECRC
;
...
...
@@ -155,19 +157,22 @@ void initMp3DecodeData(mp3DecodeData * data, InputStream * inStream) {
mad_timer_reset
(
&
data
->
timer
);
}
int
fillMp3InputBuffer
(
mp3DecodeData
*
data
,
long
offset
)
{
int
seekMp3InputBuffer
(
mp3DecodeData
*
data
,
long
offset
)
{
if
(
seekInputStream
(
data
->
inStream
,
offset
,
SEEK_SET
)
<
0
)
{
return
-
1
;
}
data
->
bufferReset
=
1
;
return
0
;
}
int
fillMp3InputBuffer
(
mp3DecodeData
*
data
)
{
size_t
readSize
;
size_t
remaining
;
size_t
readed
;
unsigned
char
*
readStart
;
if
(
offset
>=
0
)
{
if
(
seekInputStream
(
data
->
inStream
,
offset
,
SEEK_SET
)
<
0
)
{
return
-
1
;
}
}
if
(
offset
==-
1
&&
(
data
->
stream
).
next_frame
!=
NULL
)
{
if
(
!
data
->
bufferReset
&&
(
data
->
stream
).
next_frame
!=
NULL
)
{
remaining
=
(
data
->
stream
).
bufend
-
(
data
->
stream
).
next_frame
;
memmove
(
data
->
readBuffer
,(
data
->
stream
).
next_frame
,
remaining
);
readStart
=
(
data
->
readBuffer
)
+
remaining
;
...
...
@@ -177,14 +182,14 @@ int fillMp3InputBuffer(mp3DecodeData * data, long offset) {
readSize
=
READ_BUFFER_SIZE
;
readStart
=
data
->
readBuffer
,
remaining
=
0
;
data
->
bufferReset
=
0
;
}
readed
=
0
;
while
(
readed
==
0
&&
!
inputStreamAtEOF
(
data
->
inStream
))
{
readed
=
readFromInputStream
(
data
->
inStream
,
readStart
,
(
size_t
)
1
,
readSize
);
}
if
(
readed
<=
0
)
return
-
1
;
readed
=
readFromInputStream
(
data
->
inStream
,
readStart
,
(
size_t
)
1
,
readSize
);
if
(
readed
<=
0
&&
inputStreamAtEOF
(
data
->
inStream
))
return
-
1
;
/* sleep for a fraction of a second! */
else
if
(
readed
==
0
)
my_usleep
(
10
);
mad_stream_buffer
(
&
data
->
stream
,
data
->
readBuffer
,
readed
+
remaining
);
(
data
->
stream
).
error
=
0
;
...
...
@@ -194,7 +199,7 @@ int fillMp3InputBuffer(mp3DecodeData * data, long offset) {
int
decodeNextFrameHeader
(
mp3DecodeData
*
data
)
{
if
((
data
->
stream
).
buffer
==
NULL
||
(
data
->
stream
).
error
==
MAD_ERROR_BUFLEN
)
{
if
(
fillMp3InputBuffer
(
data
,
/*data->currentOffset*/
-
1
)
<
0
)
{
if
(
fillMp3InputBuffer
(
data
)
<
0
)
{
return
DECODE_BREAK
;
}
}
...
...
@@ -234,7 +239,7 @@ int decodeNextFrameHeader(mp3DecodeData * data) {
int
decodeNextFrame
(
mp3DecodeData
*
data
)
{
if
((
data
->
stream
).
buffer
==
NULL
||
(
data
->
stream
).
error
==
MAD_ERROR_BUFLEN
)
{
if
(
fillMp3InputBuffer
(
data
,
/*data->currentOffset*/
-
1
)
<
0
)
{
if
(
fillMp3InputBuffer
(
data
)
<
0
)
{
return
DECODE_BREAK
;
}
}
...
...
@@ -504,7 +509,7 @@ int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc) {
i
++
;
}
if
(
i
<
data
->
highestFrame
)
{
if
(
fill
Mp3InputBuffer
(
data
,
if
(
seek
Mp3InputBuffer
(
data
,
data
->
frameOffset
[
i
])
==
0
)
{
clearOutputBuffer
(
cb
);
...
...
@@ -519,16 +524,20 @@ int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc) {
while
(
1
)
{
skip
=
0
;
while
((
ret
=
decodeNextFrameHeader
(
data
))
==
DECODE_CONT
);
while
((
ret
=
decodeNextFrameHeader
(
data
))
==
DECODE_CONT
&&
!
dc
->
seek
&&
!
dc
->
stop
);
if
(
ret
==
DECODE_SKIP
)
skip
=
1
;
else
if
(
ret
==
DECODE_BREAK
)
break
;
if
(
!
data
->
muteFrame
)
{
while
((
ret
=
decodeNextFrame
(
data
))
==
DECODE_CONT
);
while
((
ret
=
decodeNextFrame
(
data
))
==
DECODE_CONT
&&
!
dc
->
seek
&&
!
dc
->
stop
);
if
(
ret
==
DECODE_BREAK
)
break
;
}
if
(
!
skip
&&
ret
==
DECODE_OK
)
break
;
}
if
(
dc
->
stop
)
return
DECODE_BREAK
;
return
ret
;
}
...
...
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