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
547e3587
Commit
547e3587
authored
May 21, 2004
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
do input buffering in while sleeping loop of sending stuff to output buffer
git-svn-id:
https://svn.musicpd.org/mpd/trunk@1125
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
aea1ae9b
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
47 additions
and
34 deletions
+47
-34
TODO
TODO
+4
-9
aac_decode.c
src/aac_decode.c
+2
-2
audiofile_decode.c
src/audiofile_decode.c
+5
-1
flac_decode.c
src/flac_decode.c
+2
-2
inputStream.h
src/inputStream.h
+3
-0
inputStream_http.c
src/inputStream_http.c
+7
-7
mp3_decode.c
src/mp3_decode.c
+4
-2
mp4_decode.c
src/mp4_decode.c
+2
-2
ogg_decode.c
src/ogg_decode.c
+4
-4
outputBuffer.c
src/outputBuffer.c
+8
-3
outputBuffer.h
src/outputBuffer.h
+6
-2
No files found.
TODO
View file @
547e3587
1) play streams
a) make seekings non-blocking:
1) player: first check that seekWhere isn't already buffered
b) bufferInput in outputBuffer waiting!
1) implement some sort of callback mechanism for this
for abstraction sake
c) deal with pausing better
a) deal with pausing better
1) seekable, on resuming pause, check if we need to reconnect,
jumping to offset
2) if seekable, at some point after init, mark this!
3) if not seekable, reset buffer, and elapsedTime when
unpaused
d
) put some sort of error reporting for streaming/inputStream!
e
) fetch metadata and store in DecoderControl and pass to
b
) put some sort of error reporting for streaming/inputStream!
c
) fetch metadata and store in DecoderControl and pass to
PlayerControl
1) eventually deal with icy-metadata
2) parse metadata on the fly in decoders
f
) command for dealing with the changing metadata, currentsonginfo
d
) command for dealing with the changing metadata, currentsonginfo
or something
2) how to deal with streams and the db
...
...
src/aac_decode.c
View file @
547e3587
...
...
@@ -362,8 +362,8 @@ int aac_decode(OutputBuffer * cb, DecoderControl * dc) {
sampleBufferLen
=
sampleCount
*
2
;
sendDataToOutputBuffer
(
cb
,
dc
,
sampleBuffer
,
sampleBufferLen
,
time
,
bitRate
);
sendDataToOutputBuffer
(
cb
,
NULL
,
dc
,
sampleBuffer
,
sampleBufferLen
,
time
,
bitRate
);
if
(
dc
->
seek
)
dc
->
seek
=
0
;
else
if
(
dc
->
stop
)
{
eof
=
1
;
...
...
src/audiofile_decode.c
View file @
547e3587
...
...
@@ -109,7 +109,11 @@ int audiofile_decode(OutputBuffer * cb, DecoderControl * dc) {
if
(
ret
<=
0
)
eof
=
1
;
else
{
current
+=
ret
;
sendDataToOutputBuffer
(
cb
,
dc
,
chunk
,
ret
*
fs
,
sendDataToOutputBuffer
(
cb
,
NULL
,
dc
,
chunk
,
ret
*
fs
,
(
float
)
current
/
(
float
)
dc
->
audioFormat
.
sampleRate
,
bitRate
);
...
...
src/flac_decode.c
View file @
547e3587
...
...
@@ -376,8 +376,8 @@ int flacSendChunk(FlacData * data) {
doReplayGain
(
data
->
chunk
,
data
->
chunk_length
,
&
(
data
->
dc
->
audioFormat
),
data
->
replayGainScale
);
switch
(
sendDataToOutputBuffer
(
data
->
cb
,
data
->
dc
,
data
->
chunk
,
data
->
chunk_length
,
data
->
time
,
data
->
bitRate
))
switch
(
sendDataToOutputBuffer
(
data
->
cb
,
NULL
,
data
->
dc
,
data
->
chunk
,
data
->
chunk_length
,
data
->
time
,
data
->
bitRate
))
{
case
OUTPUT_BUFFER_DC_STOP
:
return
-
1
;
...
...
src/inputStream.h
View file @
547e3587
...
...
@@ -53,6 +53,9 @@ int openInputStream(InputStream * inStream, char * url);
int
seekInputStream
(
InputStream
*
inStream
,
long
offset
,
int
whence
);
int
closeInputStream
(
InputStream
*
inStream
);
int
inputStreamAtEOF
(
InputStream
*
inStream
);
/* return value: -1 is error, 1 inidicates stuff was buffered, 0 means nothing
was buffered */
int
bufferInputStream
(
InputStream
*
inStream
);
size_t
readFromInputStream
(
InputStream
*
inStream
,
void
*
ptr
,
size_t
size
,
...
...
src/inputStream_http.c
View file @
547e3587
...
...
@@ -542,20 +542,20 @@ int inputStream_httpBuffer(InputStream * inStream) {
readed
=
read
(
data
->
sock
,
data
->
buffer
+
data
->
buflen
,
(
size_t
)(
HTTP_BUFFER_SIZE
-
1
-
data
->
buflen
));
if
(
readed
<
0
&&
(
errno
==
EAGAIN
||
errno
==
EINTR
));
if
(
readed
<
0
&&
(
errno
==
EAGAIN
||
errno
==
EINTR
))
{
readed
=
0
;
}
else
if
(
readed
<=
0
)
{
close
(
data
->
sock
);
data
->
connState
=
HTTP_CONN_STATE_CLOSED
;
readed
=
0
;
}
else
{
/*fwrite(data->buffer+data->buflen,1,readed,stdout);*/
data
->
buflen
+=
readed
;
}
/*fwrite(data->buffer+data->buflen,1,readed,stdout);*/
data
->
buflen
+=
readed
;
}
if
(
data
->
buflen
>
HTTP_PREBUFFER_SIZE
)
data
->
prebuffer
=
0
;
return
0
;
return
(
readed
?
1
:
0
)
;
}
/* vim:set shiftwidth=8 tabstop=8 expandtab: */
src/mp3_decode.c
View file @
547e3587
...
...
@@ -494,7 +494,9 @@ int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc) {
if
(
data
->
outputPtr
==
data
->
outputBufferEnd
)
{
long
ret
;
ret
=
sendDataToOutputBuffer
(
cb
,
dc
,
ret
=
sendDataToOutputBuffer
(
cb
,
data
->
inStream
,
dc
,
data
->
outputBuffer
,
MP3_DATA_OUTPUT_BUFFER_SIZE
,
data
->
elapsedTime
,
...
...
@@ -584,7 +586,7 @@ int mp3_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream) {
while
(
mp3Read
(
&
data
,
cb
,
dc
)
!=
DECODE_BREAK
);
/* send last little bit if not dc->stop */
if
(
data
.
outputPtr
!=
data
.
outputBuffer
&&
data
.
flush
)
{
if
(
sendDataToOutputBuffer
(
cb
,
dc
,
data
.
outputBuffer
,
if
(
sendDataToOutputBuffer
(
cb
,
NULL
,
dc
,
data
.
outputBuffer
,
data
.
outputPtr
-
data
.
outputBuffer
,
data
.
elapsedTime
,
data
.
bitRate
/
1000
)
==
0
)
{
...
...
src/mp4_decode.c
View file @
547e3587
...
...
@@ -279,8 +279,8 @@ int mp4_decode(OutputBuffer * cb, DecoderControl * dc) {
sampleBuffer
+=
offset
*
channels
*
2
;
sendDataToOutputBuffer
(
cb
,
dc
,
sampleBuffer
,
sampleBufferLen
,
time
,
bitRate
);
sendDataToOutputBuffer
(
cb
,
NULL
,
dc
,
sampleBuffer
,
sampleBufferLen
,
time
,
bitRate
);
if
(
dc
->
stop
)
{
eof
=
1
;
break
;
...
...
src/ogg_decode.c
View file @
547e3587
...
...
@@ -241,16 +241,16 @@ int ogg_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream)
}
doReplayGain
(
chunk
,
ret
,
&
(
dc
->
audioFormat
),
replayGainScale
);
sendDataToOutputBuffer
(
cb
,
dc
,
chunk
,
chunkpos
,
ov_time_tell
(
&
vf
),
bitRate
);
sendDataToOutputBuffer
(
cb
,
inStream
,
dc
,
chunk
,
chunkpos
,
ov_time_tell
(
&
vf
),
bitRate
);
if
(
dc
->
stop
)
break
;
chunkpos
=
0
;
}
}
if
(
!
dc
->
stop
&&
chunkpos
>
0
)
{
sendDataToOutputBuffer
(
cb
,
dc
,
chunk
,
chunkpos
,
ov_time_tell
(
&
vf
),
bitRate
);
sendDataToOutputBuffer
(
cb
,
NULL
,
dc
,
chunk
,
chunkpos
,
ov_time_tell
(
&
vf
),
bitRate
);
}
ov_clear
(
&
vf
);
...
...
src/outputBuffer.c
View file @
547e3587
...
...
@@ -43,8 +43,9 @@ void flushOutputBuffer(OutputBuffer * cb) {
}
}
int
sendDataToOutputBuffer
(
OutputBuffer
*
cb
,
DecoderControl
*
dc
,
char
*
dataIn
,
long
dataInLen
,
float
time
,
mpd_uint16
bitRate
)
int
sendDataToOutputBuffer
(
OutputBuffer
*
cb
,
InputStream
*
inStream
,
DecoderControl
*
dc
,
char
*
dataIn
,
long
dataInLen
,
float
time
,
mpd_uint16
bitRate
)
{
mpd_uint16
dataToSend
;
mpd_uint16
chunkLeft
;
...
...
@@ -75,7 +76,11 @@ int sendDataToOutputBuffer(OutputBuffer * cb, DecoderControl * dc,
if
(
currentChunk
!=
cb
->
end
)
{
while
(
cb
->
begin
==
cb
->
end
&&
cb
->
wrap
&&
!
dc
->
stop
)
{
my_usleep
(
10000
);
if
(
!
inStream
||
bufferInputStream
(
inStream
)
<=
0
)
{
my_usleep
(
10000
);
}
}
if
(
dc
->
stop
)
return
OUTPUT_BUFFER_DC_STOP
;
...
...
src/outputBuffer.h
View file @
547e3587
...
...
@@ -22,6 +22,7 @@
#include "mpd_types.h"
#include "decode.h"
#include "audio.h"
#include "inputStream.h"
#define OUTPUT_BUFFER_DC_STOP -1
#define OUTPUT_BUFFER_DC_SEEK -2
...
...
@@ -42,8 +43,11 @@ void clearOutputBuffer(OutputBuffer * cb);
void
flushOutputBuffer
(
OutputBuffer
*
cb
);
int
sendDataToOutputBuffer
(
OutputBuffer
*
cb
,
DecoderControl
*
dc
,
char
*
data
,
long
datalen
,
float
time
,
mpd_uint16
bitRate
);
/* we send inStream where for buffering the inputStream while waiting to
send the next chunk */
int
sendDataToOutputBuffer
(
OutputBuffer
*
cb
,
InputStream
*
inStream
,
DecoderControl
*
dc
,
char
*
data
,
long
datalen
,
float
time
,
mpd_uint16
bitRate
);
#endif
/* vim:set shiftwidth=4 tabstop=8 expandtab: */
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