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
48a58073
Commit
48a58073
authored
May 18, 2004
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add new inputStream stuff, hopefully something major isn't foobar'd
git-svn-id:
https://svn.musicpd.org/mpd/trunk@1049
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
ee79a3a8
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
41 additions
and
54 deletions
+41
-54
Makefile.am
src/Makefile.am
+2
-2
aac_decode.c
src/aac_decode.c
+2
-2
flac_decode.c
src/flac_decode.c
+1
-1
inputStream.c
src/inputStream.c
+12
-38
inputStream.h
src/inputStream.h
+19
-5
mp3_decode.c
src/mp3_decode.c
+2
-2
mp4_decode.c
src/mp4_decode.c
+1
-1
ogg_decode.c
src/ogg_decode.c
+1
-1
tag.c
src/tag.c
+1
-2
No files found.
src/Makefile.am
View file @
48a58073
...
...
@@ -6,14 +6,14 @@ mpd_headers = buffer2array.h interface.h command.h playlist.h ls.h \
audio.h playerData.h stats.h myfprintf.h sig_handlers.h decode.h log.h
\
audiofile_decode.h charConv.h permission.h mpd_types.h pcm_utils.h
\
mp4_decode.h aac_decode.h signal_check.h utf8.h inputStream.h
\
outputBuffer.h replayGain.h
outputBuffer.h replayGain.h
inputStream_file.h inputStream_http.h
mpd_SOURCES
=
main.c buffer2array.c interface.c command.c playlist.c ls.c
\
song.c list.c directory.c tables.c utils.c path.c mp3_decode.c
\
tag.c player.c listen.c conf.c ogg_decode.c volume.c flac_decode.c
\
audio.c playerData.c stats.c myfprintf.c sig_handlers.c decode.c log.c
\
audiofile_decode.c charConv.c permission.c pcm_utils.c mp4_decode.c
\
aac_decode.c signal_check.c utf8.c inputStream.c outputBuffer.c
\
replayGain.c
$(mpd_headers)
replayGain.c
inputStream_file.c inputStream_http.c
$(mpd_headers)
mpd_CFLAGS
=
$(MPD_CFLAGS)
mpd_LDADD
=
$(MPD_LIBS)
$(ID3_LIB)
$(MAD_LIB)
$(MP4FF_LIB)
...
...
src/aac_decode.c
View file @
48a58073
...
...
@@ -212,7 +212,7 @@ float getAacFloatTotalTime(char * file) {
InputStream
inStream
;
size_t
bread
;
if
(
openInputStream
FromFile
(
&
inStream
,
file
)
<
0
)
return
-
1
;
if
(
openInputStream
(
&
inStream
,
file
)
<
0
)
return
-
1
;
initAacBuffer
(
&
inStream
,
&
b
,
&
length
,
&
fileread
,
&
tagsize
);
...
...
@@ -274,7 +274,7 @@ int aac_decode(OutputBuffer * cb, DecoderControl * dc) {
if
((
totalTime
=
getAacFloatTotalTime
(
dc
->
file
))
<
0
)
return
-
1
;
if
(
openInputStream
FromFile
(
&
inStream
,
dc
->
file
)
<
0
)
return
-
1
;
if
(
openInputStream
(
&
inStream
,
dc
->
file
)
<
0
)
return
-
1
;
initAacBuffer
(
&
inStream
,
&
b
,
NULL
,
NULL
,
NULL
);
...
...
src/flac_decode.c
View file @
48a58073
...
...
@@ -81,7 +81,7 @@ int flac_decode(OutputBuffer * cb, DecoderControl *dc) {
data
.
dc
=
dc
;
data
.
replayGainScale
=
1
.
0
;
if
(
openInputStream
FromFile
(
&
(
data
.
inStream
),
dc
->
file
)
<
0
)
{
if
(
openInputStream
(
&
(
data
.
inStream
),
dc
->
file
)
<
0
)
{
ERROR
(
"unable to open flac: %s
\n
"
,
dc
->
file
);
return
-
1
;
}
...
...
src/inputStream.c
View file @
48a58073
...
...
@@ -18,61 +18,35 @@
#include "inputStream.h"
#include "inputStream_file.h"
#include "inputStream_http.h"
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
int
openInputStreamFromFile
(
InputStream
*
inStream
,
char
*
filename
)
{
inStream
->
fp
=
fopen
(
filename
,
"r"
);
if
(
!
inStream
->
fp
)
{
inStream
->
error
=
errno
;
return
-
1
;
}
inStream
->
offset
=
0
;
int
openInputStream
(
InputStream
*
inStream
,
char
*
url
)
{
if
(
inputStream_fileOpen
(
inStream
,
url
)
==
0
)
return
0
;
if
(
inputStream_httpOpen
(
inStream
,
url
)
==
0
)
return
0
;
fseek
(
inStream
->
fp
,
0
,
SEEK_END
);
inStream
->
size
=
ftell
(
inStream
->
fp
);
fseek
(
inStream
->
fp
,
0
,
SEEK_SET
);
return
0
;
return
-
1
;
}
int
seekInputStream
(
InputStream
*
inStream
,
long
offset
,
int
whence
)
{
if
(
fseek
(
inStream
->
fp
,
offset
,
whence
)
==
0
)
{
inStream
->
offset
=
ftell
(
inStream
->
fp
);
}
else
{
inStream
->
error
=
errno
;
return
-
1
;
}
return
0
;
return
inStream
->
seekFunc
(
inStream
,
offset
,
whence
);
}
size_t
readFromInputStream
(
InputStream
*
inStream
,
void
*
ptr
,
size_t
size
,
size_t
nmemb
)
{
size_t
readSize
;
readSize
=
fread
(
ptr
,
size
,
nmemb
,
inStream
->
fp
);
if
(
readSize
>
0
)
inStream
->
offset
+=
readSize
;
return
readSize
;
return
inStream
->
readFunc
(
inStream
,
ptr
,
size
,
nmemb
);
}
int
closeInputStream
(
InputStream
*
inStream
)
{
if
(
fclose
(
inStream
->
fp
)
<
0
)
{
inStream
->
error
=
errno
;
}
else
return
-
1
;
return
0
;
return
inStream
->
closeFunc
(
inStream
);
}
int
inputStreamAtEOF
(
InputStream
*
inStream
)
{
return
feof
(
inStream
->
fp
);
return
inStream
->
atEOFFunc
(
inStream
);
}
/* vim:set shiftwidth=
4
tabstop=8 expandtab: */
/* vim:set shiftwidth=
8
tabstop=8 expandtab: */
src/inputStream.h
View file @
48a58073
...
...
@@ -19,19 +19,33 @@
#ifndef INPUT_STREAM_H
#define INPUT_STREAM_H
#include <stdio.h>
#include <stdlib.h>
typedef
struct
_InputStream
{
FILE
*
fp
;
typedef
struct
_InputStream
InputStream
;
typedef
int
(
*
InputStreamSeekFunc
)
(
InputStream
*
inStream
,
long
offset
,
int
whence
);
typedef
size_t
(
*
InputStreamReadFunc
)
(
InputStream
*
inStream
,
void
*
ptr
,
size_t
size
,
size_t
nmemb
);
typedef
int
(
*
InputStreamCloseFunc
)
(
InputStream
*
inStream
);
typedef
int
(
*
InputStreamAtEOFFunc
)
(
InputStream
*
inStream
);
struct
_InputStream
{
int
error
;
long
offset
;
size_t
size
;
}
InputStream
;
/* don't touc this stuff */
InputStreamSeekFunc
seekFunc
;
InputStreamReadFunc
readFunc
;
InputStreamCloseFunc
closeFunc
;
InputStreamAtEOFFunc
atEOFFunc
;
void
*
data
;
};
/* if an error occurs for these 3 functions, then -1 is returned and errno
for the input stream is set */
int
openInputStream
FromFile
(
InputStream
*
inStream
,
char
*
filename
);
int
openInputStream
(
InputStream
*
inStream
,
char
*
url
);
int
seekInputStream
(
InputStream
*
inStream
,
long
offset
,
int
whence
);
int
closeInputStream
(
InputStream
*
inStream
);
int
inputStreamAtEOF
(
InputStream
*
inStream
);
...
...
src/mp3_decode.c
View file @
48a58073
...
...
@@ -139,8 +139,8 @@ typedef struct _mp3DecodeData {
int
initMp3DecodeData
(
mp3DecodeData
*
data
,
char
*
file
)
{
int
ret
;
while
(((
ret
=
openInputStream
FromFile
(
&
(
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
;
...
...
src/mp4_decode.c
View file @
48a58073
...
...
@@ -113,7 +113,7 @@ int mp4_decode(OutputBuffer * cb, DecoderControl * dc) {
mpd_uint16
bitRate
=
0
;
InputStream
inStream
;
if
(
openInputStream
FromFile
(
&
inStream
,
dc
->
file
)
<
0
)
{
if
(
openInputStream
(
&
inStream
,
dc
->
file
)
<
0
)
{
ERROR
(
"failed to open %s
\n
"
,
dc
->
file
);
return
-
1
;
}
...
...
src/ogg_decode.c
View file @
48a58073
...
...
@@ -154,7 +154,7 @@ int ogg_decode(OutputBuffer * cb, DecoderControl * dc)
callbacks
.
close_func
=
ogg_close_cb
;
callbacks
.
tell_func
=
ogg_tell_cb
;
if
(
openInputStream
FromFile
(
&
inStream
,
dc
->
file
)
<
0
)
{
if
(
openInputStream
(
&
inStream
,
dc
->
file
)
<
0
)
{
ERROR
(
"failed to open ogg
\n
"
);
return
-
1
;
}
...
...
src/tag.c
View file @
48a58073
...
...
@@ -219,8 +219,7 @@ MpdTag * mp4DataDup(char * utf8file, int * mp4MetadataFound) {
*
mp4MetadataFound
=
0
;
if
(
openInputStreamFromFile
(
&
inStream
,
rmp2amp
(
utf8ToFsCharset
(
utf8file
)))
<
0
)
if
(
openInputStream
(
&
inStream
,
rmp2amp
(
utf8ToFsCharset
(
utf8file
)))
<
0
)
{
return
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