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
fe0b751c
Commit
fe0b751c
authored
Jun 01, 2004
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ogg voribs comment parsing on the fly in the decoder
git-svn-id:
https://svn.musicpd.org/mpd/trunk@1279
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
187eba57
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
111 additions
and
35 deletions
+111
-35
decode.c
src/decode.c
+32
-1
decode.h
src/decode.h
+5
-0
ogg_plugin.c
src/inputPlugins/ogg_plugin.c
+60
-34
player.c
src/player.c
+8
-0
player.h
src/player.h
+2
-0
playerData.c
src/playerData.c
+4
-0
No files found.
src/decode.c
View file @
fe0b751c
...
...
@@ -118,6 +118,8 @@ int calculateCrossFadeChunks(PlayerControl * pc, AudioFormat * af) {
DECODE_METADATA_LENGTH); \
pc->metadata[DECODE_METADATA_LENGTH-1] = '\0'; \
pc->title = dc->title; \
pc->artist = dc->artist; \
pc->album = dc->album; \
} \
pc->metadataState = PLAYER_METADATA_STATE_READ; \
pc->totalTime = dc->totalTime; \
...
...
@@ -265,6 +267,8 @@ void decodeStart(PlayerControl * pc, OutputBuffer * cb, DecoderControl * dc) {
dc
->
metadataSet
=
0
;
memset
(
dc
->
metadata
,
0
,
DECODE_METADATA_LENGTH
);
dc
->
title
=
-
1
;
dc
->
album
=
-
1
;
dc
->
artist
=
-
1
;
strncpy
(
dc
->
utf8url
,
pc
->
utf8url
,
MAXPATHLEN
);
dc
->
utf8url
[
MAXPATHLEN
]
=
'\0'
;
...
...
@@ -595,4 +599,31 @@ void decode() {
decodeParent
(
pc
,
dc
,
cb
);
}
/* vim:set shiftwidth=8 tabstop=8 expandtab: */
/* this is stuff for inputPlugins to use! */
#define copyStringToMetadata(string, element) { \
if(string && (slen = strlen(string)) && \
pos < DECODE_METADATA_LENGTH-1) \
{ \
strncpy(dc->metadata+pos, string, \
DECODE_METADATA_LENGTH-1-pos); \
element = pos; \
pos += slen; \
} \
}
void
copyMpdTagToDecoderControlMetadata
(
DecoderControl
*
dc
,
MpdTag
*
tag
)
{
int
pos
=
0
;
int
slen
;
if
(
dc
->
metadataSet
)
return
;
if
(
!
tag
)
return
;
memset
(
dc
->
metadata
,
0
,
DECODE_METADATA_LENGTH
);
copyStringToMetadata
(
tag
->
title
,
dc
->
title
);
copyStringToMetadata
(
tag
->
artist
,
dc
->
artist
);
copyStringToMetadata
(
tag
->
album
,
dc
->
album
);
dc
->
metadataSet
=
1
;
}
src/decode.h
View file @
fe0b751c
...
...
@@ -20,6 +20,7 @@
#define DECODE_H
#include "../config.h"
#include "tag.h"
#include "mpd_types.h"
#include "audio.h"
...
...
@@ -63,11 +64,15 @@ typedef struct _DecoderControl {
volatile
mpd_sint8
metadataSet
;
char
metadata
[
DECODE_METADATA_LENGTH
];
volatile
mpd_sint16
title
;
volatile
mpd_sint16
artist
;
volatile
mpd_sint16
album
;
}
DecoderControl
;
void
decodeSigHandler
(
int
sig
);
void
decode
();
void
copyMpdTagToDecoderControlMetadata
(
DecoderControl
*
dc
,
MpdTag
*
tag
);
#endif
/* vim:set shiftwidth=4 tabstop=8 expandtab: */
src/inputPlugins/ogg_plugin.c
View file @
fe0b751c
...
...
@@ -165,6 +165,61 @@ float ogg_getReplayGainScale(char ** comments) {
return
1
.
0
;
}
MpdTag
*
oggCommentsParse
(
char
**
comments
)
{
MpdTag
*
ret
=
NULL
;
char
*
temp
;
while
(
*
comments
)
{
if
((
temp
=
ogg_parseComment
(
*
comments
,
"artist"
)))
{
if
(
!
ret
)
ret
=
newMpdTag
();
if
(
!
ret
->
artist
)
{
ret
->
artist
=
strdup
(
temp
);
stripReturnChar
(
ret
->
artist
);
}
}
else
if
((
temp
=
ogg_parseComment
(
*
comments
,
"title"
)))
{
if
(
!
ret
)
ret
=
newMpdTag
();
if
(
!
ret
->
title
)
{
ret
->
title
=
strdup
(
temp
);
stripReturnChar
(
ret
->
title
);
}
}
else
if
((
temp
=
ogg_parseComment
(
*
comments
,
"album"
)))
{
if
(
!
ret
)
ret
=
newMpdTag
();
if
(
!
ret
->
album
)
{
ret
->
album
=
strdup
(
temp
);
stripReturnChar
(
ret
->
album
);
}
}
else
if
((
temp
=
ogg_parseComment
(
*
comments
,
"tracknumber"
)))
{
if
(
!
ret
)
ret
=
newMpdTag
();
if
(
!
ret
->
track
)
{
ret
->
track
=
strdup
(
temp
);
stripReturnChar
(
ret
->
track
);
}
}
comments
++
;
}
return
ret
;
}
void
putOggCommentsIntoDecoderControlMetadata
(
DecoderControl
*
dc
,
char
**
comments
)
{
MpdTag
*
tag
;
if
(
dc
->
metadataSet
)
return
;
tag
=
oggCommentsParse
(
comments
);
if
(
!
tag
)
return
;
copyMpdTagToDecoderControlMetadata
(
dc
,
tag
);
freeMpdTag
(
tag
);
}
int
ogg_decode
(
OutputBuffer
*
cb
,
DecoderControl
*
dc
,
InputStream
*
inStream
)
{
OggVorbis_File
vf
;
...
...
@@ -215,6 +270,8 @@ int ogg_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream)
comments
=
ov_comment
(
&
vf
,
-
1
)
->
user_comments
;
putOggCommentsIntoDecoderControlMetadata
(
dc
,
comments
);
dc
->
state
=
DECODE_STATE_DECODE
;
replayGainScale
=
ogg_getReplayGainScale
(
comments
);
...
...
@@ -281,8 +338,6 @@ MpdTag * oggTagDup(char * file) {
MpdTag
*
ret
=
NULL
;
FILE
*
fp
;
OggVorbis_File
vf
;
char
**
comments
;
char
*
temp
;
fp
=
fopen
(
file
,
"r"
);
if
(
!
fp
)
return
NULL
;
...
...
@@ -291,39 +346,10 @@ MpdTag * oggTagDup(char * file) {
return
NULL
;
}
ret
=
newMpdTag
();
ret
->
time
=
(
int
)(
ov_time_total
(
&
vf
,
-
1
)
+
0
.
5
);
comments
=
ov_comment
(
&
vf
,
-
1
)
->
user_comments
;
while
(
*
comments
)
{
if
((
temp
=
ogg_parseComment
(
*
comments
,
"artist"
)))
{
if
(
!
ret
->
artist
)
{
ret
->
artist
=
strdup
(
temp
);
stripReturnChar
(
ret
->
artist
);
}
}
else
if
((
temp
=
ogg_parseComment
(
*
comments
,
"title"
)))
{
if
(
!
ret
->
title
)
{
ret
->
title
=
strdup
(
temp
);
stripReturnChar
(
ret
->
title
);
}
}
else
if
((
temp
=
ogg_parseComment
(
*
comments
,
"album"
)))
{
if
(
!
ret
->
album
)
{
ret
->
album
=
strdup
(
temp
);
stripReturnChar
(
ret
->
album
);
}
}
else
if
((
temp
=
ogg_parseComment
(
*
comments
,
"tracknumber"
)))
{
if
(
!
ret
->
track
)
{
ret
->
track
=
strdup
(
temp
);
stripReturnChar
(
ret
->
track
);
}
}
ret
=
oggCommentsParse
(
ov_comment
(
&
vf
,
-
1
)
->
user_comments
);
comments
++
;
}
if
(
!
ret
)
ret
=
newMpdTag
()
;
ret
->
time
=
(
int
)(
ov_time_total
(
&
vf
,
-
1
)
+
0
.
5
);
ov_clear
(
&
vf
);
...
...
src/player.c
View file @
fe0b751c
...
...
@@ -56,6 +56,8 @@ static void resetPlayerMetadata() {
if
(
pc
->
metadataState
==
PLAYER_METADATA_STATE_READ
)
{
pc
->
metadataState
=
PLAYER_METADATA_STATE_WRITE
;
pc
->
title
=
-
1
;
pc
->
artist
=
-
1
;
pc
->
album
=
-
1
;
}
}
...
...
@@ -489,6 +491,12 @@ Song * playerCurrentDecodeSong() {
if
(
pc
->
title
>=
0
)
{
song
->
tag
->
title
=
strdup
(
pc
->
title
+
pc
->
metadata
);
}
if
(
pc
->
artist
>=
0
)
{
song
->
tag
->
artist
=
strdup
(
pc
->
artist
+
pc
->
metadata
);
}
if
(
pc
->
album
>=
0
)
{
song
->
tag
->
album
=
strdup
(
pc
->
album
+
pc
->
metadata
);
}
validateUtf8Tag
(
song
->
tag
);
resetPlayerMetadata
();
return
song
;
...
...
src/player.h
View file @
fe0b751c
...
...
@@ -87,6 +87,8 @@ typedef struct _PlayerControl {
volatile
mpd_sint8
metadataState
;
char
metadata
[
DECODE_METADATA_LENGTH
];
volatile
mpd_sint16
title
;
volatile
mpd_sint16
artist
;
volatile
mpd_sint16
album
;
}
PlayerControl
;
void
clearPlayerPid
();
...
...
src/playerData.c
View file @
fe0b751c
...
...
@@ -118,6 +118,8 @@ void initPlayerData() {
playerData_pd
->
playerControl
.
totalPlayTime
=
0
;
playerData_pd
->
playerControl
.
decode_pid
=
0
;
playerData_pd
->
playerControl
.
title
=
-
1
;
playerData_pd
->
playerControl
.
artist
=
-
1
;
playerData_pd
->
playerControl
.
album
=
-
1
;
playerData_pd
->
playerControl
.
metadataState
=
PLAYER_METADATA_STATE_WRITE
;
...
...
@@ -130,6 +132,8 @@ void initPlayerData() {
memset
(
playerData_pd
->
decoderControl
.
metadata
,
0
,
DECODE_METADATA_LENGTH
);
playerData_pd
->
decoderControl
.
title
=
-
1
;
playerData_pd
->
decoderControl
.
artist
=
-
1
;
playerData_pd
->
decoderControl
.
album
=
-
1
;
playerData_pd
->
decoderControl
.
metadataSet
=
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