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
bb472206
Commit
bb472206
authored
Aug 19, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
InputStream: move typedef offset_type to Offset.hxx
Reduce header dependencies.
parent
d87cf514
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
77 additions
and
52 deletions
+77
-52
Makefile.am
Makefile.am
+1
-0
AudiofileDecoderPlugin.cxx
src/decoder/plugins/AudiofileDecoderPlugin.cxx
+1
-1
DsdiffDecoderPlugin.cxx
src/decoder/plugins/DsdiffDecoderPlugin.cxx
+9
-9
DsfDecoderPlugin.cxx
src/decoder/plugins/DsfDecoderPlugin.cxx
+2
-2
FlacIOHandle.cxx
src/decoder/plugins/FlacIOHandle.cxx
+1
-1
MadDecoderPlugin.cxx
src/decoder/plugins/MadDecoderPlugin.cxx
+5
-5
ModplugDecoderPlugin.cxx
src/decoder/plugins/ModplugDecoderPlugin.cxx
+1
-1
OggFind.cxx
src/decoder/plugins/OggFind.cxx
+2
-1
OggFind.hxx
src/decoder/plugins/OggFind.hxx
+3
-2
OpusDecoderPlugin.cxx
src/decoder/plugins/OpusDecoderPlugin.cxx
+2
-2
PcmDecoderPlugin.cxx
src/decoder/plugins/PcmDecoderPlugin.cxx
+2
-2
SndfileDecoderPlugin.cxx
src/decoder/plugins/SndfileDecoderPlugin.cxx
+1
-1
VorbisDecoderPlugin.cxx
src/decoder/plugins/VorbisDecoderPlugin.cxx
+1
-1
WavpackDecoderPlugin.cxx
src/decoder/plugins/WavpackDecoderPlugin.cxx
+1
-1
InputStream.hxx
src/input/InputStream.hxx
+2
-1
Offset.hxx
src/input/Offset.hxx
+32
-0
test_rewind.cxx
test/test_rewind.cxx
+11
-22
No files found.
Makefile.am
View file @
bb472206
...
...
@@ -1090,6 +1090,7 @@ libinput_a_SOURCES = \
src/input/Init.cxx src/input/Init.hxx
\
src/input/Registry.cxx src/input/Registry.hxx
\
src/input/Open.cxx
\
src/input/Offset.hxx
\
src/input/InputStream.cxx src/input/InputStream.hxx
\
src/input/InputPlugin.hxx
\
src/input/TextInputStream.cxx src/input/TextInputStream.hxx
\
...
...
src/decoder/plugins/AudiofileDecoderPlugin.cxx
View file @
bb472206
...
...
@@ -114,7 +114,7 @@ audiofile_file_seek(AFvirtualfile *vfile, AFfileoffset _offset,
AudioFileInputStream
&
afis
=
*
(
AudioFileInputStream
*
)
vfile
->
closure
;
InputStream
&
is
=
afis
.
is
;
InputStream
::
offset_type
offset
=
_offset
;
offset_type
offset
=
_offset
;
if
(
is_relative
)
offset
+=
is
.
GetOffset
();
...
...
src/decoder/plugins/DsdiffDecoderPlugin.cxx
View file @
bb472206
...
...
@@ -110,14 +110,14 @@ dsdiff_read_payload(Decoder *decoder, InputStream &is,
static
bool
dsdiff_read_prop_snd
(
Decoder
*
decoder
,
InputStream
&
is
,
DsdiffMetaData
*
metadata
,
InputStream
::
offset_type
end_offset
)
offset_type
end_offset
)
{
DsdiffChunkHeader
header
;
while
(
(
InputStream
::
offset_type
)
(
is
.
GetOffset
()
+
sizeof
(
header
))
<=
end_offset
)
{
while
(
offset_type
(
is
.
GetOffset
()
+
sizeof
(
header
))
<=
end_offset
)
{
if
(
!
dsdiff_read_chunk_header
(
decoder
,
is
,
&
header
))
return
false
;
InputStream
::
offset_type
chunk_end_offset
=
is
.
GetOffset
()
offset_type
chunk_end_offset
=
is
.
GetOffset
()
+
header
.
GetSize
();
if
(
chunk_end_offset
>
end_offset
)
return
false
;
...
...
@@ -171,7 +171,7 @@ dsdiff_read_prop(Decoder *decoder, InputStream &is,
const
DsdiffChunkHeader
*
prop_header
)
{
uint64_t
prop_size
=
prop_header
->
GetSize
();
InputStream
::
offset_type
end_offset
=
is
.
GetOffset
()
+
prop_size
;
const
offset_type
end_offset
=
is
.
GetOffset
()
+
prop_size
;
DsdId
prop_id
;
if
(
prop_size
<
sizeof
(
prop_id
)
||
...
...
@@ -188,7 +188,7 @@ dsdiff_read_prop(Decoder *decoder, InputStream &is,
static
void
dsdiff_handle_native_tag
(
InputStream
&
is
,
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
,
InputStream
::
offset_type
tagoffset
,
void
*
handler_ctx
,
offset_type
tagoffset
,
TagType
type
)
{
if
(
!
dsdlib_skip_to
(
nullptr
,
is
,
tagoffset
))
...
...
@@ -240,12 +240,12 @@ dsdiff_read_metadata_extra(Decoder *decoder, InputStream &is,
return
false
;
/** offset for artist tag */
InputStream
::
offset_type
artist_offset
=
0
;
offset_type
artist_offset
=
0
;
/** offset for title tag */
InputStream
::
offset_type
title_offset
=
0
;
offset_type
title_offset
=
0
;
#ifdef HAVE_ID3TAG
InputStream
::
offset_type
id3_offset
=
0
;
offset_type
id3_offset
=
0
;
#endif
/* Now process all the remaining chunk headers in the stream
...
...
@@ -334,7 +334,7 @@ dsdiff_read_metadata(Decoder *decoder, InputStream &is,
}
else
{
/* ignore unknown chunk */
const
uint64_t
chunk_size
=
chunk_header
->
GetSize
();
InputStream
::
offset_type
chunk_end_offset
=
const
offset_type
chunk_end_offset
=
is
.
GetOffset
()
+
chunk_size
;
if
(
!
dsdlib_skip_to
(
decoder
,
is
,
chunk_end_offset
))
...
...
src/decoder/plugins/DsfDecoderPlugin.cxx
View file @
bb472206
...
...
@@ -44,7 +44,7 @@ struct DsfMetaData {
bool
bitreverse
;
uint64_t
chunk_size
;
#ifdef HAVE_ID3TAG
InputStream
::
offset_type
id3_offset
;
offset_type
id3_offset
;
uint64_t
id3_size
;
#endif
};
...
...
@@ -173,7 +173,7 @@ dsf_read_metadata(Decoder *decoder, InputStream &is,
metadata
->
channels
=
(
unsigned
)
dsf_fmt_chunk
.
channelnum
;
metadata
->
sample_rate
=
samplefreq
;
#ifdef HAVE_ID3TAG
metadata
->
id3_offset
=
(
InputStream
::
offset_type
)
metadata_offset
;
metadata
->
id3_offset
=
(
offset_type
)
metadata_offset
;
#endif
/* check bits per sample format, determine if bitreverse is needed */
metadata
->
bitreverse
=
dsf_fmt_chunk
.
bitssample
==
1
;
...
...
src/decoder/plugins/FlacIOHandle.cxx
View file @
bb472206
...
...
@@ -67,7 +67,7 @@ FlacIOSeek(FLAC__IOHandle handle, FLAC__int64 _offset, int whence)
{
InputStream
*
is
=
(
InputStream
*
)
handle
;
InputStream
::
offset_type
offset
=
_offset
;
offset_type
offset
=
_offset
;
switch
(
whence
)
{
case
SEEK_SET
:
break
;
...
...
src/decoder/plugins/MadDecoderPlugin.cxx
View file @
bb472206
...
...
@@ -153,10 +153,10 @@ struct MadDecoder {
enum
mp3_action
DecodeNextFrame
();
gcc_pure
InputStream
::
offset_type
ThisFrameOffset
()
const
;
offset_type
ThisFrameOffset
()
const
;
gcc_pure
InputStream
::
offset_type
RestIncludingThisFrame
()
const
;
offset_type
RestIncludingThisFrame
()
const
;
/**
* Attempt to calulcate the length of the song from filesize
...
...
@@ -747,7 +747,7 @@ mp3_frame_duration(const struct mad_frame *frame)
MAD_UNITS_MILLISECONDS
)
/
1000.0
;
}
inline
InputStream
::
offset_type
inline
offset_type
MadDecoder
::
ThisFrameOffset
()
const
{
auto
offset
=
input_stream
.
GetOffset
();
...
...
@@ -760,7 +760,7 @@ MadDecoder::ThisFrameOffset() const
return
offset
;
}
inline
InputStream
::
offset_type
inline
offset_type
MadDecoder
::
RestIncludingThisFrame
()
const
{
return
input_stream
.
GetSize
()
-
ThisFrameOffset
();
...
...
@@ -770,7 +770,7 @@ inline void
MadDecoder
::
FileSizeToSongLength
()
{
if
(
input_stream
.
KnownSize
())
{
InputStream
::
offset_type
rest
=
RestIncludingThisFrame
();
offset_type
rest
=
RestIncludingThisFrame
();
float
frame_duration
=
mp3_frame_duration
(
&
frame
);
...
...
src/decoder/plugins/ModplugDecoderPlugin.cxx
View file @
bb472206
...
...
@@ -36,7 +36,7 @@ static constexpr Domain modplug_domain("modplug");
static
constexpr
size_t
MODPLUG_FRAME_SIZE
=
4096
;
static
constexpr
size_t
MODPLUG_PREALLOC_BLOCK
=
256
*
1024
;
static
constexpr
InputStream
::
offset_type
MODPLUG_FILE_LIMIT
=
100
*
1024
*
1024
;
static
constexpr
offset_type
MODPLUG_FILE_LIMIT
=
100
*
1024
*
1024
;
static
int
modplug_loop_count
;
...
...
src/decoder/plugins/OggFind.cxx
View file @
bb472206
...
...
@@ -20,6 +20,7 @@
#include "config.h"
#include "OggFind.hxx"
#include "OggSyncState.hxx"
#include "input/InputStream.hxx"
#include "util/Error.hxx"
bool
...
...
@@ -39,7 +40,7 @@ OggFindEOS(OggSyncState &oy, ogg_stream_state &os, ogg_packet &packet)
bool
OggSeekPageAtOffset
(
OggSyncState
&
oy
,
ogg_stream_state
&
os
,
InputStream
&
is
,
InputStream
::
offset_type
offset
)
offset_type
offset
)
{
oy
.
Reset
();
...
...
src/decoder/plugins/OggFind.hxx
View file @
bb472206
...
...
@@ -21,11 +21,12 @@
#define MPD_OGG_FIND_HXX
#include "check.h"
#include "input/
InputStream
.hxx"
#include "input/
Offset
.hxx"
#include <ogg/ogg.h>
class
OggSyncState
;
class
InputStream
;
/**
* Skip all pages/packets until an end-of-stream (EOS) packet for the
...
...
@@ -41,7 +42,7 @@ OggFindEOS(OggSyncState &oy, ogg_stream_state &os, ogg_packet &packet);
*/
bool
OggSeekPageAtOffset
(
OggSyncState
&
oy
,
ogg_stream_state
&
os
,
InputStream
&
is
,
InputStream
::
offset_type
offset
);
offset_type
offset
);
/**
* Try to find the end-of-stream (EOS) packet. Seek to the end of the
...
...
src/decoder/plugins/OpusDecoderPlugin.cxx
View file @
bb472206
...
...
@@ -339,8 +339,8 @@ MPDOpusDecoder::Seek(OggSyncState &oy, double where_s)
/* interpolate the file offset where we expect to find the
given granule position */
/* TODO: implement binary search */
InputStream
::
offset_type
offset
(
where_granulepos
*
input_stream
.
GetSize
()
/
eos_granulepos
);
offset_type
offset
(
where_granulepos
*
input_stream
.
GetSize
()
/
eos_granulepos
);
if
(
!
OggSeekPageAtOffset
(
oy
,
os
,
input_stream
,
offset
))
return
false
;
...
...
src/decoder/plugins/PcmDecoderPlugin.cxx
View file @
bb472206
...
...
@@ -70,8 +70,8 @@ pcm_stream_decode(Decoder &decoder, InputStream &is)
buffer
,
nbytes
,
0
)
:
decoder_get_command
(
decoder
);
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
InputStream
::
offset_type
offset
(
time_to_size
*
decoder_seek_where
(
decoder
));
offset_type
offset
(
time_to_size
*
decoder_seek_where
(
decoder
));
Error
error
;
if
(
is
.
LockSeek
(
offset
,
error
))
{
...
...
src/decoder/plugins/SndfileDecoderPlugin.cxx
View file @
bb472206
...
...
@@ -70,7 +70,7 @@ sndfile_vio_seek(sf_count_t _offset, int whence, void *user_data)
SndfileInputStream
&
sis
=
*
(
SndfileInputStream
*
)
user_data
;
InputStream
&
is
=
sis
.
is
;
InputStream
::
offset_type
offset
=
_offset
;
offset_type
offset
=
_offset
;
switch
(
whence
)
{
case
SEEK_SET
:
break
;
...
...
src/decoder/plugins/VorbisDecoderPlugin.cxx
View file @
bb472206
...
...
@@ -80,7 +80,7 @@ static int ogg_seek_cb(void *data, ogg_int64_t _offset, int whence)
decoder_get_command
(
*
vis
->
decoder
)
==
DecoderCommand
::
STOP
))
return
-
1
;
InputStream
::
offset_type
offset
=
_offset
;
offset_type
offset
=
_offset
;
switch
(
whence
)
{
case
SEEK_SET
:
break
;
...
...
src/decoder/plugins/WavpackDecoderPlugin.cxx
View file @
bb472206
...
...
@@ -405,7 +405,7 @@ wavpack_input_set_pos_rel(void *id, int32_t delta, int mode)
WavpackInput
&
wpi
=
*
wpin
(
id
);
InputStream
&
is
=
wpi
.
is
;
InputStream
::
offset_type
offset
=
delta
;
offset_type
offset
=
delta
;
switch
(
mode
)
{
case
SEEK_SET
:
break
;
...
...
src/input/InputStream.hxx
View file @
bb472206
...
...
@@ -21,6 +21,7 @@
#define MPD_INPUT_STREAM_HXX
#include "check.h"
#include "Offset.hxx"
#include "thread/Mutex.hxx"
#include "Compiler.h"
...
...
@@ -35,7 +36,7 @@ struct Tag;
class
InputStream
{
public
:
typedef
uint64_t
offset_type
;
typedef
::
offset_type
offset_type
;
private
:
/**
...
...
src/input/Offset.hxx
0 → 100644
View file @
bb472206
/*
* Copyright (C) 2003-2014 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_OFFSET_HXX
#define MPD_OFFSET_HXX
#include "check.h"
#include <stdint.h>
/**
* A type for absolute offsets in a file.
*/
typedef
uint64_t
offset_type
;
#endif
test/test_rewind.cxx
View file @
bb472206
...
...
@@ -72,8 +72,7 @@ public:
ris
->
Update
();
CPPUNIT_ASSERT
(
ris
->
IsReady
());
CPPUNIT_ASSERT
(
!
ris
->
KnownSize
());
CPPUNIT_ASSERT_EQUAL
(
InputStream
::
offset_type
(
0
),
ris
->
GetOffset
());
CPPUNIT_ASSERT_EQUAL
(
offset_type
(
0
),
ris
->
GetOffset
());
Error
error
;
char
buffer
[
16
];
...
...
@@ -81,50 +80,43 @@ public:
CPPUNIT_ASSERT_EQUAL
(
size_t
(
2
),
nbytes
);
CPPUNIT_ASSERT_EQUAL
(
'f'
,
buffer
[
0
]);
CPPUNIT_ASSERT_EQUAL
(
'o'
,
buffer
[
1
]);
CPPUNIT_ASSERT_EQUAL
(
InputStream
::
offset_type
(
2
),
ris
->
GetOffset
());
CPPUNIT_ASSERT_EQUAL
(
offset_type
(
2
),
ris
->
GetOffset
());
CPPUNIT_ASSERT
(
!
ris
->
IsEOF
());
nbytes
=
ris
->
Read
(
buffer
,
2
,
error
);
CPPUNIT_ASSERT_EQUAL
(
size_t
(
2
),
nbytes
);
CPPUNIT_ASSERT_EQUAL
(
'o'
,
buffer
[
0
]);
CPPUNIT_ASSERT_EQUAL
(
' '
,
buffer
[
1
]);
CPPUNIT_ASSERT_EQUAL
(
InputStream
::
offset_type
(
4
),
ris
->
GetOffset
());
CPPUNIT_ASSERT_EQUAL
(
offset_type
(
4
),
ris
->
GetOffset
());
CPPUNIT_ASSERT
(
!
ris
->
IsEOF
());
CPPUNIT_ASSERT
(
ris
->
Seek
(
1
,
error
));
CPPUNIT_ASSERT_EQUAL
(
InputStream
::
offset_type
(
1
),
ris
->
GetOffset
());
CPPUNIT_ASSERT_EQUAL
(
offset_type
(
1
),
ris
->
GetOffset
());
CPPUNIT_ASSERT
(
!
ris
->
IsEOF
());
nbytes
=
ris
->
Read
(
buffer
,
2
,
error
);
CPPUNIT_ASSERT_EQUAL
(
size_t
(
2
),
nbytes
);
CPPUNIT_ASSERT_EQUAL
(
'o'
,
buffer
[
0
]);
CPPUNIT_ASSERT_EQUAL
(
'o'
,
buffer
[
1
]);
CPPUNIT_ASSERT_EQUAL
(
InputStream
::
offset_type
(
3
),
ris
->
GetOffset
());
CPPUNIT_ASSERT_EQUAL
(
offset_type
(
3
),
ris
->
GetOffset
());
CPPUNIT_ASSERT
(
!
ris
->
IsEOF
());
CPPUNIT_ASSERT
(
ris
->
Seek
(
0
,
error
));
CPPUNIT_ASSERT_EQUAL
(
InputStream
::
offset_type
(
0
),
ris
->
GetOffset
());
CPPUNIT_ASSERT_EQUAL
(
offset_type
(
0
),
ris
->
GetOffset
());
CPPUNIT_ASSERT
(
!
ris
->
IsEOF
());
nbytes
=
ris
->
Read
(
buffer
,
2
,
error
);
CPPUNIT_ASSERT_EQUAL
(
size_t
(
2
),
nbytes
);
CPPUNIT_ASSERT_EQUAL
(
'f'
,
buffer
[
0
]);
CPPUNIT_ASSERT_EQUAL
(
'o'
,
buffer
[
1
]);
CPPUNIT_ASSERT_EQUAL
(
InputStream
::
offset_type
(
2
),
ris
->
GetOffset
());
CPPUNIT_ASSERT_EQUAL
(
offset_type
(
2
),
ris
->
GetOffset
());
CPPUNIT_ASSERT
(
!
ris
->
IsEOF
());
nbytes
=
ris
->
Read
(
buffer
,
sizeof
(
buffer
),
error
);
CPPUNIT_ASSERT_EQUAL
(
size_t
(
2
),
nbytes
);
CPPUNIT_ASSERT_EQUAL
(
'o'
,
buffer
[
0
]);
CPPUNIT_ASSERT_EQUAL
(
' '
,
buffer
[
1
]);
CPPUNIT_ASSERT_EQUAL
(
InputStream
::
offset_type
(
4
),
ris
->
GetOffset
());
CPPUNIT_ASSERT_EQUAL
(
offset_type
(
4
),
ris
->
GetOffset
());
CPPUNIT_ASSERT
(
!
ris
->
IsEOF
());
nbytes
=
ris
->
Read
(
buffer
,
sizeof
(
buffer
),
error
);
...
...
@@ -132,13 +124,11 @@ public:
CPPUNIT_ASSERT_EQUAL
(
'b'
,
buffer
[
0
]);
CPPUNIT_ASSERT_EQUAL
(
'a'
,
buffer
[
1
]);
CPPUNIT_ASSERT_EQUAL
(
'r'
,
buffer
[
2
]);
CPPUNIT_ASSERT_EQUAL
(
InputStream
::
offset_type
(
7
),
ris
->
GetOffset
());
CPPUNIT_ASSERT_EQUAL
(
offset_type
(
7
),
ris
->
GetOffset
());
CPPUNIT_ASSERT
(
ris
->
IsEOF
());
CPPUNIT_ASSERT
(
ris
->
Seek
(
3
,
error
));
CPPUNIT_ASSERT_EQUAL
(
InputStream
::
offset_type
(
3
),
ris
->
GetOffset
());
CPPUNIT_ASSERT_EQUAL
(
offset_type
(
3
),
ris
->
GetOffset
());
CPPUNIT_ASSERT
(
!
ris
->
IsEOF
());
nbytes
=
ris
->
Read
(
buffer
,
sizeof
(
buffer
),
error
);
...
...
@@ -147,8 +137,7 @@ public:
CPPUNIT_ASSERT_EQUAL
(
'b'
,
buffer
[
1
]);
CPPUNIT_ASSERT_EQUAL
(
'a'
,
buffer
[
2
]);
CPPUNIT_ASSERT_EQUAL
(
'r'
,
buffer
[
3
]);
CPPUNIT_ASSERT_EQUAL
(
InputStream
::
offset_type
(
7
),
ris
->
GetOffset
());
CPPUNIT_ASSERT_EQUAL
(
offset_type
(
7
),
ris
->
GetOffset
());
CPPUNIT_ASSERT
(
ris
->
IsEOF
());
}
};
...
...
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