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
746e7477
Commit
746e7477
authored
May 18, 2004
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
yes! rudimentary stream playing for mp3's!
be gentle git-svn-id:
https://svn.musicpd.org/mpd/trunk@1051
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
aed844a6
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
57 additions
and
36 deletions
+57
-36
audiofile_decode.c
src/audiofile_decode.c
+1
-2
flac_decode.c
src/flac_decode.c
+1
-2
ls.c
src/ls.c
+3
-4
mp3_decode.c
src/mp3_decode.c
+23
-12
mp4_decode.c
src/mp4_decode.c
+1
-2
ogg_decode.c
src/ogg_decode.c
+1
-2
outputBuffer.c
src/outputBuffer.c
+6
-0
outputBuffer.h
src/outputBuffer.h
+2
-0
player.c
src/player.c
+19
-12
No files found.
src/audiofile_decode.c
View file @
746e7477
...
...
@@ -98,8 +98,7 @@ int audiofile_decode(OutputBuffer * cb, DecoderControl * dc) {
while
(
!
eof
)
{
if
(
dc
->
seek
)
{
cb
->
end
=
cb
->
begin
;
cb
->
wrap
=
0
;
clearOutputBuffer
(
cb
);
current
=
dc
->
seekWhere
*
dc
->
audioFormat
.
sampleRate
;
afSeekFrame
(
af_fp
,
AF_DEFAULT_TRACK
,
current
);
...
...
src/flac_decode.c
View file @
746e7477
...
...
@@ -147,8 +147,7 @@ int flac_decode(OutputBuffer * cb, DecoderControl *dc) {
if
(
dc
->
seek
)
{
FLAC__uint64
sampleToSeek
=
dc
->
seekWhere
*
dc
->
audioFormat
.
sampleRate
+
0
.
5
;
cb
->
end
=
cb
->
begin
;
cb
->
wrap
=
0
;
clearOutputBuffer
(
cb
);
if
(
FLAC__seekable_stream_decoder_seek_absolute
(
flacDec
,
sampleToSeek
))
{
...
...
src/ls.c
View file @
746e7477
...
...
@@ -44,7 +44,6 @@ char * dupAndStripPlaylistSuffix(char * file) {
int
isRemoteUrl
(
char
*
url
)
{
char
*
prefixes
[]
=
{
"http://"
,
"ftp://"
,
NULL
};
...
...
@@ -53,12 +52,12 @@ int isRemoteUrl(char * url) {
while
(
*
urlPrefixes
)
{
if
(
strncmp
(
*
urlPrefixes
,
url
,
strlen
(
*
urlPrefixes
))
==
0
)
{
#ifdef HAVE_MAD
if
(
hasMp3Suffix
(
*
urlPrefixes
))
return
1
;
if
(
hasMp3Suffix
(
url
))
return
1
;
#endif
#ifdef HAVE_OGG
if
(
hasOggSuffix
(
*
urlPrefixes
))
return
1
;
return
0
;
if
(
hasOggSuffix
(
url
))
return
1
;
#endif
return
0
;
}
urlPrefixes
++
;
}
...
...
src/mp3_decode.c
View file @
746e7477
...
...
@@ -139,8 +139,8 @@ typedef struct _mp3DecodeData {
int
initMp3DecodeData
(
mp3DecodeData
*
data
,
char
*
file
)
{
int
ret
;
while
(((
ret
=
openInputStream
(
&
(
data
->
inStream
),
file
))
<
0
))
/*
&&
data->inStream.error==EINTR)
;*/
/*while(((*/
ret
=
openInputStream
(
&
(
data
->
inStream
),
file
)
/*)<0))
&&
data->inStream.error==EINTR)
*/
;
if
(
ret
<
0
)
return
-
1
;
data
->
outputPtr
=
data
->
outputBuffer
;
...
...
@@ -165,10 +165,13 @@ int initMp3DecodeData(mp3DecodeData * data, char * file) {
int
fillMp3InputBuffer
(
mp3DecodeData
*
data
,
long
offset
)
{
size_t
readSize
;
size_t
remaining
;
size_t
readed
;
unsigned
char
*
readStart
;
if
(
offset
>=
0
)
{
seekInputStream
(
&
(
data
->
inStream
),
offset
,
SEEK_SET
);
if
(
seekInputStream
(
&
(
data
->
inStream
),
offset
,
SEEK_SET
)
<
0
)
{
return
-
1
;
}
}
if
(
offset
==-
1
&&
(
data
->
stream
).
next_frame
!=
NULL
)
{
...
...
@@ -182,11 +185,15 @@ int fillMp3InputBuffer(mp3DecodeData * data, long offset) {
readStart
=
data
->
readBuffer
,
remaining
=
0
;
}
readSize
=
readFromInputStream
(
&
(
data
->
inStream
),
readStart
,
1
,
readSize
);
if
(
readSize
<=
0
)
return
-
1
;
mad_stream_buffer
(
&
data
->
stream
,
data
->
readBuffer
,
readSize
+
remaining
);
readed
=
0
;
while
(
readed
==
0
&&
!
inputStreamAtEOF
(
&
(
data
->
inStream
)))
{
readed
=
readFromInputStream
(
&
(
data
->
inStream
),
readStart
,
1
,
readSize
);
}
if
(
readed
<=
0
)
return
-
1
;
mad_stream_buffer
(
&
data
->
stream
,
data
->
readBuffer
,
readed
+
remaining
);
(
data
->
stream
).
error
=
0
;
return
0
;
...
...
@@ -441,6 +448,7 @@ int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc) {
if
(
data
->
muteFrame
)
{
if
(
!
dc
->
seek
)
data
->
muteFrame
=
0
;
else
if
(
dc
->
seekWhere
<=
data
->
elapsedTime
)
{
clearOutputBuffer
(
cb
);
data
->
muteFrame
=
0
;
dc
->
seek
=
0
;
}
...
...
@@ -485,8 +493,6 @@ int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc) {
if
(
dc
->
seek
)
{
long
i
=
0
;
cb
->
wrap
=
0
;
cb
->
end
=
cb
->
begin
;
data
->
muteFrame
=
1
;
while
(
i
<
data
->
highestFrame
&&
dc
->
seekWhere
>
((
float
)
mad_timer_count
(
data
->
times
[
i
],
...
...
@@ -495,9 +501,14 @@ int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc) {
i
++
;
}
if
(
i
<
data
->
highestFrame
)
{
data
->
currentFrame
=
i
;
fillMp3InputBuffer
(
data
,
data
->
frameOffset
[
i
]);
data
->
muteFrame
=
0
;
if
(
fillMp3InputBuffer
(
data
,
data
->
frameOffset
[
i
])
==
0
)
{
clearOutputBuffer
(
cb
);
data
->
currentFrame
=
i
;
data
->
muteFrame
=
0
;
}
else
dc
->
seekError
=
1
;
dc
->
seek
=
0
;
}
}
...
...
src/mp4_decode.c
View file @
746e7477
...
...
@@ -220,8 +220,7 @@ int mp4_decode(OutputBuffer * cb, DecoderControl * dc) {
if
(
dc
->
seek
&&
seekPositionFound
)
{
seekPositionFound
=
0
;
chunkLen
=
0
;
cb
->
end
=
cb
->
begin
;
cb
->
wrap
=
0
;
clearOutputBuffer
(
cb
);
dc
->
seek
=
0
;
}
...
...
src/ogg_decode.c
View file @
746e7477
...
...
@@ -191,8 +191,7 @@ int ogg_decode(OutputBuffer * cb, DecoderControl * dc)
while
(
!
eof
)
{
if
(
dc
->
seek
)
{
cb
->
end
=
cb
->
begin
;
cb
->
wrap
=
0
;
clearOutputBuffer
(
cb
);
chunkpos
=
0
;
ov_time_seek_page
(
&
vf
,
dc
->
seekWhere
);
dc
->
seek
=
0
;
...
...
src/outputBuffer.c
View file @
746e7477
...
...
@@ -26,6 +26,12 @@
static
mpd_sint16
currentChunk
=
-
1
;
void
clearOutputBuffer
(
OutputBuffer
*
cb
)
{
currentChunk
=
-
1
;
cb
->
end
=
cb
->
begin
;
cb
->
wrap
=
0
;
}
void
flushOutputBuffer
(
OutputBuffer
*
cb
)
{
if
(
currentChunk
==
cb
->
end
)
{
cb
->
end
++
;
...
...
src/outputBuffer.h
View file @
746e7477
...
...
@@ -38,6 +38,8 @@ typedef struct _OutputBuffer {
AudioFormat
audioFormat
;
}
OutputBuffer
;
void
clearOutputBuffer
(
OutputBuffer
*
cb
);
void
flushOutputBuffer
(
OutputBuffer
*
cb
);
int
sendDataToOutputBuffer
(
OutputBuffer
*
cb
,
DecoderControl
*
dc
,
...
...
src/player.c
View file @
746e7477
...
...
@@ -161,22 +161,22 @@ int playerInit() {
}
int
playerGetDecodeType
(
char
*
utf8file
)
{
if
(
!
is
File
(
utf8file
,
NULL
))
;
if
(
!
is
RemoteUrl
(
utf8file
)
&&
!
isFile
(
utf8file
,
NULL
))
return
-
1
;
#ifdef HAVE_MAD
else
if
(
hasMp3Suffix
(
utf8file
))
return
DECODE_TYPE_MP3
;
if
(
hasMp3Suffix
(
utf8file
))
return
DECODE_TYPE_MP3
;
#endif
#ifdef HAVE_OGG
else
if
(
hasOggSuffix
(
utf8file
))
return
DECODE_TYPE_OGG
;
if
(
hasOggSuffix
(
utf8file
))
return
DECODE_TYPE_OGG
;
#endif
#ifdef HAVE_FLAC
else
if
(
hasFlacSuffix
(
utf8file
))
return
DECODE_TYPE_FLAC
;
if
(
hasFlacSuffix
(
utf8file
))
return
DECODE_TYPE_FLAC
;
#endif
#ifdef HAVE_AUDIOFILE
else
if
(
hasWaveSuffix
(
utf8file
))
return
DECODE_TYPE_AUDIOFILE
;
if
(
hasWaveSuffix
(
utf8file
))
return
DECODE_TYPE_AUDIOFILE
;
#endif
#ifdef HAVE_FAAD
else
if
(
hasAacSuffix
(
utf8file
))
return
DECODE_TYPE_AAC
;
else
if
(
hasMp4Suffix
(
utf8file
))
return
DECODE_TYPE_MP4
;
if
(
hasAacSuffix
(
utf8file
))
return
DECODE_TYPE_AAC
;
if
(
hasMp4Suffix
(
utf8file
))
return
DECODE_TYPE_MP4
;
#endif
return
-
1
;
}
...
...
@@ -189,7 +189,7 @@ int playerPlay(FILE * fp, char * utf8file) {
if
(
playerStop
(
fp
)
<
0
)
return
-
1
;
{
/*
{
struct stat st;
if(stat(rmp2amp(utf8ToFsCharset(utf8file)),&st)<0) {
strncpy(pc->erroredFile,pc->file,MAXPATHLEN);
...
...
@@ -197,7 +197,7 @@ int playerPlay(FILE * fp, char * utf8file) {
pc->error = PLAYER_ERROR_FILENOTFOUND;
return 0;
}
}
}
*/
decodeType
=
playerGetDecodeType
(
utf8file
);
if
(
decodeType
<
0
)
{
...
...
@@ -208,7 +208,10 @@ int playerPlay(FILE * fp, char * utf8file) {
}
pc
->
decodeType
=
decodeType
;
strncpy
(
pc
->
file
,
rmp2amp
(
utf8ToFsCharset
(
utf8file
)),
MAXPATHLEN
);
if
(
isRemoteUrl
(
utf8file
))
{
strncpy
(
pc
->
file
,
utf8file
,
MAXPATHLEN
);
}
else
strncpy
(
pc
->
file
,
rmp2amp
(
utf8ToFsCharset
(
utf8file
)),
MAXPATHLEN
);
pc
->
file
[
MAXPATHLEN
]
=
'\0'
;
pc
->
play
=
1
;
...
...
@@ -353,7 +356,10 @@ int queueSong(char * utf8file) {
int
decodeType
;
if
(
pc
->
queueState
==
PLAYER_QUEUE_BLANK
)
{
strncpy
(
pc
->
file
,
rmp2amp
(
utf8ToFsCharset
(
utf8file
)),
MAXPATHLEN
);
if
(
isRemoteUrl
(
utf8file
))
{
strncpy
(
pc
->
file
,
utf8file
,
MAXPATHLEN
);
}
else
strncpy
(
pc
->
file
,
rmp2amp
(
utf8ToFsCharset
(
utf8file
)),
MAXPATHLEN
);
pc
->
file
[
MAXPATHLEN
]
=
'\0'
;
decodeType
=
playerGetDecodeType
(
utf8file
);
...
...
@@ -410,7 +416,8 @@ int playerSeek(FILE * fp, char * utf8file, float time) {
return
-
1
;
}
file
=
rmp2amp
(
utf8ToFsCharset
(
utf8file
));
if
(
isRemoteUrl
(
utf8file
))
file
=
utf8file
;
else
file
=
rmp2amp
(
utf8ToFsCharset
(
utf8file
));
if
(
strcmp
(
pc
->
file
,
file
)
!=
0
)
{
decodeType
=
playerGetDecodeType
(
utf8file
);
if
(
decodeType
<
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