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
e02659f6
Commit
e02659f6
authored
Feb 01, 2005
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
will compile if you manually add "HAVE_MUSEPACK" to config.h and -lmusepack to
MPD_LIBS in Makefile git-svn-id:
https://svn.musicpd.org/mpd/trunk@2919
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
9c218e48
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
102 additions
and
77 deletions
+102
-77
Makefile.am
src/Makefile.am
+1
-0
inputPlugin.c
src/inputPlugin.c
+2
-0
mpc_plugin.c
src/inputPlugins/mpc_plugin.c
+99
-77
No files found.
src/Makefile.am
View file @
e02659f6
...
@@ -13,6 +13,7 @@ mpd_inputPlugins = \
...
@@ -13,6 +13,7 @@ mpd_inputPlugins = \
inputPlugins/mod_plugin.c
\
inputPlugins/mod_plugin.c
\
inputPlugins/mp3_plugin.c
\
inputPlugins/mp3_plugin.c
\
inputPlugins/mp4_plugin.c
\
inputPlugins/mp4_plugin.c
\
inputPlugins/mpc_plugin.c
\
inputPlugins/ogg_plugin.c
inputPlugins/ogg_plugin.c
...
...
src/inputPlugin.c
View file @
e02659f6
...
@@ -113,6 +113,7 @@ extern InputPlugin oggPlugin;
...
@@ -113,6 +113,7 @@ extern InputPlugin oggPlugin;
extern
InputPlugin
flacPlugin
;
extern
InputPlugin
flacPlugin
;
extern
InputPlugin
audiofilePlugin
;
extern
InputPlugin
audiofilePlugin
;
extern
InputPlugin
mp4Plugin
;
extern
InputPlugin
mp4Plugin
;
extern
InputPlugin
mpcPlugin
;
extern
InputPlugin
aacPlugin
;
extern
InputPlugin
aacPlugin
;
extern
InputPlugin
modPlugin
;
extern
InputPlugin
modPlugin
;
...
@@ -125,6 +126,7 @@ void initInputPlugins() {
...
@@ -125,6 +126,7 @@ void initInputPlugins() {
loadInputPlugin
(
&
flacPlugin
);
loadInputPlugin
(
&
flacPlugin
);
loadInputPlugin
(
&
audiofilePlugin
);
loadInputPlugin
(
&
audiofilePlugin
);
loadInputPlugin
(
&
mp4Plugin
);
loadInputPlugin
(
&
mp4Plugin
);
loadInputPlugin
(
&
mpcPlugin
);
loadInputPlugin
(
&
modPlugin
);
loadInputPlugin
(
&
modPlugin
);
}
}
...
...
src/inputPlugins/mpc_plugin.c
View file @
e02659f6
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
#include "../inputPlugin.h"
#include "../inputPlugin.h"
#ifdef HAVE_M
PC
#ifdef HAVE_M
USEPACK
#include "../utils.h"
#include "../utils.h"
#include "../audio.h"
#include "../audio.h"
...
@@ -41,14 +41,14 @@ typedef struct _MpcCallbackData {
...
@@ -41,14 +41,14 @@ typedef struct _MpcCallbackData {
/* this is just for tag parsing for db import! */
/* this is just for tag parsing for db import! */
int
getMpcTotalTime
(
char
*
file
)
{
int
getMpcTotalTime
(
char
*
file
)
{
int
totalTime
=
0
int
totalTime
=
0
;
return
totalTime
;
return
totalTime
;
}
}
mpc_int32_t
mpc_read_cb
(
void
*
vdata
,
void
*
ptr
,
size
_t
size
)
{
mpc_int32_t
mpc_read_cb
(
void
*
vdata
,
void
*
ptr
,
mpc_int32
_t
size
)
{
mpc_int32_t
ret
=
0
;
mpc_int32_t
ret
=
0
;
OggCallbackData
*
data
=
(
Ogg
CallbackData
*
)
vdata
;
MpcCallbackData
*
data
=
(
Mpc
CallbackData
*
)
vdata
;
while
(
1
)
{
while
(
1
)
{
ret
=
readFromInputStream
(
data
->
inStream
,
ptr
,
size
,
1
);
ret
=
readFromInputStream
(
data
->
inStream
,
ptr
,
size
,
1
);
...
@@ -63,32 +63,59 @@ mpc_int32_t mpc_read_cb(void * vdata, void * ptr, size_t size) {
...
@@ -63,32 +63,59 @@ mpc_int32_t mpc_read_cb(void * vdata, void * ptr, size_t size) {
return
ret
;
return
ret
;
}
}
static
mpc_bool_t
ogg_seek_cb
(
void
*
vdata
,
ogg_int64
_t
offset
)
{
static
mpc_bool_t
mpc_seek_cb
(
void
*
vdata
,
mpc_int32
_t
offset
)
{
OggCallbackData
*
data
=
(
Ogg
CallbackData
*
)
vdata
;
MpcCallbackData
*
data
=
(
Mpc
CallbackData
*
)
vdata
;
return
data
->
inStream
->
seekable
?
return
!
seekInputStream
(
data
->
inStream
,
offset
,
SEEK_SET
);
!
seekInputStream
(
data
->
inStream
,
offset
,
SEEK_SET
)
:
false
;
}
}
mp
d
_int32_t
mpc_tell_cb
(
void
*
vdata
)
{
mp
c
_int32_t
mpc_tell_cb
(
void
*
vdata
)
{
OggCallbackData
*
data
=
(
Ogg
CallbackData
*
)
vdata
;
MpcCallbackData
*
data
=
(
Mpc
CallbackData
*
)
vdata
;
return
(
long
)(
data
->
inStream
->
offset
);
return
(
long
)(
data
->
inStream
->
offset
);
}
}
mpc_bool_t
mpc_canseek_cb
(
void
*
vdata
)
{
mpc_bool_t
mpc_canseek_cb
(
void
*
vdata
)
{
OggCallbackData
*
data
=
(
Ogg
CallbackData
*
)
vdata
;
MpcCallbackData
*
data
=
(
Mpc
CallbackData
*
)
vdata
;
return
data
->
inStream
->
seekable
;
return
data
->
inStream
->
seekable
;
}
}
mpc_int32_t
mpc_getsize_cb
(
void
*
vdata
)
{
mpc_int32_t
mpc_getsize_cb
(
void
*
vdata
)
{
OggCallbackData
*
data
=
(
Ogg
CallbackData
*
)
vdata
;
MpcCallbackData
*
data
=
(
Mpc
CallbackData
*
)
vdata
;
return
data
->
inStream
->
size
;
return
data
->
inStream
->
size
;
}
}
inline
mpd_sint16
convertSample
(
MPC_SAMPLE_FORMAT
sample
)
{
/* only doing 16-bit audio for now */
mpd_sint32
val
;
const
int
clip_min
=
-
1
<<
(
16
-
1
);
const
int
clip_max
=
(
1
<<
(
16
-
1
))
-
1
;
#ifdef MPC_FIXED_POINT
const
int
shift
=
16
-
MPC_FIXED_POINT_SCALE_SHIFT
;
if
(
ssample
>
0
)
{
sample
<<=
shift
;
}
else
if
(
shift
<
0
)
{
sample
>>=
-
shift
;
}
val
=
sample
;
#else
const
int
float_scale
=
1
<<
(
16
-
1
);
val
=
sample
*
float_scale
;
#endif
if
(
val
<
clip_min
)
val
=
clip_min
;
else
if
(
val
>
clip_max
)
val
=
clip_max
;
return
val
;
}
int
mpc_decode
(
OutputBuffer
*
cb
,
DecoderControl
*
dc
,
InputStream
*
inStream
)
int
mpc_decode
(
OutputBuffer
*
cb
,
DecoderControl
*
dc
,
InputStream
*
inStream
)
{
{
mpc_decoder
decoder
;
mpc_decoder
decoder
;
...
@@ -96,8 +123,8 @@ int mpc_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream)
...
@@ -96,8 +123,8 @@ int mpc_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream)
mpc_streaminfo
info
;
mpc_streaminfo
info
;
MpcCallbackData
data
;
MpcCallbackData
data
;
data
.
inStream
=
inStream
;
data
.
dc
=
dc
;
MPC_SAMPLE_FORMAT
sample_buffer
[
MPC_DECODER_BUFFER_LENGTH
]
;
int
eof
=
0
;
int
eof
=
0
;
long
ret
;
long
ret
;
...
@@ -105,7 +132,12 @@ int mpc_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream)
...
@@ -105,7 +132,12 @@ int mpc_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream)
char
chunk
[
MPC_CHUNK_SIZE
];
char
chunk
[
MPC_CHUNK_SIZE
];
int
chunkpos
=
0
;
int
chunkpos
=
0
;
long
bitRate
=
0
;
long
bitRate
=
0
;
char
**
comments
;
mpd_sint16
*
s16
=
(
mpd_sint16
*
)
chunk
;
unsigned
long
samplePos
=
0
;
mpc_uint32_t
vbrUpdateAcc
;
mpc_uint32_t
vbrUpdateBits
;
float
time
;
int
i
;
data
.
inStream
=
inStream
;
data
.
inStream
=
inStream
;
data
.
dc
=
dc
;
data
.
dc
=
dc
;
...
@@ -143,75 +175,72 @@ int mpc_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream)
...
@@ -143,75 +175,72 @@ int mpc_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream)
}
}
}
}
dc
->
totalTime
=
0
;
dc
->
totalTime
=
mpc_streaminfo_get_length
(
&
info
)
;
dc
->
audioFormat
.
bits
=
16
;
dc
->
audioFormat
.
bits
=
16
;
dc
->
audioFormat
.
sampleRate
=
info
.
sample_freq
;
while
(
!
eof
)
{
while
(
!
eof
)
{
if
(
dc
->
seek
)
{
if
(
dc
->
seek
)
{
if
(
0
==
ov_time_seek_page
(
&
vf
,
dc
->
seekWhere
))
{
samplePos
=
dc
->
seekWhere
*
dc
->
audioFormat
.
sampleRate
;
if
(
0
==
mpc_decoder_seek_sample
(
&
decoder
,
samplePos
))
{
clearOutputBuffer
(
cb
);
clearOutputBuffer
(
cb
);
chunkpos
=
0
;
chunkpos
=
0
;
}
}
else
dc
->
seekError
=
1
;
else
dc
->
seekError
=
1
;
dc
->
seek
=
0
;
dc
->
seek
=
0
;
}
}
ret
=
ov_read
(
&
vf
,
chunk
+
chunkpos
,
ret
=
mpc_decoder_decode
(
&
decoder
,
sample_buffer
,
OGG_CHUNK_SIZE
-
chunkpos
,
&
vbrUpdateAcc
,
&
vbrUpdateBits
);
OGG_DECODE_USE_BIGENDIAN
,
2
,
1
,
&
current_section
);
if
(
current_section
!=
prev_section
)
{
/*printf("new song!\n");*/
vorbis_info
*
vi
=
ov_info
(
&
vf
,
-
1
);
dc
->
audioFormat
.
channels
=
vi
->
channels
;
dc
->
audioFormat
.
sampleRate
=
vi
->
rate
;
if
(
dc
->
state
==
DECODE_STATE_START
)
{
getOutputAudioFormat
(
&
(
dc
->
audioFormat
),
&
(
cb
->
audioFormat
));
dc
->
state
=
DECODE_STATE_DECODE
;
}
comments
=
ov_comment
(
&
vf
,
-
1
)
->
user_comments
;
putOggCommentsIntoOutputBuffer
(
cb
,
inStream
->
metaName
,
comments
);
ogg_getReplayGainInfo
(
comments
,
&
replayGainInfo
);
}
prev_section
=
current_section
;
if
(
ret
<=
0
)
{
if
(
ret
<=
0
&&
ret
!=
OV_HOLE
)
{
eof
=
1
;
eof
=
1
;
break
;
break
;
}
}
if
(
ret
==
OV_HOLE
)
ret
=
0
;
chunkpos
+=
ret
;
samplePos
+=
ret
;
if
(
chunkpos
>=
OGG_CHUNK_SIZE
)
{
/* ret is in samples, and we have stereo */
if
((
test
=
ov_bitrate_instant
(
&
vf
))
>
0
)
{
ret
*=
2
;
bitRate
=
test
/
1000
;
}
for
(
i
=
0
;
i
<
ret
;
i
++
)
{
sendDataToOutputBuffer
(
cb
,
inStream
,
dc
,
/* 16 bit audio again */
*
s16
=
convertSample
(
sample_buffer
[
i
]);
chunkpos
+=
2
;
s16
++
;
if
(
chunkpos
>=
MPC_CHUNK_SIZE
)
{
time
=
((
float
)
samplePos
)
/
dc
->
audioFormat
.
sampleRate
;
bitRate
=
vbrUpdateBits
*
dc
->
audioFormat
.
sampleRate
/
(
MPC_CHUNK_SIZE
);
sendDataToOutputBuffer
(
cb
,
inStream
,
dc
,
inStream
->
seekable
,
inStream
->
seekable
,
chunk
,
chunkpos
,
chunk
,
chunkpos
,
ov_pcm_tell
(
&
vf
)
/
time
,
dc
->
audioFormat
.
sampleRate
,
bitRate
,
bitRate
,
replayGainInfo
);
NULL
);
chunkpos
=
0
;
chunkpos
=
0
;
if
(
dc
->
stop
)
break
;
s16
=
(
mpd_sint16
*
)
chunk
;
if
(
dc
->
stop
)
break
;
}
}
}
}
}
if
(
!
dc
->
stop
&&
chunkpos
>
0
)
{
if
(
!
dc
->
stop
&&
chunkpos
>
0
)
{
time
=
((
float
)
samplePos
)
/
dc
->
audioFormat
.
sampleRate
;
bitRate
=
vbrUpdateBits
*
dc
->
audioFormat
.
sampleRate
/
chunkpos
;
sendDataToOutputBuffer
(
cb
,
NULL
,
dc
,
inStream
->
seekable
,
sendDataToOutputBuffer
(
cb
,
NULL
,
dc
,
inStream
->
seekable
,
chunk
,
chunkpos
,
chunk
,
chunkpos
,
time
,
bitRate
,
NULL
);
ov_time_tell
(
&
vf
),
bitRate
,
replayGainInfo
);
}
}
if
(
replayGainInfo
)
freeReplayGainInfo
(
replayGainInfo
);
closeInputStream
(
inStream
);
ov_clear
(
&
vf
);
flushOutputBuffer
(
cb
);
flushOutputBuffer
(
cb
);
...
@@ -224,47 +253,40 @@ int mpc_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream)
...
@@ -224,47 +253,40 @@ int mpc_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream)
return
0
;
return
0
;
}
}
MpdTag
*
ogg
TagDup
(
char
*
file
)
{
MpdTag
*
mpc
TagDup
(
char
*
file
)
{
MpdTag
*
ret
=
NULL
;
MpdTag
*
ret
=
NULL
;
FILE
*
fp
;
FILE
*
fp
;
OggVorbis_File
vf
;
fp
=
fopen
(
file
,
"r"
);
fp
=
fopen
(
file
,
"r"
);
if
(
!
fp
)
return
NULL
;
if
(
!
fp
)
return
NULL
;
if
(
ov_open
(
fp
,
&
vf
,
NULL
,
0
)
<
0
)
{
fclose
(
fp
);
return
NULL
;
}
ret
=
oggCommentsParse
(
ov_comment
(
&
vf
,
-
1
)
->
user_comments
);
/* get tag info here */
if
(
!
ret
)
ret
=
newMpdTag
();
if
(
!
ret
)
ret
=
newMpdTag
();
ret
->
time
=
(
int
)(
ov_time_total
(
&
vf
,
-
1
)
+
0
.
5
);
ret
->
time
=
getMpcTotalTime
(
file
);
ov_clear
(
&
vf
);
return
ret
;
return
ret
;
}
}
char
*
oggSuffixes
[]
=
{
"ogg
"
,
NULL
};
char
*
mpcSuffixes
[]
=
{
"mpc
"
,
NULL
};
char
*
oggMimeTypes
[]
=
{
"application/ogg"
,
NULL
};
char
*
mpcMimeTypes
[]
=
{
NULL
};
InputPlugin
ogg
Plugin
=
InputPlugin
mpc
Plugin
=
{
{
"
ogg
"
,
"
mpc
"
,
NULL
,
NULL
,
NULL
,
NULL
,
ogg
_decode
,
mpc
_decode
,
NULL
,
NULL
,
ogg
TagDup
,
mpc
TagDup
,
INPUT_PLUGIN_STREAM_URL
|
INPUT_PLUGIN_STREAM_FILE
,
INPUT_PLUGIN_STREAM_URL
|
INPUT_PLUGIN_STREAM_FILE
,
ogg
Suffixes
,
mpc
Suffixes
,
ogg
MimeTypes
mpc
MimeTypes
};
};
#else
#else
InputPlugin
ogg
Plugin
=
InputPlugin
mpc
Plugin
=
{
{
NULL
,
NULL
,
NULL
,
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