Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
GNOME
rygel
Commits
4b915419
Commit
4b915419
authored
Oct 07, 2013
by
Jean-Baptiste Dubois
Committed by
Jens Georg
Oct 15, 2013
Browse files
engine: Add large files (> 4GB) streaming support.
https://bugzilla.gnome.org/show_bug.cgi?id=709551
parent
9da3ca39
Changes
3
Hide whitespace changes
Inline
Side-by-side
configure.ac
View file @
4b915419
...
...
@@ -27,6 +27,8 @@ dnl Disable generation of static libraries
LT_PREREQ([2.2.6])
LT_INIT([dlopen disable-static])
AC_SYS_LARGEFILE
dnl Required versions of library packages
dnl Not all of these are actually used, depending on the configure options.
GLIB_REQUIRED=2.31.13
...
...
src/media-engines/simple/Makefile.am
View file @
4b915419
...
...
@@ -8,6 +8,7 @@ librygel_media_engine_simple_la_SOURCES = \
rygel-simple-data-source.vala
librygel_media_engine_simple_la_VALAFLAGS
=
\
--pkg
posix
\
$(RYGEL_COMMON_LIBRYGEL_SERVER_VALAFLAGS)
\
$(RYGEL_COMMON_VALAFLAGS)
...
...
src/media-engines/simple/rygel-simple-data-source.vala
View file @
4b915419
...
...
@@ -34,8 +34,8 @@ internal class Rygel.SimpleDataSource : DataSource, Object {
private
Thread
<
void
*>
thread
;
private
Mutex
mutex
=
Mutex
();
private
Cond
cond
=
Cond
();
private
uint64
first_byte
=
0
;
private
uint64
last_byte
=
0
;
private
Posix
.
off_t
first_byte
=
0
;
private
Posix
.
off_t
last_byte
=
0
;
private
bool
frozen
=
false
;
private
bool
stop_thread
=
false
;
private
HTTPSeek
offsets
=
null
;
...
...
@@ -103,13 +103,26 @@ internal class Rygel.SimpleDataSource : DataSource, Object {
private
void
*
thread_func
()
{
var
file
=
File
.
new_for_commandline_arg
(
this
.
uri
);
debug
(
"Spawning new thread for streaming file %s"
,
this
.
uri
);
int
fd
=
-
1
;
try
{
var
mapped
=
new
MappedFile
(
file
.
get_path
(),
false
);
fd
=
Posix
.
open
(
file
.
get_path
(),
Posix
.
O_RDONLY
,
0
);
if
(
fd
<
0
)
{
throw
new
IOError
.
FAILED
(
"Failed to open file '%s': %s"
,
file
.
get_path
(),
Posix
.
strerror
(
Posix
.
errno
));
}
if
(
this
.
offsets
!=
null
)
{
this
.
first_byte
=
this
.
offsets
.
start
;
this
.
last_byte
=
this
.
offsets
.
stop
+
1
;
this
.
first_byte
=
(
Posix
.
off_t
)
this
.
offsets
.
start
;
this
.
last_byte
=
(
Posix
.
off_t
)
this
.
offsets
.
stop
+
1
;
}
else
{
this
.
last_byte
=
mapped
.
get_length
();
this
.
first_byte
=
0
;
this
.
last_byte
=
Posix
.
lseek
(
fd
,
0
,
Posix
.
SEEK_END
);
Posix
.
lseek
(
fd
,
0
,
Posix
.
SEEK_SET
);
}
if
(
this
.
first_byte
!=
0
)
{
Posix
.
lseek
(
fd
,
this
.
first_byte
,
Posix
.
SEEK_SET
);
}
while
(
true
)
{
...
...
@@ -134,9 +147,15 @@ internal class Rygel.SimpleDataSource : DataSource, Object {
stop
=
this
.
last_byte
;
}
unowned
uint8
[]
data
=
(
uint8
[])
mapped
.
get_contents
();
data
.
length
=
(
int
)
mapped
.
get_length
();
uint8
[]
slice
=
data
[
start
:
stop
];
var
slice
=
new
uint8
[
stop
-
start
];
var
len
=
(
int
)
Posix
.
read
(
fd
,
slice
,
slice
.
length
);
if
(
len
<
0
)
{
throw
new
IOError
.
FAILED
(
"Failed to read file '%s': %s"
,
file
.
get_path
(),
Posix
.
strerror
(
Posix
.
errno
));
}
slice
.
length
=
len
;
this
.
first_byte
=
stop
;
// There's a potential race condition here.
...
...
@@ -149,7 +168,11 @@ internal class Rygel.SimpleDataSource : DataSource, Object {
});
}
}
catch
(
Error
error
)
{
warning
(
"Failed to map file: %s"
,
error
.
message
);
warning
(
"Failed to stream file %s: %s"
,
file
.
get_path
(),
error
.
message
);
}
finally
{
Posix
.
close
(
fd
);
}
// Signal that we're done streaming
...
...
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