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
bc6472bb
Commit
bc6472bb
authored
Jul 09, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/audiofile: use decoder_read()
.. instead of InputStream::LockRead(). The former is cancellable.
parent
d4bd947b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
15 deletions
+26
-15
NEWS
NEWS
+2
-0
AudiofileDecoderPlugin.cxx
src/decoder/AudiofileDecoderPlugin.cxx
+24
-15
No files found.
NEWS
View file @
bc6472bb
...
...
@@ -2,6 +2,8 @@ ver 0.18.12 (not yet released)
* database
- proxy: fix build failure with libmpdclient 2.2
- proxy: fix add/search and other commands with libmpdclient < 2.9
* decoder
- audiofile: improve responsiveness
ver 0.18.11 (2014/05/12)
* decoder
...
...
src/decoder/AudiofileDecoderPlugin.cxx
View file @
bc6472bb
...
...
@@ -38,6 +38,15 @@
static
constexpr
Domain
audiofile_domain
(
"audiofile"
);
struct
AudioFileInputStream
{
Decoder
*
const
decoder
;
InputStream
&
is
;
size_t
Read
(
void
*
buffer
,
size_t
size
)
{
return
decoder_read
(
decoder
,
is
,
buffer
,
size
);
}
};
static
int
audiofile_get_duration
(
const
char
*
file
)
{
int
total_time
;
...
...
@@ -55,29 +64,26 @@ static int audiofile_get_duration(const char *file)
static
ssize_t
audiofile_file_read
(
AFvirtualfile
*
vfile
,
void
*
data
,
size_t
length
)
{
InputStream
&
is
=
*
(
InputStream
*
)
vfile
->
closure
;
Error
error
;
size_t
nbytes
=
is
.
LockRead
(
data
,
length
,
error
);
if
(
nbytes
==
0
&&
error
.
IsDefined
())
{
LogError
(
error
);
return
-
1
;
}
AudioFileInputStream
&
afis
=
*
(
AudioFileInputStream
*
)
vfile
->
closure
;
return
nbytes
;
return
afis
.
Read
(
data
,
length
)
;
}
static
AFfileoffset
audiofile_file_length
(
AFvirtualfile
*
vfile
)
{
InputStream
&
is
=
*
(
InputStream
*
)
vfile
->
closure
;
AudioFileInputStream
&
afis
=
*
(
AudioFileInputStream
*
)
vfile
->
closure
;
InputStream
&
is
=
afis
.
is
;
return
is
.
GetSize
();
}
static
AFfileoffset
audiofile_file_tell
(
AFvirtualfile
*
vfile
)
{
InputStream
&
is
=
*
(
InputStream
*
)
vfile
->
closure
;
AudioFileInputStream
&
afis
=
*
(
AudioFileInputStream
*
)
vfile
->
closure
;
InputStream
&
is
=
afis
.
is
;
return
is
.
GetOffset
();
}
...
...
@@ -92,7 +98,9 @@ audiofile_file_destroy(AFvirtualfile *vfile)
static
AFfileoffset
audiofile_file_seek
(
AFvirtualfile
*
vfile
,
AFfileoffset
offset
,
int
is_relative
)
{
InputStream
&
is
=
*
(
InputStream
*
)
vfile
->
closure
;
AudioFileInputStream
&
afis
=
*
(
AudioFileInputStream
*
)
vfile
->
closure
;
InputStream
&
is
=
afis
.
is
;
int
whence
=
(
is_relative
?
SEEK_CUR
:
SEEK_SET
);
Error
error
;
...
...
@@ -104,10 +112,10 @@ audiofile_file_seek(AFvirtualfile *vfile, AFfileoffset offset, int is_relative)
}
static
AFvirtualfile
*
setup_virtual_fops
(
InputStream
&
stream
)
setup_virtual_fops
(
AudioFileInputStream
&
afis
)
{
AFvirtualfile
*
vf
=
new
AFvirtualfile
();
vf
->
closure
=
&
stream
;
vf
->
closure
=
&
afis
;
vf
->
write
=
nullptr
;
vf
->
read
=
audiofile_file_read
;
vf
->
length
=
audiofile_file_length
;
...
...
@@ -174,7 +182,8 @@ audiofile_stream_decode(Decoder &decoder, InputStream &is)
return
;
}
vf
=
setup_virtual_fops
(
is
);
AudioFileInputStream
afis
{
&
decoder
,
is
};
vf
=
setup_virtual_fops
(
afis
);
af_fp
=
afOpenVirtualFile
(
vf
,
"r"
,
nullptr
);
if
(
af_fp
==
AF_NULL_FILEHANDLE
)
{
...
...
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