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
445d807b
Commit
445d807b
authored
Mar 21, 2004
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
streamline ls.c code
remove dontUpSampleSBR, not in faad2 rc3 git-svn-id:
https://svn.musicpd.org/mpd/trunk@330
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
6436b0ac
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
82 additions
and
159 deletions
+82
-159
ls.c
src/ls.c
+78
-158
ls.h
src/ls.h
+2
-0
mp4_decode.c
src/mp4_decode.c
+2
-1
No files found.
src/ls.c
View file @
445d807b
...
...
@@ -110,202 +110,98 @@ int lsPlaylists(FILE * fp, char * utf8path) {
return
0
;
}
int
isMusic
(
char
*
utf8file
,
time_t
*
mtime
)
{
int
ret
=
0
;
#ifdef HAVE_OGG
if
((
ret
=
isOgg
(
utf8file
,
mtime
)))
return
ret
;
#endif
#ifdef HAVE_FLAC
if
((
ret
=
isFlac
(
utf8file
,
mtime
)))
return
ret
;
#endif
#ifdef HAVE_MAD
if
((
ret
=
isMp3
(
utf8file
,
mtime
)))
return
ret
;
#endif
#ifdef HAVE_AUDIOFILE
if
((
ret
=
isWave
(
utf8file
,
mtime
)))
return
ret
;
#endif
#ifdef HAVE_FAAD
if
((
ret
=
isMp4
(
utf8file
,
mtime
)))
return
ret
;
#endif
return
ret
;
}
int
isPlaylist
(
char
*
utf8file
)
{
int
isFile
(
char
*
utf8file
,
time_t
*
mtime
)
{
struct
stat
st
;
char
*
file
=
utf8ToFsCharset
(
utf8file
);
char
*
actualFile
=
file
;
char
*
temp
=
NULL
;
if
(
actualFile
[
0
]
!=
'/'
)
actualFile
=
r
pp2ap
p
(
file
);
if
(
actualFile
[
0
]
!=
'/'
)
actualFile
=
r
mp2am
p
(
file
);
if
(
stat
(
actualFile
,
&
st
)
==
0
)
{
if
(
S_ISREG
(
st
.
st_mode
))
{
char
*
dup
;
char
*
cLast
;
char
*
cNext
;
int
ret
=
0
;
dup
=
strdup
(
file
);
cNext
=
cLast
=
strtok
(
dup
,
"."
);
while
((
cNext
=
strtok
(
NULL
,
"."
)))
cLast
=
cNext
;
if
(
cLast
&&
0
==
strcmp
(
cLast
,
PLAYLIST_FILE_SUFFIX
))
{
ret
=
1
;
}
free
(
dup
);
if
(
temp
)
free
(
temp
);
return
ret
;
if
(
mtime
)
*
mtime
=
st
.
st_mtime
;
return
1
;
}
else
return
0
;
}
if
(
temp
)
free
(
temp
);
return
0
;
}
int
isWave
(
char
*
utf8file
,
time_t
*
mtime
)
{
struct
stat
st
;
int
hasSuffix
(
char
*
utf8file
,
char
*
suffix
)
{
char
*
file
=
utf8ToFsCharset
(
utf8file
);
char
*
actualFile
=
file
;
char
*
dup
=
strdup
(
file
);;
char
*
cLast
;
char
*
cNext
=
cLast
=
strtok
(
dup
,
"."
);
int
ret
=
0
;
if
(
actualFile
[
0
]
!=
'/'
)
actualFile
=
rmp2amp
(
file
);
while
((
cNext
=
strtok
(
NULL
,
"."
)))
cLast
=
cNext
;
if
(
cLast
&&
0
==
strcasecmp
(
cLast
,
suffix
))
ret
=
1
;
free
(
dup
);
if
(
stat
(
actualFile
,
&
st
)
==
0
)
{
if
(
S_ISREG
(
st
.
st_mode
))
{
char
*
dup
;
char
*
cLast
;
char
*
cNext
;
int
ret
=
0
;
dup
=
strdup
(
file
);
cNext
=
cLast
=
strtok
(
dup
,
"."
);
while
((
cNext
=
strtok
(
NULL
,
"."
)))
cLast
=
cNext
;
if
(
cLast
&&
0
==
strcasecmp
(
cLast
,
"wav"
))
{
if
(
mtime
)
*
mtime
=
st
.
st_mtime
;
ret
=
1
;
}
free
(
dup
);
return
ret
;
}
else
return
0
;
}
return
ret
;
}
int
isPlaylist
(
char
*
utf8file
)
{
if
(
isFile
(
utf8file
,
NULL
))
{
return
hasSuffix
(
utf8file
,
PLAYLIST_FILE_SUFFIX
);
}
return
0
;
}
int
isFlac
(
char
*
utf8file
,
time_t
*
mtime
)
{
struct
stat
st
;
char
*
file
=
utf8ToFsCharset
(
utf8file
);
char
*
actualFile
=
file
;
int
hasWaveSuffix
(
char
*
utf8file
)
{
return
hasSuffix
(
utf8file
,
"wav"
);
}
if
(
actualFile
[
0
]
!=
'/'
)
actualFile
=
rmp2amp
(
file
);
int
isWave
(
char
*
utf8file
,
time_t
*
mtime
)
{
if
(
isFile
(
utf8file
,
mtime
))
return
hasWaveSuffix
(
utf8file
);
return
0
;
}
if
(
stat
(
actualFile
,
&
st
)
==
0
)
{
if
(
S_ISREG
(
st
.
st_mode
))
{
char
*
dup
;
char
*
cLast
;
char
*
cNext
;
int
ret
=
0
;
dup
=
strdup
(
file
);
cNext
=
cLast
=
strtok
(
dup
,
"."
);
while
((
cNext
=
strtok
(
NULL
,
"."
)))
cLast
=
cNext
;
if
(
cLast
&&
0
==
strcasecmp
(
cLast
,
"flac"
))
{
if
(
mtime
)
*
mtime
=
st
.
st_mtime
;
ret
=
1
;
}
free
(
dup
);
return
ret
;
}
else
return
0
;
}
int
hasFlacSuffix
(
char
*
utf8file
)
{
return
hasSuffix
(
utf8file
,
"flac"
);
}
int
isFlac
(
char
*
utf8file
,
time_t
*
mtime
)
{
if
(
isFile
(
utf8file
,
mtime
))
return
hasFlacSuffix
(
utf8file
);
return
0
;
}
int
hasOggSuffix
(
char
*
utf8file
)
{
return
hasSuffix
(
utf8file
,
"ogg"
);
}
int
isOgg
(
char
*
utf8file
,
time_t
*
mtime
)
{
struct
stat
st
;
char
*
file
=
utf8ToFsCharset
(
utf8file
)
;
char
*
actualFile
=
file
;
if
(
isFile
(
utf8file
,
mtime
))
return
hasOggSuffix
(
utf8file
);
return
0
;
}
if
(
actualFile
[
0
]
!=
'/'
)
actualFile
=
rmp2amp
(
file
);
int
hasAacSuffix
(
char
*
utf8file
)
{
return
hasSuffix
(
utf8file
,
"aac"
);
}
if
(
stat
(
actualFile
,
&
st
)
==
0
)
{
if
(
S_ISREG
(
st
.
st_mode
))
{
char
*
dup
;
char
*
cLast
;
char
*
cNext
;
int
ret
=
0
;
dup
=
strdup
(
file
);
cNext
=
cLast
=
strtok
(
dup
,
"."
);
while
((
cNext
=
strtok
(
NULL
,
"."
)))
cLast
=
cNext
;
if
(
cLast
&&
0
==
strcasecmp
(
cLast
,
"ogg"
))
{
if
(
mtime
)
*
mtime
=
st
.
st_mtime
;
ret
=
1
;
}
free
(
dup
);
return
ret
;
}
else
return
0
;
}
int
isAac
(
char
*
utf8file
,
time_t
*
mtime
)
{
if
(
isFile
(
utf8file
,
mtime
))
return
hasAacSuffix
(
utf8file
);
return
0
;
}
int
hasMp4Suffix
(
char
*
utf8file
)
{
if
(
hasSuffix
(
utf8file
,
"mp4"
))
return
1
;
if
(
hasSuffix
(
utf8file
,
"m4a"
))
return
1
;
return
0
;
}
int
isMp4
(
char
*
utf8file
,
time_t
*
mtime
)
{
struct
stat
st
;
char
*
file
=
utf8ToFsCharset
(
utf8file
);
char
*
actualFile
=
file
;
if
(
actualFile
[
0
]
!=
'/'
)
actualFile
=
rmp2amp
(
file
);
if
(
stat
(
actualFile
,
&
st
)
==
0
)
{
if
(
S_ISREG
(
st
.
st_mode
))
{
char
*
dup
;
char
*
cLast
;
char
*
cNext
;
int
ret
=
0
;
dup
=
strdup
(
file
);
cNext
=
cLast
=
strtok
(
dup
,
"."
);
while
((
cNext
=
strtok
(
NULL
,
"."
)))
cLast
=
cNext
;
if
(
cLast
&&
(
0
==
strcasecmp
(
cLast
,
"m4a"
)
||
0
==
strcasecmp
(
cLast
,
"mp4"
)))
{
if
(
mtime
)
*
mtime
=
st
.
st_mtime
;
ret
=
1
;
}
free
(
dup
);
return
ret
;
}
else
return
0
;
}
if
(
isFile
(
utf8file
,
mtime
))
return
hasMp4Suffix
(
utf8file
);
return
0
;
}
int
isMp3
(
char
*
utf8file
,
time_t
*
mtime
)
{
struct
stat
st
;
char
*
file
=
utf8ToFsCharset
(
utf8file
);
char
*
actualFile
=
file
;
if
(
actualFile
[
0
]
!=
'/'
)
actualFile
=
rmp2amp
(
file
);
if
(
stat
(
actualFile
,
&
st
)
==
0
)
{
if
(
S_ISREG
(
st
.
st_mode
))
{
char
*
dup
;
char
*
cLast
;
char
*
cNext
;
int
ret
=
0
;
dup
=
strdup
(
file
);
cNext
=
cLast
=
strtok
(
dup
,
"."
);
while
((
cNext
=
strtok
(
NULL
,
"."
)))
cLast
=
cNext
;
if
(
cLast
&&
0
==
strcasecmp
(
cLast
,
"mp3"
))
{
if
(
mtime
)
*
mtime
=
st
.
st_mtime
;
ret
=
1
;
}
free
(
dup
);
return
ret
;
}
else
return
0
;
}
int
hasMp3Suffix
(
char
*
utf8file
)
{
return
hasSuffix
(
utf8file
,
"mp3"
);
}
int
isMp3
(
char
*
utf8file
,
time_t
*
mtime
)
{
if
(
isFile
(
utf8file
,
mtime
))
return
hasMp3Suffix
(
utf8file
);
return
0
;
}
...
...
@@ -325,3 +221,27 @@ int isDir(char * utf8name, time_t * mtime) {
return
0
;
}
int
isMusic
(
char
*
utf8file
,
time_t
*
mtime
)
{
if
(
isFile
(
utf8file
,
mtime
))
{
#ifdef HAVE_OGG
if
(
hasOggSuffix
(
utf8file
))
return
1
;
#endif
#ifdef HAVE_FLAC
if
(
hasFlacSuffix
(
utf8file
))
return
1
;
#endif
#ifdef HAVE_MAD
if
(
hasMp3Suffix
(
utf8file
))
return
1
;
#endif
#ifdef HAVE_AUDIOFILE
if
(
hasWaveSuffix
(
utf8file
))
return
1
;
#endif
#ifdef HAVE_FAAD
if
(
hasMp4Suffix
(
utf8file
))
return
1
;
if
(
hasAacSuffix
(
utf8file
))
return
1
;
}
#endif
return
0
;
}
src/ls.h
View file @
445d807b
...
...
@@ -28,6 +28,8 @@ int lsPlaylists(FILE * fp, char * utf8path);
int
isMp3
(
char
*
utf8file
,
time_t
*
mtime
);
int
isAac
(
char
*
utf8file
,
time_t
*
mtime
);
int
isMp4
(
char
*
utf8file
,
time_t
*
mtime
);
int
isOgg
(
char
*
utf8file
,
time_t
*
mtime
);
...
...
src/mp4_decode.c
View file @
445d807b
...
...
@@ -133,7 +133,8 @@ int mp4_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
config
=
faacDecGetCurrentConfiguration
(
decoder
);
config
->
outputFormat
=
FAAD_FMT_16BIT
;
config
->
downMatrix
=
1
;
config
->
dontUpSampleImplicitSBR
=
1
;
/*comment this out, its not in faad2 2.0 rc2*/
/*config->dontUpSampleImplicitSBR = 0;*/
faacDecSetConfiguration
(
decoder
,
config
);
af
->
bits
=
16
;
...
...
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