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
817a68b2
Commit
817a68b2
authored
Aug 26, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added decoder_get_command()
Another big patch which hides internal mpd APIs from decoder plugins: decoder plugins regularly poll dc->command; expose it with a decoder_api.h function.
parent
2e9169de
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
74 additions
and
59 deletions
+74
-59
decoder_api.c
src/decoder_api.c
+5
-0
decoder_api.h
src/decoder_api.h
+2
-0
_flac_common.c
src/inputPlugins/_flac_common.c
+1
-1
aac_plugin.c
src/inputPlugins/aac_plugin.c
+3
-3
audiofile_plugin.c
src/inputPlugins/audiofile_plugin.c
+2
-2
flac_plugin.c
src/inputPlugins/flac_plugin.c
+6
-6
mod_plugin.c
src/inputPlugins/mod_plugin.c
+2
-2
mp3_plugin.c
src/inputPlugins/mp3_plugin.c
+20
-20
mp4_plugin.c
src/inputPlugins/mp4_plugin.c
+3
-3
mpc_plugin.c
src/inputPlugins/mpc_plugin.c
+12
-7
oggflac_plugin.c
src/inputPlugins/oggflac_plugin.c
+7
-6
oggvorbis_plugin.c
src/inputPlugins/oggvorbis_plugin.c
+8
-6
wavpack_plugin.c
src/inputPlugins/wavpack_plugin.c
+3
-3
No files found.
src/decoder_api.c
View file @
817a68b2
...
...
@@ -45,6 +45,11 @@ void decoder_initialized(struct decoder * decoder,
notify_signal
(
&
pc
.
notify
);
}
enum
decoder_command
decoder_get_command
(
mpd_unused
struct
decoder
*
decoder
)
{
return
dc
.
command
;
}
/**
* All chunks are full of decoded data; wait for the player to free
* one.
...
...
src/decoder_api.h
View file @
817a68b2
...
...
@@ -103,6 +103,8 @@ void decoder_initialized(struct decoder * decoder,
const
AudioFormat
*
audio_format
,
float
total_time
);
enum
decoder_command
decoder_get_command
(
struct
decoder
*
decoder
);
/**
* This function is called by the decoder plugin when it has
* successfully decoded block of input data.
...
...
src/inputPlugins/_flac_common.c
View file @
817a68b2
...
...
@@ -178,7 +178,7 @@ void flac_error_common_cb(const char *plugin,
const
FLAC__StreamDecoderErrorStatus
status
,
mpd_unused
FlacData
*
data
)
{
if
(
d
c
.
command
==
DECODE_COMMAND_STOP
)
if
(
d
ecoder_get_command
(
data
->
decoder
)
==
DECODE_COMMAND_STOP
)
return
;
switch
(
status
)
{
...
...
src/inputPlugins/aac_plugin.c
View file @
817a68b2
...
...
@@ -389,10 +389,10 @@ static int aac_decode(struct decoder * mpd_decoder, char *path)
decoder_data
(
mpd_decoder
,
NULL
,
0
,
sampleBuffer
,
sampleBufferLen
,
file_time
,
bitRate
,
NULL
);
if
(
d
c
.
command
==
DECODE_COMMAND_SEEK
)
{
if
(
d
ecoder_get_command
(
decoder
)
==
DECODE_COMMAND_SEEK
)
{
dc
.
seekError
=
1
;
dc_command_finished
();
}
else
if
(
d
c
.
command
==
DECODE_COMMAND_STOP
)
}
else
if
(
d
ecoder_get_command
(
decoder
)
==
DECODE_COMMAND_STOP
)
break
;
}
...
...
@@ -405,7 +405,7 @@ static int aac_decode(struct decoder * mpd_decoder, char *path)
if
(
dc
.
state
!=
DECODE_STATE_DECODE
)
return
-
1
;
if
(
d
c
.
command
==
DECODE_COMMAND_SEEK
)
{
if
(
d
ecoder_get_command
(
decoder
)
==
DECODE_COMMAND_SEEK
)
{
dc
.
seekError
=
1
;
dc_command_finished
();
}
...
...
src/inputPlugins/audiofile_plugin.c
View file @
817a68b2
...
...
@@ -90,7 +90,7 @@ static int audiofile_decode(struct decoder * decoder, char *path)
decoder_initialized
(
decoder
,
&
audio_format
,
total_time
);
do
{
if
(
d
c
.
command
==
DECODE_COMMAND_SEEK
)
{
if
(
d
ecoder_get_command
(
decoder
)
==
DECODE_COMMAND_SEEK
)
{
decoder_clear
(
decoder
);
current
=
dc
.
seekWhere
*
audio_format
.
sampleRate
;
...
...
@@ -108,7 +108,7 @@ static int audiofile_decode(struct decoder * decoder, char *path)
chunk
,
ret
*
fs
,
(
float
)
current
/
(
float
)
audio_format
.
sampleRate
,
bitRate
,
NULL
);
}
while
(
d
c
.
command
!=
DECODE_COMMAND_STOP
);
}
while
(
d
ecoder_get_command
(
decoder
)
!=
DECODE_COMMAND_STOP
);
decoder_flush
(
decoder
);
...
...
src/inputPlugins/flac_plugin.c
View file @
817a68b2
...
...
@@ -37,14 +37,14 @@ static flac_read_status flacRead(mpd_unused const flac_decoder * flacDec,
while
(
1
)
{
r
=
readFromInputStream
(
data
->
inStream
,
(
void
*
)
buf
,
1
,
*
bytes
);
if
(
r
==
0
&&
!
inputStreamAtEOF
(
data
->
inStream
)
&&
d
c
.
command
!=
DECODE_COMMAND_STOP
)
d
ecoder_get_command
(
data
->
decoder
)
!=
DECODE_COMMAND_STOP
)
my_usleep
(
10000
);
else
break
;
}
*
bytes
=
r
;
if
(
r
==
0
&&
d
c
.
command
!=
DECODE_COMMAND_STOP
)
{
if
(
r
==
0
&&
d
ecoder_get_command
(
data
->
decoder
)
!=
DECODE_COMMAND_STOP
)
{
if
(
inputStreamAtEOF
(
data
->
inStream
))
return
flac_read_status_eof
;
else
...
...
@@ -287,7 +287,7 @@ static FLAC__StreamDecoderWriteStatus flacWrite(const flac_decoder *dec,
FLAC__STREAM_DECODER_WRITE_STATUS_ABORT
;
}
data
->
chunk_length
=
0
;
if
(
d
c
.
command
==
DECODE_COMMAND_SEEK
)
{
if
(
d
ecoder_get_command
(
data
->
decoder
)
==
DECODE_COMMAND_SEEK
)
{
return
FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE
;
}
...
...
@@ -423,7 +423,7 @@ static int flac_decode_internal(struct decoder * decoder,
break
;
if
(
flac_get_state
(
flacDec
)
==
flac_decoder_eof
)
break
;
if
(
d
c
.
command
==
DECODE_COMMAND_SEEK
)
{
if
(
d
ecoder_get_command
(
decoder
)
==
DECODE_COMMAND_SEEK
)
{
FLAC__uint64
sampleToSeek
=
dc
.
seekWhere
*
data
.
audio_format
.
sampleRate
+
0
.
5
;
if
(
flac_seek_absolute
(
flacDec
,
sampleToSeek
))
{
...
...
@@ -436,12 +436,12 @@ static int flac_decode_internal(struct decoder * decoder,
dc_command_finished
();
}
}
if
(
d
c
.
command
!=
DECODE_COMMAND_STOP
)
{
if
(
d
ecoder_get_command
(
decoder
)
!=
DECODE_COMMAND_STOP
)
{
flacPrintErroredState
(
flac_get_state
(
flacDec
));
flac_finish
(
flacDec
);
}
/* send last little bit */
if
(
data
.
chunk_length
>
0
&&
d
c
.
command
!=
DECODE_COMMAND_STOP
)
{
if
(
data
.
chunk_length
>
0
&&
d
ecoder_get_command
(
decoder
)
!=
DECODE_COMMAND_STOP
)
{
flacSendChunk
(
&
data
);
decoder_flush
(
decoder
);
}
...
...
src/inputPlugins/mod_plugin.c
View file @
817a68b2
...
...
@@ -187,12 +187,12 @@ static int mod_decode(struct decoder * decoder, char *path)
decoder_initialized
(
decoder
,
&
audio_format
,
0
);
while
(
1
)
{
if
(
d
c
.
command
==
DECODE_COMMAND_SEEK
)
{
if
(
d
ecoder_get_command
(
decoder
)
==
DECODE_COMMAND_SEEK
)
{
dc
.
seekError
=
1
;
dc_command_finished
();
}
if
(
d
c
.
command
==
DECODE_COMMAND_STOP
)
if
(
d
ecoder_get_command
(
decoder
)
==
DECODE_COMMAND_STOP
)
break
;
if
(
!
Player_Active
())
...
...
src/inputPlugins/mp3_plugin.c
View file @
817a68b2
...
...
@@ -669,7 +669,7 @@ static int parse_lame(struct lame *lame, struct mad_bitptr *ptr, int *bitlen)
return
1
;
}
static
int
decodeFirstFrame
(
mp3DecodeData
*
data
,
static
int
decodeFirstFrame
(
mp3DecodeData
*
data
,
struct
decoder
*
decoder
,
MpdTag
**
tag
,
ReplayGainInfo
**
replayGainInfo
)
{
struct
xing
xing
;
...
...
@@ -684,16 +684,16 @@ static int decodeFirstFrame(mp3DecodeData * data,
while
(
1
)
{
while
((
ret
=
decodeNextFrameHeader
(
data
,
tag
,
replayGainInfo
))
==
DECODE_CONT
&&
dc
.
command
!=
DECODE_COMMAND_STOP
);
(
!
decoder
||
decoder_get_command
(
decoder
)
!=
DECODE_COMMAND_STOP
)
);
if
(
ret
==
DECODE_BREAK
||
(
d
c
.
command
==
DECODE_COMMAND_STOP
))
(
d
ecoder
&&
decoder_get_command
(
decoder
)
==
DECODE_COMMAND_STOP
))
return
-
1
;
if
(
ret
==
DECODE_SKIP
)
continue
;
while
((
ret
=
decodeNextFrame
(
data
))
==
DECODE_CONT
&&
dc
.
command
!=
DECODE_COMMAND_STOP
);
(
!
decoder
||
decoder_get_command
(
decoder
)
!=
DECODE_COMMAND_STOP
)
);
if
(
ret
==
DECODE_BREAK
||
(
d
c
.
command
==
DECODE_COMMAND_STOP
))
(
d
ecoder
&&
decoder_get_command
(
decoder
)
==
DECODE_COMMAND_STOP
))
return
-
1
;
if
(
ret
==
DECODE_OK
)
break
;
}
...
...
@@ -786,7 +786,7 @@ static int getMp3TotalTime(char *file)
if
(
openInputStream
(
&
inStream
,
file
)
<
0
)
return
-
1
;
initMp3DecodeData
(
&
data
,
&
inStream
);
if
(
decodeFirstFrame
(
&
data
,
NULL
,
NULL
)
<
0
)
if
(
decodeFirstFrame
(
&
data
,
NULL
,
NULL
,
NULL
)
<
0
)
ret
=
-
1
;
else
ret
=
data
.
totalTime
+
0
.
5
;
...
...
@@ -797,12 +797,12 @@ static int getMp3TotalTime(char *file)
}
static
int
openMp3FromInputStream
(
InputStream
*
inStream
,
mp3DecodeData
*
data
,
MpdTag
**
tag
,
struct
decoder
*
decoder
,
MpdTag
**
tag
,
ReplayGainInfo
**
replayGainInfo
)
{
initMp3DecodeData
(
data
,
inStream
);
*
tag
=
NULL
;
if
(
decodeFirstFrame
(
data
,
tag
,
replayGainInfo
)
<
0
)
{
if
(
decodeFirstFrame
(
data
,
decoder
,
tag
,
replayGainInfo
)
<
0
)
{
mp3DecodeDataFinalize
(
data
);
if
(
tag
&&
*
tag
)
freeMpdTag
(
*
tag
);
...
...
@@ -948,7 +948,7 @@ static int mp3Read(mp3DecodeData * data, struct decoder *decoder,
data
->
decodedFirstFrame
=
1
;
if
(
d
c
.
command
==
DECODE_COMMAND_SEEK
&&
if
(
d
ecoder_get_command
(
decoder
)
==
DECODE_COMMAND_SEEK
&&
data
->
inStream
->
seekable
)
{
long
j
=
0
;
data
->
muteFrame
=
MUTEFRAME_SEEK
;
...
...
@@ -970,7 +970,7 @@ static int mp3Read(mp3DecodeData * data, struct decoder *decoder,
data
->
muteFrame
=
0
;
dc_command_finished
();
}
}
else
if
(
d
c
.
command
==
DECODE_COMMAND_SEEK
&&
}
else
if
(
d
ecoder_get_command
(
decoder
)
==
DECODE_COMMAND_SEEK
&&
!
data
->
inStream
->
seekable
)
{
dc
.
seekError
=
1
;
dc_command_finished
();
...
...
@@ -982,23 +982,23 @@ static int mp3Read(mp3DecodeData * data, struct decoder *decoder,
while
((
ret
=
decodeNextFrameHeader
(
data
,
NULL
,
replayGainInfo
))
==
DECODE_CONT
&&
d
c
.
command
!=
DECODE_COMMAND_STOP
)
;
if
(
ret
==
DECODE_BREAK
||
d
c
.
command
!=
DECODE_COMMAND_NONE
)
&&
d
ecoder_get_command
(
decoder
)
!=
DECODE_COMMAND_STOP
)
;
if
(
ret
==
DECODE_BREAK
||
d
ecoder_get_command
(
decoder
)
!=
DECODE_COMMAND_NONE
)
break
;
else
if
(
ret
==
DECODE_SKIP
)
skip
=
1
;
if
(
!
data
->
muteFrame
)
{
while
((
ret
=
decodeNextFrame
(
data
))
==
DECODE_CONT
&&
d
c
.
command
==
DECODE_COMMAND_NONE
)
;
d
ecoder_get_command
(
decoder
)
==
DECODE_COMMAND_NONE
)
;
if
(
ret
==
DECODE_BREAK
||
d
c
.
command
!=
DECODE_COMMAND_NONE
)
d
ecoder_get_command
(
decoder
)
!=
DECODE_COMMAND_NONE
)
break
;
}
if
(
!
skip
&&
ret
==
DECODE_OK
)
break
;
}
if
(
d
c
.
command
==
DECODE_COMMAND_STOP
)
if
(
d
ecoder_get_command
(
decoder
)
==
DECODE_COMMAND_STOP
)
return
DECODE_BREAK
;
return
ret
;
...
...
@@ -1019,9 +1019,9 @@ static int mp3_decode(struct decoder * decoder, InputStream * inStream)
ReplayGainInfo
*
replayGainInfo
=
NULL
;
AudioFormat
audio_format
;
if
(
openMp3FromInputStream
(
inStream
,
&
data
,
&
tag
,
&
replayGainInfo
)
<
0
)
{
if
(
d
c
.
command
!=
DECODE_COMMAND_STOP
)
{
if
(
openMp3FromInputStream
(
inStream
,
&
data
,
decoder
,
&
tag
,
&
replayGainInfo
)
<
0
)
{
if
(
d
ecoder_get_command
(
decoder
)
!=
DECODE_COMMAND_STOP
)
{
ERROR
(
"Input does not appear to be a mp3 bit stream.
\n
"
);
return
-
1
;
...
...
@@ -1060,7 +1060,7 @@ static int mp3_decode(struct decoder * decoder, InputStream * inStream)
while
(
mp3Read
(
&
data
,
decoder
,
&
replayGainInfo
)
!=
DECODE_BREAK
)
;
/* send last little bit if not DECODE_COMMAND_STOP */
if
(
d
c
.
command
!=
DECODE_COMMAND_STOP
&&
if
(
d
ecoder_get_command
(
decoder
)
!=
DECODE_COMMAND_STOP
&&
data
.
outputPtr
!=
data
.
outputBuffer
&&
data
.
flush
)
{
decoder_data
(
decoder
,
NULL
,
data
.
inStream
->
seekable
,
...
...
@@ -1073,7 +1073,7 @@ static int mp3_decode(struct decoder * decoder, InputStream * inStream)
if
(
replayGainInfo
)
freeReplayGainInfo
(
replayGainInfo
);
if
(
d
c
.
command
==
DECODE_COMMAND_SEEK
&&
if
(
d
ecoder_get_command
(
decoder
)
==
DECODE_COMMAND_SEEK
&&
data
.
muteFrame
==
MUTEFRAME_SEEK
)
{
decoder_clear
(
decoder
);
dc_command_finished
();
...
...
src/inputPlugins/mp4_plugin.c
View file @
817a68b2
...
...
@@ -178,7 +178,7 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
seekTable
=
xmalloc
(
sizeof
(
float
)
*
numSamples
);
for
(
sampleId
=
0
;
sampleId
<
numSamples
;
sampleId
++
)
{
if
(
d
c
.
command
==
DECODE_COMMAND_SEEK
)
if
(
d
ecoder_get_command
(
mpd_decoder
)
==
DECODE_COMMAND_SEEK
)
seeking
=
1
;
if
(
seeking
&&
seekTableEnd
>
1
&&
...
...
@@ -270,7 +270,7 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
decoder_data
(
mpd_decoder
,
inStream
,
1
,
sampleBuffer
,
sampleBufferLen
,
file_time
,
bitRate
,
NULL
);
if
(
d
c
.
command
==
DECODE_COMMAND_STOP
)
if
(
d
ecoder_get_command
(
mpd_decoder
)
==
DECODE_COMMAND_STOP
)
break
;
}
...
...
@@ -282,7 +282,7 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
if
(
dc
.
state
!=
DECODE_STATE_DECODE
)
return
-
1
;
if
(
d
c
.
command
==
DECODE_COMMAND_SEEK
&&
seeking
)
{
if
(
d
ecoder_get_command
(
mpd_decoder
)
==
DECODE_COMMAND_SEEK
&&
seeking
)
{
decoder_clear
(
mpd_decoder
);
dc_command_finished
();
}
...
...
src/inputPlugins/mpc_plugin.c
View file @
817a68b2
...
...
@@ -27,6 +27,7 @@
typedef
struct
_MpcCallbackData
{
InputStream
*
inStream
;
struct
decoder
*
decoder
;
}
MpcCallbackData
;
static
mpc_int32_t
mpc_read_cb
(
void
*
vdata
,
void
*
ptr
,
mpc_int32_t
size
)
...
...
@@ -37,7 +38,8 @@ static mpc_int32_t mpc_read_cb(void *vdata, void *ptr, mpc_int32_t size)
while
(
1
)
{
ret
=
readFromInputStream
(
data
->
inStream
,
ptr
,
1
,
size
);
if
(
ret
==
0
&&
!
inputStreamAtEOF
(
data
->
inStream
)
&&
(
dc
.
command
!=
DECODE_COMMAND_STOP
))
(
data
->
decoder
&&
decoder_get_command
(
data
->
decoder
)
!=
DECODE_COMMAND_STOP
))
my_usleep
(
10000
);
else
break
;
...
...
@@ -132,6 +134,7 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
ReplayGainInfo
*
replayGainInfo
=
NULL
;
data
.
inStream
=
inStream
;
data
.
decoder
=
mpd_decoder
;
reader
.
read
=
mpc_read_cb
;
reader
.
seek
=
mpc_seek_cb
;
...
...
@@ -143,7 +146,7 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
mpc_streaminfo_init
(
&
info
);
if
((
ret
=
mpc_streaminfo_read
(
&
info
,
&
reader
))
!=
ERROR_CODE_OK
)
{
if
(
d
c
.
command
!=
DECODE_COMMAND_STOP
)
{
if
(
d
ecoder_get_command
(
mpd_decoder
)
!=
DECODE_COMMAND_STOP
)
{
ERROR
(
"Not a valid musepack stream
\n
"
);
return
-
1
;
}
...
...
@@ -153,7 +156,7 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
mpc_decoder_setup
(
&
decoder
,
&
reader
);
if
(
!
mpc_decoder_initialize
(
&
decoder
,
&
info
))
{
if
(
d
c
.
command
!=
DECODE_COMMAND_STOP
)
{
if
(
d
ecoder_get_command
(
mpd_decoder
)
!=
DECODE_COMMAND_STOP
)
{
ERROR
(
"Not a valid musepack stream
\n
"
);
return
-
1
;
}
...
...
@@ -174,7 +177,7 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
mpc_streaminfo_get_length
(
&
info
));
while
(
!
eof
)
{
if
(
d
c
.
command
==
DECODE_COMMAND_SEEK
)
{
if
(
d
ecoder_get_command
(
mpd_decoder
)
==
DECODE_COMMAND_SEEK
)
{
samplePos
=
dc
.
seekWhere
*
audio_format
.
sampleRate
;
if
(
mpc_decoder_seek_sample
(
&
decoder
,
samplePos
))
{
decoder_clear
(
mpd_decoder
);
...
...
@@ -190,7 +193,7 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
ret
=
mpc_decoder_decode
(
&
decoder
,
sample_buffer
,
&
vbrUpdateAcc
,
&
vbrUpdateBits
);
if
(
ret
<=
0
||
d
c
.
command
==
DECODE_COMMAND_STOP
)
{
if
(
ret
<=
0
||
d
ecoder_get_command
(
mpd_decoder
)
==
DECODE_COMMAND_STOP
)
{
eof
=
1
;
break
;
}
...
...
@@ -221,7 +224,7 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
chunkpos
=
0
;
s16
=
(
mpd_sint16
*
)
chunk
;
if
(
d
c
.
command
==
DECODE_COMMAND_STOP
)
{
if
(
d
ecoder_get_command
(
mpd_decoder
)
==
DECODE_COMMAND_STOP
)
{
eof
=
1
;
break
;
}
...
...
@@ -229,7 +232,8 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
}
}
if
(
dc
.
command
!=
DECODE_COMMAND_STOP
&&
chunkpos
>
0
)
{
if
(
decoder_get_command
(
mpd_decoder
)
!=
DECODE_COMMAND_STOP
&&
chunkpos
>
0
)
{
total_time
=
((
float
)
samplePos
)
/
audio_format
.
sampleRate
;
bitRate
=
...
...
@@ -257,6 +261,7 @@ static float mpcGetTime(char *file)
MpcCallbackData
data
;
data
.
inStream
=
&
inStream
;
data
.
decoder
=
NULL
;
reader
.
read
=
mpc_read_cb
;
reader
.
seek
=
mpc_seek_cb
;
...
...
src/inputPlugins/oggflac_plugin.c
View file @
817a68b2
...
...
@@ -50,7 +50,7 @@ static OggFLAC__SeekableStreamDecoderReadStatus of_read_cb(const
while
(
1
)
{
r
=
readFromInputStream
(
data
->
inStream
,
(
void
*
)
buf
,
1
,
*
bytes
);
if
(
r
==
0
&&
!
inputStreamAtEOF
(
data
->
inStream
)
&&
d
c
.
command
!=
DECODE_COMMAND_STOP
)
d
ecoder_get_command
(
data
->
decoder
)
!=
DECODE_COMMAND_STOP
)
my_usleep
(
10000
);
else
break
;
...
...
@@ -58,7 +58,7 @@ static OggFLAC__SeekableStreamDecoderReadStatus of_read_cb(const
*
bytes
=
r
;
if
(
r
==
0
&&
!
inputStreamAtEOF
(
data
->
inStream
)
&&
d
c
.
command
!=
DECODE_COMMAND_STOP
)
d
ecoder_get_command
(
data
->
decoder
)
!=
DECODE_COMMAND_STOP
)
return
OggFLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR
;
return
OggFLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK
;
...
...
@@ -195,7 +195,7 @@ static FLAC__StreamDecoderWriteStatus oggflacWrite(const
FLAC__STREAM_DECODER_WRITE_STATUS_ABORT
;
}
data
->
chunk_length
=
0
;
if
(
d
c
.
command
==
DECODE_COMMAND_SEEK
)
{
if
(
d
ecoder_get_command
(
data
->
decoder
)
==
DECODE_COMMAND_SEEK
)
{
return
FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE
;
}
...
...
@@ -353,7 +353,7 @@ static int oggflac_decode(struct decoder * mpd_decoder, InputStream * inStream)
OggFLAC__SEEKABLE_STREAM_DECODER_OK
)
{
break
;
}
if
(
d
c
->
command
==
DECODE_COMMAND_SEEK
)
{
if
(
d
ecoder_get_command
(
mpd_decoder
)
==
DECODE_COMMAND_SEEK
)
{
FLAC__uint64
sampleToSeek
=
dc
->
seekWhere
*
data
.
audio_format
.
sampleRate
+
0
.
5
;
if
(
OggFLAC__seekable_stream_decoder_seek_absolute
...
...
@@ -368,13 +368,14 @@ static int oggflac_decode(struct decoder * mpd_decoder, InputStream * inStream)
}
}
if
(
d
c
.
command
!=
DECODE_COMMAND_STOP
)
{
if
(
d
ecoder_get_command
(
mpd_decoder
)
!=
DECODE_COMMAND_STOP
)
{
oggflacPrintErroredState
(
OggFLAC__seekable_stream_decoder_get_state
(
decoder
));
OggFLAC__seekable_stream_decoder_finish
(
decoder
);
}
/* send last little bit */
if
(
data
.
chunk_length
>
0
&&
dc
.
command
!=
DECODE_COMMAND_STOP
)
{
if
(
data
.
chunk_length
>
0
&&
decoder_get_command
(
mpd_decoder
)
!=
DECODE_COMMAND_STOP
)
{
flacSendChunk
(
&
data
);
decoder_flush
(
mpd_decoder
);
}
...
...
src/inputPlugins/oggvorbis_plugin.c
View file @
817a68b2
...
...
@@ -50,6 +50,7 @@
typedef
struct
_OggCallbackData
{
InputStream
*
inStream
;
struct
decoder
*
decoder
;
}
OggCallbackData
;
static
size_t
ogg_read_cb
(
void
*
ptr
,
size_t
size
,
size_t
nmemb
,
void
*
vdata
)
...
...
@@ -60,7 +61,7 @@ static size_t ogg_read_cb(void *ptr, size_t size, size_t nmemb, void *vdata)
while
(
1
)
{
ret
=
readFromInputStream
(
data
->
inStream
,
ptr
,
size
,
nmemb
);
if
(
ret
==
0
&&
!
inputStreamAtEOF
(
data
->
inStream
)
&&
d
c
.
command
!=
DECODE_COMMAND_STOP
)
{
d
ecoder_get_command
(
data
->
decoder
)
!=
DECODE_COMMAND_STOP
)
{
my_usleep
(
10000
);
}
else
break
;
...
...
@@ -74,7 +75,7 @@ static size_t ogg_read_cb(void *ptr, size_t size, size_t nmemb, void *vdata)
static
int
ogg_seek_cb
(
void
*
vdata
,
ogg_int64_t
offset
,
int
whence
)
{
const
OggCallbackData
*
data
=
(
const
OggCallbackData
*
)
vdata
;
if
(
d
c
.
command
==
DECODE_COMMAND_STOP
)
if
(
d
ecoder_get_command
(
data
->
decoder
)
==
DECODE_COMMAND_STOP
)
return
-
1
;
return
seekInputStream
(
data
->
inStream
,
offset
,
whence
);
}
...
...
@@ -229,13 +230,14 @@ static int oggvorbis_decode(struct decoder * decoder, InputStream * inStream)
const
char
*
errorStr
;
data
.
inStream
=
inStream
;
data
.
decoder
=
decoder
;
callbacks
.
read_func
=
ogg_read_cb
;
callbacks
.
seek_func
=
ogg_seek_cb
;
callbacks
.
close_func
=
ogg_close_cb
;
callbacks
.
tell_func
=
ogg_tell_cb
;
if
((
ret
=
ov_open_callbacks
(
&
data
,
&
vf
,
NULL
,
0
,
callbacks
))
<
0
)
{
if
(
d
c
.
command
!=
DECODE_COMMAND_STOP
)
{
if
(
d
ecoder_get_command
(
decoder
)
!=
DECODE_COMMAND_STOP
)
{
switch
(
ret
)
{
case
OV_EREAD
:
errorStr
=
"read error"
;
...
...
@@ -265,7 +267,7 @@ static int oggvorbis_decode(struct decoder * decoder, InputStream * inStream)
audio_format
.
bits
=
16
;
while
(
1
)
{
if
(
d
c
.
command
==
DECODE_COMMAND_SEEK
)
{
if
(
d
ecoder_get_command
(
decoder
)
==
DECODE_COMMAND_SEEK
)
{
if
(
0
==
ov_time_seek_page
(
&
vf
,
dc
.
seekWhere
))
{
decoder_clear
(
decoder
);
chunkpos
=
0
;
...
...
@@ -315,12 +317,12 @@ static int oggvorbis_decode(struct decoder * decoder, InputStream * inStream)
ov_pcm_tell
(
&
vf
)
/
audio_format
.
sampleRate
,
bitRate
,
replayGainInfo
);
chunkpos
=
0
;
if
(
d
c
.
command
==
DECODE_COMMAND_STOP
)
if
(
d
ecoder_get_command
(
decoder
)
==
DECODE_COMMAND_STOP
)
break
;
}
}
if
(
d
c
.
command
!=
DECODE_COMMAND_STOP
&&
chunkpos
>
0
)
{
if
(
d
ecoder_get_command
(
decoder
)
!=
DECODE_COMMAND_STOP
&&
chunkpos
>
0
)
{
decoder_data
(
decoder
,
NULL
,
inStream
->
seekable
,
chunk
,
chunkpos
,
ov_time_tell
(
&
vf
),
bitRate
,
...
...
src/inputPlugins/wavpack_plugin.c
View file @
817a68b2
...
...
@@ -172,7 +172,7 @@ static void wavpack_decode(struct decoder * decoder,
position
=
0
;
do
{
if
(
d
c
.
command
==
DECODE_COMMAND_SEEK
)
{
if
(
d
ecoder_get_command
(
decoder
)
==
DECODE_COMMAND_SEEK
)
{
if
(
canseek
)
{
int
where
;
...
...
@@ -191,7 +191,7 @@ static void wavpack_decode(struct decoder * decoder,
dc_command_finished
();
}
if
(
d
c
.
command
==
DECODE_COMMAND_STOP
)
if
(
d
ecoder_get_command
(
decoder
)
==
DECODE_COMMAND_STOP
)
break
;
samplesgot
=
WavpackUnpackSamples
(
wpc
,
...
...
@@ -501,7 +501,7 @@ static int wavpack_streamdecode(struct decoder * decoder, InputStream *is)
break
;
}
if
(
d
c
.
command
==
DECODE_COMMAND_STOP
)
{
if
(
d
ecoder_get_command
(
decoder
)
==
DECODE_COMMAND_STOP
)
{
break
;
}
...
...
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