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
0ef843f1
Commit
0ef843f1
authored
Jul 11, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/sndfile: use decoder_read()
.. instead of InputStream::LockRead(). The former is cancellable.
parent
eb79d830
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
16 deletions
+23
-16
NEWS
NEWS
+1
-0
SndfileDecoderPlugin.cxx
src/decoder/SndfileDecoderPlugin.cxx
+22
-16
No files found.
NEWS
View file @
0ef843f1
...
...
@@ -6,6 +6,7 @@ ver 0.18.12 (not yet released)
- audiofile: improve responsiveness
- audiofile: fix WAV stream playback
- dsdiff, dsf: fix stream playback
- sndfile: improve responsiveness
* randomize next song when enabling "random" mode while not playing
* randomize next song when adding to single-song queue
...
...
src/decoder/SndfileDecoderPlugin.cxx
View file @
0ef843f1
...
...
@@ -31,10 +31,20 @@
static
constexpr
Domain
sndfile_domain
(
"sndfile"
);
struct
SndfileInputStream
{
Decoder
*
const
decoder
;
InputStream
&
is
;
size_t
Read
(
void
*
buffer
,
size_t
size
)
{
return
decoder_read
(
decoder
,
is
,
buffer
,
size
);
}
};
static
sf_count_t
sndfile_vio_get_filelen
(
void
*
user_data
)
{
const
InputStream
&
is
=
*
(
const
InputStream
*
)
user_data
;
SndfileInputStream
&
sis
=
*
(
SndfileInputStream
*
)
user_data
;
const
InputStream
&
is
=
sis
.
is
;
return
is
.
GetSize
();
}
...
...
@@ -42,7 +52,8 @@ sndfile_vio_get_filelen(void *user_data)
static
sf_count_t
sndfile_vio_seek
(
sf_count_t
offset
,
int
whence
,
void
*
user_data
)
{
InputStream
&
is
=
*
(
InputStream
*
)
user_data
;
SndfileInputStream
&
sis
=
*
(
SndfileInputStream
*
)
user_data
;
InputStream
&
is
=
sis
.
is
;
Error
error
;
if
(
!
is
.
LockSeek
(
offset
,
whence
,
error
))
{
...
...
@@ -56,25 +67,18 @@ sndfile_vio_seek(sf_count_t offset, int whence, void *user_data)
static
sf_count_t
sndfile_vio_read
(
void
*
ptr
,
sf_count_t
count
,
void
*
user_data
)
{
InputStream
&
is
=
*
(
InputStream
*
)
user_data
;
SndfileInputStream
&
sis
=
*
(
Sndfile
InputStream
*
)
user_data
;
sf_count_t
total_bytes
=
0
;
Error
error
;
/* this loop is necessary because libsndfile chokes on partial
reads */
do
{
size_t
nbytes
=
is
.
LockRead
((
char
*
)
ptr
+
total_bytes
,
count
-
total_bytes
,
error
);
if
(
nbytes
==
0
)
{
if
(
error
.
IsDefined
())
{
LogError
(
error
);
return
-
1
;
}
break
;
}
size_t
nbytes
=
sis
.
Read
((
char
*
)
ptr
+
total_bytes
,
count
-
total_bytes
);
if
(
nbytes
==
0
)
return
-
1
;
total_bytes
+=
nbytes
;
}
while
(
total_bytes
<
count
);
...
...
@@ -94,7 +98,8 @@ sndfile_vio_write(gcc_unused const void *ptr,
static
sf_count_t
sndfile_vio_tell
(
void
*
user_data
)
{
const
InputStream
&
is
=
*
(
const
InputStream
*
)
user_data
;
SndfileInputStream
&
sis
=
*
(
SndfileInputStream
*
)
user_data
;
const
InputStream
&
is
=
sis
.
is
;
return
is
.
GetOffset
();
}
...
...
@@ -140,7 +145,8 @@ sndfile_stream_decode(Decoder &decoder, InputStream &is)
info
.
format
=
0
;
sf
=
sf_open_virtual
(
&
vio
,
SFM_READ
,
&
info
,
&
is
);
SndfileInputStream
sis
{
&
decoder
,
is
};
sf
=
sf_open_virtual
(
&
vio
,
SFM_READ
,
&
info
,
&
sis
);
if
(
sf
==
nullptr
)
{
LogWarning
(
sndfile_domain
,
"sf_open_virtual() failed"
);
return
;
...
...
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