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
dcf55c7e
Commit
dcf55c7e
authored
Jan 28, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
InputStream: add constructor/destructor
Eliminate input_stream_init() and input_stream_deinit().
parent
e565cd44
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
40 additions
and
91 deletions
+40
-91
InputInternal.cxx
src/InputInternal.cxx
+0
-31
InputInternal.hxx
src/InputInternal.hxx
+0
-10
InputStream.hxx
src/InputStream.hxx
+17
-0
Bzip2ArchivePlugin.cxx
src/archive/Bzip2ArchivePlugin.cxx
+2
-3
Iso9660ArchivePlugin.cxx
src/archive/Iso9660ArchivePlugin.cxx
+2
-4
ZzipArchivePlugin.cxx
src/archive/ZzipArchivePlugin.cxx
+2
-5
CdioParanoiaInputPlugin.cxx
src/input/CdioParanoiaInputPlugin.cxx
+2
-5
CurlInputPlugin.cxx
src/input/CurlInputPlugin.cxx
+2
-4
DespotifyInputPlugin.cxx
src/input/DespotifyInputPlugin.cxx
+2
-4
FfmpegInputPlugin.cxx
src/input/FfmpegInputPlugin.cxx
+2
-5
FileInputPlugin.cxx
src/input/FileInputPlugin.cxx
+2
-5
MmsInputPlugin.cxx
src/input/MmsInputPlugin.cxx
+2
-4
RewindInputPlugin.cxx
src/input/RewindInputPlugin.cxx
+3
-5
SoupInputPlugin.cxx
src/input/SoupInputPlugin.cxx
+2
-6
No files found.
src/InputInternal.cxx
View file @
dcf55c7e
...
@@ -21,37 +21,6 @@
...
@@ -21,37 +21,6 @@
#include "InputInternal.hxx"
#include "InputInternal.hxx"
#include "InputStream.hxx"
#include "InputStream.hxx"
#include <assert.h>
void
input_stream_init
(
struct
input_stream
*
is
,
const
struct
input_plugin
*
plugin
,
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
)
{
assert
(
is
!=
NULL
);
assert
(
plugin
!=
NULL
);
assert
(
uri
!=
NULL
);
is
->
plugin
=
plugin
;
is
->
uri
=
g_strdup
(
uri
);
is
->
mutex
=
&
mutex
;
is
->
cond
=
&
cond
;
is
->
ready
=
false
;
is
->
seekable
=
false
;
is
->
size
=
-
1
;
is
->
offset
=
0
;
is
->
mime
=
NULL
;
}
void
input_stream_deinit
(
struct
input_stream
*
is
)
{
assert
(
is
!=
NULL
);
assert
(
is
->
plugin
!=
NULL
);
g_free
(
is
->
uri
);
g_free
(
is
->
mime
);
}
void
void
input_stream_signal_client
(
struct
input_stream
*
is
)
input_stream_signal_client
(
struct
input_stream
*
is
)
{
{
...
...
src/InputInternal.hxx
View file @
dcf55c7e
...
@@ -21,18 +21,8 @@
...
@@ -21,18 +21,8 @@
#define MPD_INPUT_INTERNAL_HXX
#define MPD_INPUT_INTERNAL_HXX
#include "check.h"
#include "check.h"
#include "thread/Mutex.hxx"
#include "thread/Cond.hxx"
struct
input_stream
;
struct
input_stream
;
struct
input_plugin
;
void
input_stream_init
(
struct
input_stream
*
is
,
const
struct
input_plugin
*
plugin
,
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
);
void
input_stream_deinit
(
struct
input_stream
*
is
);
void
void
input_stream_signal_client
(
struct
input_stream
*
is
);
input_stream_signal_client
(
struct
input_stream
*
is
);
...
...
src/InputStream.hxx
View file @
dcf55c7e
...
@@ -28,6 +28,8 @@
...
@@ -28,6 +28,8 @@
#include <glib.h>
#include <glib.h>
#include <assert.h>
struct
input_stream
{
struct
input_stream
{
/**
/**
* the plugin which implements this input stream
* the plugin which implements this input stream
...
@@ -85,6 +87,21 @@ struct input_stream {
...
@@ -85,6 +87,21 @@ struct input_stream {
* the MIME content type of the resource, or NULL if unknown
* the MIME content type of the resource, or NULL if unknown
*/
*/
char
*
mime
;
char
*
mime
;
input_stream
(
const
input_plugin
&
_plugin
,
const
char
*
_uri
,
Mutex
&
_mutex
,
Cond
&
_cond
)
:
plugin
(
&
_plugin
),
uri
(
g_strdup
(
_uri
)),
mutex
(
&
_mutex
),
cond
(
&
_cond
),
ready
(
false
),
seekable
(
false
),
size
(
-
1
),
offset
(
0
),
mime
(
nullptr
)
{
assert
(
_uri
!=
NULL
);
}
~
input_stream
()
{
g_free
(
uri
);
g_free
(
mime
);
}
};
};
gcc_nonnull
(
1
)
gcc_nonnull
(
1
)
...
...
src/archive/Bzip2ArchivePlugin.cxx
View file @
dcf55c7e
...
@@ -184,16 +184,15 @@ bz2_close(struct archive_file *file)
...
@@ -184,16 +184,15 @@ bz2_close(struct archive_file *file)
Bzip2InputStream
::
Bzip2InputStream
(
Bzip2ArchiveFile
&
_context
,
const
char
*
uri
,
Bzip2InputStream
::
Bzip2InputStream
(
Bzip2ArchiveFile
&
_context
,
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
)
Mutex
&
mutex
,
Cond
&
cond
)
:
archive
(
&
_context
),
eof
(
false
)
:
base
(
bz2_inputplugin
,
uri
,
mutex
,
cond
),
archive
(
&
_context
),
eof
(
false
)
{
{
input_stream_init
(
&
base
,
&
bz2_inputplugin
,
uri
,
mutex
,
cond
);
refcount_inc
(
&
archive
->
ref
);
refcount_inc
(
&
archive
->
ref
);
}
}
Bzip2InputStream
::~
Bzip2InputStream
()
Bzip2InputStream
::~
Bzip2InputStream
()
{
{
bz2_close
(
&
archive
->
base
);
bz2_close
(
&
archive
->
base
);
input_stream_deinit
(
&
base
);
}
}
static
struct
input_stream
*
static
struct
input_stream
*
...
...
src/archive/Iso9660ArchivePlugin.cxx
View file @
dcf55c7e
...
@@ -178,10 +178,9 @@ struct Iso9660InputStream {
...
@@ -178,10 +178,9 @@ struct Iso9660InputStream {
Iso9660InputStream
(
Iso9660ArchiveFile
&
_archive
,
const
char
*
uri
,
Iso9660InputStream
(
Iso9660ArchiveFile
&
_archive
,
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
,
Mutex
&
mutex
,
Cond
&
cond
,
iso9660_stat_t
*
_statbuf
)
iso9660_stat_t
*
_statbuf
)
:
archive
(
&
_archive
),
statbuf
(
_statbuf
),
:
base
(
iso9660_input_plugin
,
uri
,
mutex
,
cond
),
archive
(
&
_archive
),
statbuf
(
_statbuf
),
max_blocks
(
CEILING
(
statbuf
->
size
,
ISO_BLOCKSIZE
))
{
max_blocks
(
CEILING
(
statbuf
->
size
,
ISO_BLOCKSIZE
))
{
input_stream_init
(
&
base
,
&
iso9660_input_plugin
,
uri
,
mutex
,
cond
);
base
.
ready
=
true
;
base
.
ready
=
true
;
base
.
size
=
statbuf
->
size
;
base
.
size
=
statbuf
->
size
;
...
@@ -192,7 +191,6 @@ struct Iso9660InputStream {
...
@@ -192,7 +191,6 @@ struct Iso9660InputStream {
~
Iso9660InputStream
()
{
~
Iso9660InputStream
()
{
free
(
statbuf
);
free
(
statbuf
);
archive
->
Unref
();
archive
->
Unref
();
input_stream_deinit
(
&
base
);
}
}
};
};
...
...
src/archive/ZzipArchivePlugin.cxx
View file @
dcf55c7e
...
@@ -142,10 +142,8 @@ struct ZzipInputStream {
...
@@ -142,10 +142,8 @@ struct ZzipInputStream {
ZzipInputStream
(
ZzipArchiveFile
&
_archive
,
const
char
*
uri
,
ZzipInputStream
(
ZzipArchiveFile
&
_archive
,
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
,
Mutex
&
mutex
,
Cond
&
cond
,
ZZIP_FILE
*
_file
)
ZZIP_FILE
*
_file
)
:
archive
(
&
_archive
),
file
(
_file
)
{
:
base
(
zzip_input_plugin
,
uri
,
mutex
,
cond
),
input_stream_init
(
&
base
,
&
zzip_input_plugin
,
uri
,
archive
(
&
_archive
),
file
(
_file
)
{
mutex
,
cond
);
base
.
ready
=
true
;
base
.
ready
=
true
;
//we are seekable (but its not recommendent to do so)
//we are seekable (but its not recommendent to do so)
base
.
seekable
=
true
;
base
.
seekable
=
true
;
...
@@ -160,7 +158,6 @@ struct ZzipInputStream {
...
@@ -160,7 +158,6 @@ struct ZzipInputStream {
~
ZzipInputStream
()
{
~
ZzipInputStream
()
{
zzip_file_close
(
file
);
zzip_file_close
(
file
);
archive
->
Unref
();
archive
->
Unref
();
input_stream_deinit
(
&
base
);
}
}
};
};
...
...
src/input/CdioParanoiaInputPlugin.cxx
View file @
dcf55c7e
...
@@ -56,11 +56,10 @@ struct CdioParanoiaInputStream {
...
@@ -56,11 +56,10 @@ struct CdioParanoiaInputStream {
CdioParanoiaInputStream
(
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
,
CdioParanoiaInputStream
(
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
,
int
_trackno
)
int
_trackno
)
:
drv
(
nullptr
),
cdio
(
nullptr
),
para
(
nullptr
),
:
base
(
input_plugin_cdio_paranoia
,
uri
,
mutex
,
cond
),
drv
(
nullptr
),
cdio
(
nullptr
),
para
(
nullptr
),
trackno
(
_trackno
)
trackno
(
_trackno
)
{
{
input_stream_init
(
&
base
,
&
input_plugin_cdio_paranoia
,
uri
,
mutex
,
cond
);
}
}
~
CdioParanoiaInputStream
()
{
~
CdioParanoiaInputStream
()
{
...
@@ -70,8 +69,6 @@ struct CdioParanoiaInputStream {
...
@@ -70,8 +69,6 @@ struct CdioParanoiaInputStream {
cdio_cddap_close_no_free_cdio
(
drv
);
cdio_cddap_close_no_free_cdio
(
drv
);
if
(
cdio
!=
nullptr
)
if
(
cdio
!=
nullptr
)
cdio_destroy
(
cdio
);
cdio_destroy
(
cdio
);
input_stream_deinit
(
&
base
);
}
}
};
};
...
...
src/input/CurlInputPlugin.cxx
View file @
dcf55c7e
...
@@ -166,12 +166,12 @@ struct input_curl {
...
@@ -166,12 +166,12 @@ struct input_curl {
GError
*
postponed_error
;
GError
*
postponed_error
;
input_curl
(
const
char
*
url
,
Mutex
&
mutex
,
Cond
&
cond
)
input_curl
(
const
char
*
url
,
Mutex
&
mutex
,
Cond
&
cond
)
:
range
(
nullptr
),
request_headers
(
nullptr
),
:
base
(
input_plugin_curl
,
url
,
mutex
,
cond
),
range
(
nullptr
),
request_headers
(
nullptr
),
paused
(
false
),
paused
(
false
),
meta_name
(
nullptr
),
meta_name
(
nullptr
),
tag
(
nullptr
),
tag
(
nullptr
),
postponed_error
(
nullptr
)
{
postponed_error
(
nullptr
)
{
input_stream_init
(
&
base
,
&
input_plugin_curl
,
url
,
mutex
,
cond
);
}
}
~
input_curl
();
~
input_curl
();
...
@@ -705,8 +705,6 @@ input_curl::~input_curl()
...
@@ -705,8 +705,6 @@ input_curl::~input_curl()
if
(
postponed_error
!=
NULL
)
if
(
postponed_error
!=
NULL
)
g_error_free
(
postponed_error
);
g_error_free
(
postponed_error
);
input_stream_deinit
(
&
base
);
}
}
static
bool
static
bool
...
...
src/input/DespotifyInputPlugin.cxx
View file @
dcf55c7e
...
@@ -51,11 +51,10 @@ struct DespotifyInputStream {
...
@@ -51,11 +51,10 @@ struct DespotifyInputStream {
Mutex
&
mutex
,
Cond
&
cond
,
Mutex
&
mutex
,
Cond
&
cond
,
despotify_session
*
_session
,
despotify_session
*
_session
,
ds_track
*
_track
)
ds_track
*
_track
)
:
session
(
_session
),
track
(
_track
),
:
base
(
input_plugin_despotify
,
uri
,
mutex
,
cond
),
session
(
_session
),
track
(
_track
),
tag
(
mpd_despotify_tag_from_track
(
track
)),
tag
(
mpd_despotify_tag_from_track
(
track
)),
len_available
(
0
),
eof
(
false
)
{
len_available
(
0
),
eof
(
false
)
{
input_stream_init
(
&
base
,
&
input_plugin_despotify
,
uri
,
mutex
,
cond
);
memset
(
&
pcm
,
0
,
sizeof
(
pcm
));
memset
(
&
pcm
,
0
,
sizeof
(
pcm
));
...
@@ -69,7 +68,6 @@ struct DespotifyInputStream {
...
@@ -69,7 +68,6 @@ struct DespotifyInputStream {
tag_free
(
tag
);
tag_free
(
tag
);
despotify_free_track
(
track
);
despotify_free_track
(
track
);
input_stream_deinit
(
&
base
);
}
}
};
};
...
...
src/input/FfmpegInputPlugin.cxx
View file @
dcf55c7e
...
@@ -44,10 +44,8 @@ struct FfmpegInputStream {
...
@@ -44,10 +44,8 @@ struct FfmpegInputStream {
FfmpegInputStream
(
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
,
FfmpegInputStream
(
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
,
AVIOContext
*
_h
)
AVIOContext
*
_h
)
:
h
(
_h
),
eof
(
false
)
{
:
base
(
input_plugin_ffmpeg
,
uri
,
mutex
,
cond
),
input_stream_init
(
&
base
,
&
input_plugin_ffmpeg
,
h
(
_h
),
eof
(
false
)
{
uri
,
mutex
,
cond
);
base
.
ready
=
true
;
base
.
ready
=
true
;
base
.
seekable
=
(
h
->
seekable
&
AVIO_SEEKABLE_NORMAL
)
!=
0
;
base
.
seekable
=
(
h
->
seekable
&
AVIO_SEEKABLE_NORMAL
)
!=
0
;
base
.
size
=
avio_size
(
h
);
base
.
size
=
avio_size
(
h
);
...
@@ -61,7 +59,6 @@ struct FfmpegInputStream {
...
@@ -61,7 +59,6 @@ struct FfmpegInputStream {
~
FfmpegInputStream
()
{
~
FfmpegInputStream
()
{
avio_close
(
h
);
avio_close
(
h
);
input_stream_deinit
(
&
base
);
}
}
};
};
...
...
src/input/FileInputPlugin.cxx
View file @
dcf55c7e
...
@@ -42,10 +42,8 @@ struct FileInputStream {
...
@@ -42,10 +42,8 @@ struct FileInputStream {
FileInputStream
(
const
char
*
path
,
int
_fd
,
off_t
size
,
FileInputStream
(
const
char
*
path
,
int
_fd
,
off_t
size
,
Mutex
&
mutex
,
Cond
&
cond
)
Mutex
&
mutex
,
Cond
&
cond
)
:
fd
(
_fd
)
{
:
base
(
input_plugin_file
,
path
,
mutex
,
cond
),
input_stream_init
(
&
base
,
&
input_plugin_file
,
path
,
fd
(
_fd
)
{
mutex
,
cond
);
base
.
size
=
size
;
base
.
size
=
size
;
base
.
seekable
=
true
;
base
.
seekable
=
true
;
base
.
ready
=
true
;
base
.
ready
=
true
;
...
@@ -53,7 +51,6 @@ struct FileInputStream {
...
@@ -53,7 +51,6 @@ struct FileInputStream {
~
FileInputStream
()
{
~
FileInputStream
()
{
close
(
fd
);
close
(
fd
);
input_stream_deinit
(
&
base
);
}
}
};
};
...
...
src/input/MmsInputPlugin.cxx
View file @
dcf55c7e
...
@@ -42,9 +42,8 @@ struct MmsInputStream {
...
@@ -42,9 +42,8 @@ struct MmsInputStream {
MmsInputStream
(
const
char
*
uri
,
MmsInputStream
(
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
,
Mutex
&
mutex
,
Cond
&
cond
,
mmsx_t
*
_mms
)
mmsx_t
*
_mms
)
:
mms
(
_mms
),
eof
(
false
)
{
:
base
(
input_plugin_mms
,
uri
,
mutex
,
cond
),
input_stream_init
(
&
base
,
&
input_plugin_mms
,
uri
,
mutex
,
cond
);
mms
(
_mms
),
eof
(
false
)
{
/* XX is this correct? at least this selects the ffmpeg
/* XX is this correct? at least this selects the ffmpeg
decoder, which seems to work fine*/
decoder, which seems to work fine*/
base
.
mime
=
g_strdup
(
"audio/x-ms-wma"
);
base
.
mime
=
g_strdup
(
"audio/x-ms-wma"
);
...
@@ -54,7 +53,6 @@ struct MmsInputStream {
...
@@ -54,7 +53,6 @@ struct MmsInputStream {
~
MmsInputStream
()
{
~
MmsInputStream
()
{
mmsx_close
(
mms
);
mmsx_close
(
mms
);
input_stream_deinit
(
&
base
);
}
}
};
};
...
...
src/input/RewindInputPlugin.cxx
View file @
dcf55c7e
...
@@ -61,15 +61,13 @@ struct RewindInputStream {
...
@@ -61,15 +61,13 @@ struct RewindInputStream {
char
buffer
[
64
*
1024
];
char
buffer
[
64
*
1024
];
RewindInputStream
(
input_stream
*
_input
)
RewindInputStream
(
input_stream
*
_input
)
:
input
(
_input
),
tail
(
0
)
{
:
base
(
rewind_input_plugin
,
_input
->
uri
,
input_stream_init
(
&
base
,
&
rewind_input_plugin
,
input
->
uri
,
*
_input
->
mutex
,
*
_input
->
cond
)
,
*
input
->
mutex
,
*
input
->
cond
);
input
(
_input
),
tail
(
0
)
{
}
}
~
RewindInputStream
()
{
~
RewindInputStream
()
{
input_stream_close
(
input
);
input_stream_close
(
input
);
input_stream_deinit
(
&
base
);
}
}
/**
/**
...
...
src/input/SoupInputPlugin.cxx
View file @
dcf55c7e
...
@@ -278,14 +278,12 @@ input_soup_queue(gpointer data)
...
@@ -278,14 +278,12 @@ input_soup_queue(gpointer data)
SoupInputStream
::
SoupInputStream
(
const
char
*
uri
,
SoupInputStream
::
SoupInputStream
(
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
)
Mutex
&
mutex
,
Cond
&
cond
)
:
buffers
(
g_queue_new
()),
:
base
(
input_plugin_soup
,
uri
,
mutex
,
cond
),
buffers
(
g_queue_new
()),
current_consumed
(
0
),
total_buffered
(
0
),
current_consumed
(
0
),
total_buffered
(
0
),
alive
(
false
),
pause
(
false
),
eof
(
false
),
completed
(
false
),
alive
(
false
),
pause
(
false
),
eof
(
false
),
completed
(
false
),
postponed_error
(
nullptr
)
postponed_error
(
nullptr
)
{
{
input_stream_init
(
&
base
,
&
input_plugin_soup
,
uri
,
mutex
,
cond
);
#if GCC_CHECK_VERSION(4,6)
#if GCC_CHECK_VERSION(4,6)
#pragma GCC diagnostic push
#pragma GCC diagnostic push
/* the libsoup macro SOUP_METHOD_GET discards the "const"
/* the libsoup macro SOUP_METHOD_GET discards the "const"
...
@@ -365,8 +363,6 @@ SoupInputStream::~SoupInputStream()
...
@@ -365,8 +363,6 @@ SoupInputStream::~SoupInputStream()
if
(
postponed_error
!=
NULL
)
if
(
postponed_error
!=
NULL
)
g_error_free
(
postponed_error
);
g_error_free
(
postponed_error
);
input_stream_deinit
(
&
base
);
}
}
static
void
static
void
...
...
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