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
547448ee
Commit
547448ee
authored
Oct 26, 2004
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lets try this soltuion to sending metadata, here we store metadata to send on the next shout_play
git-svn-id:
https://svn.musicpd.org/mpd/trunk@2346
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
91c76213
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
33 deletions
+51
-33
audioOutput_shout.c
src/audioOutput_shout.c
+51
-33
No files found.
src/audioOutput_shout.c
View file @
547448ee
...
...
@@ -64,6 +64,8 @@ typedef struct _ShoutData {
int
audioFormatConvert
;
int
opened
;
MpdTag
*
tag
;
}
ShoutData
;
static
ShoutData
*
newShoutData
()
{
...
...
@@ -73,12 +75,14 @@ static ShoutData * newShoutData() {
ret
->
convBuffer
=
NULL
;
ret
->
convBufferLen
=
0
;
ret
->
opened
=
0
;
ret
->
tag
=
NULL
;
return
ret
;
}
static
void
freeShoutData
(
ShoutData
*
sd
)
{
if
(
sd
->
shoutConn
)
shout_free
(
sd
->
shoutConn
);
if
(
sd
->
tag
)
freeMpdTag
(
sd
->
tag
);
free
(
sd
);
}
...
...
@@ -345,6 +349,45 @@ static void shout_convertAudioFormat(ShoutData * sd, char ** chunkArgPtr,
*
chunkArgPtr
=
sd
->
convBuffer
;
}
#define addTag(name, value) { \
if(value) vorbis_comment_add_tag(&(sd->vc), name, value); \
}
static
void
shout_sendMetadata
(
ShoutData
*
sd
)
{
ogg_int64_t
granulepos
=
sd
->
vd
.
granulepos
;
if
(
!
sd
->
opened
)
return
;
clearEncoder
(
sd
);
if
(
initEncoder
(
sd
)
<
0
)
return
;
sd
->
vd
.
granulepos
=
granulepos
;
if
(
sd
->
tag
)
{
addTag
(
"ARTIST"
,
sd
->
tag
->
artist
);
addTag
(
"ALBUM"
,
sd
->
tag
->
album
);
addTag
(
"TITLE"
,
sd
->
tag
->
title
);
}
vorbis_analysis_headerout
(
&
(
sd
->
vd
),
&
(
sd
->
vc
),
&
(
sd
->
header_main
),
&
(
sd
->
header_comments
),
&
(
sd
->
header_codebooks
));
ogg_stream_packetin
(
&
(
sd
->
os
),
&
(
sd
->
header_main
));
ogg_stream_packetin
(
&
(
sd
->
os
),
&
(
sd
->
header_comments
));
ogg_stream_packetin
(
&
(
sd
->
os
),
&
(
sd
->
header_codebooks
));
/*vorbis_commentheader_out(&(sd->vc), &(sd->header_comments));
ogg_stream_packetin(&(sd->os), &(sd->header_comments));*/
while
(
ogg_stream_flush
(
&
(
sd
->
os
),
&
(
sd
->
og
)))
{
if
(
write_page
(
sd
)
<
0
)
return
;
}
freeMpdTag
(
sd
->
tag
);
sd
->
tag
=
NULL
;
}
static
int
shout_play
(
AudioOutput
*
audioOutput
,
char
*
playChunk
,
int
size
)
{
int
i
,
j
;
ShoutData
*
sd
=
(
ShoutData
*
)
audioOutput
->
data
;
...
...
@@ -358,6 +401,8 @@ static int shout_play(AudioOutput * audioOutput, char * playChunk, int size) {
}
}
if
(
sd
->
tag
)
shout_sendMetadata
(
sd
);
if
(
sd
->
audioFormatConvert
)
{
shout_convertAudioFormat
(
sd
,
&
playChunk
,
&
size
);
}
...
...
@@ -395,42 +440,15 @@ static int shout_play(AudioOutput * audioOutput, char * playChunk, int size) {
return
0
;
}
#define addTag(name, value) { \
if(value) vorbis_comment_add_tag(&(sd->vc), name, value); \
}
static
void
shout_sendMetadata
(
AudioOutput
*
audioOutput
,
MpdTag
*
tag
)
{
static
void
shout_setTag
(
AudioOutput
*
audioOutput
,
MpdTag
*
tag
)
{
ShoutData
*
sd
=
(
ShoutData
*
)
audioOutput
->
data
;
ogg_int64_t
granulepos
=
sd
->
vd
.
granulepos
;
if
(
!
sd
->
opened
)
return
;
clearEncoder
(
sd
);
if
(
initEncoder
(
sd
)
<
0
)
return
;
sd
->
vd
.
granulepos
=
granulepos
;
if
(
tag
)
{
addTag
(
"ARTIST"
,
tag
->
artist
);
addTag
(
"ALBUM"
,
tag
->
album
);
addTag
(
"TITLE"
,
tag
->
title
);
if
(
sd
->
tag
)
freeMpdTag
(
sd
->
tag
);
sd
->
tag
=
NULL
;
}
vorbis_analysis_headerout
(
&
(
sd
->
vd
),
&
(
sd
->
vc
),
&
(
sd
->
header_main
),
&
(
sd
->
header_comments
),
&
(
sd
->
header_codebooks
));
ogg_stream_packetin
(
&
(
sd
->
os
),
&
(
sd
->
header_main
));
ogg_stream_packetin
(
&
(
sd
->
os
),
&
(
sd
->
header_comments
));
ogg_stream_packetin
(
&
(
sd
->
os
),
&
(
sd
->
header_codebooks
));
if
(
!
tag
)
return
;
/*vorbis_commentheader_out(&(sd->vc), &(sd->header_comments));
ogg_stream_packetin(&(sd->os), &(sd->header_comments));*/
while
(
ogg_stream_flush
(
&
(
sd
->
os
),
&
(
sd
->
og
)))
{
if
(
write_page
(
sd
)
<
0
)
return
;
}
sd
->
tag
=
mpdTagDup
(
tag
);
}
AudioOutputPlugin
shoutPlugin
=
...
...
@@ -441,7 +459,7 @@ AudioOutputPlugin shoutPlugin =
shout_openDevice
,
shout_play
,
shout_closeDevice
,
shout_se
ndMetadata
shout_se
tTag
};
#else
...
...
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