Audacious
$Id:Doxyfile42802007-03-2104:39:00Znenolod$
Main Page
Related Pages
Classes
Files
File List
File Members
src
libaudcore
vfs_async.c
Go to the documentation of this file.
1
/*
2
* vfs_async.c
3
* Copyright 2010 William Pitcock
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions are met:
7
*
8
* 1. Redistributions of source code must retain the above copyright notice,
9
* this list of conditions, and the following disclaimer.
10
*
11
* 2. Redistributions in binary form must reproduce the above copyright notice,
12
* this list of conditions, and the following disclaimer in the documentation
13
* provided with the distribution.
14
*
15
* This software is provided "as is" and without any warranty, express or
16
* implied. In no event shall the authors be liable for any damages arising from
17
* the use of this software.
18
*/
19
20
#include <glib.h>
21
22
#include "config.h"
23
#include "
vfs_async.h
"
24
25
typedef
struct
{
26
char
*
filename
;
27
void
*
buf
;
28
int64_t
size
;
29
GThread *
thread
;
30
void
*
userdata
;
31
32
VFSConsumer
cons_f
;
33
}
VFSAsyncTrampoline
;
34
35
bool_t
36
vfs_async_file_get_contents_trampoline
(
void
* data)
37
{
38
VFSAsyncTrampoline
*tr = data;
39
40
tr->
cons_f
(tr->
buf
, tr->
size
, tr->
userdata
);
41
g_slice_free(
VFSAsyncTrampoline
, tr);
42
43
return
FALSE
;
44
}
45
46
void
*
47
vfs_async_file_get_contents_worker
(
void
* data)
48
{
49
VFSAsyncTrampoline
*tr = data;
50
51
vfs_file_get_contents
(tr->
filename
, &tr->
buf
, &tr->
size
);
52
53
g_idle_add_full(G_PRIORITY_HIGH_IDLE,
vfs_async_file_get_contents_trampoline
, tr,
NULL
);
54
g_thread_exit(
NULL
);
55
return
NULL
;
56
}
57
58
EXPORT
void
59
vfs_async_file_get_contents
(
const
char
*
filename
,
VFSConsumer
cons_f,
void
* userdata)
60
{
61
VFSAsyncTrampoline
*tr;
62
63
tr = g_slice_new0(
VFSAsyncTrampoline
);
64
tr->
filename
= g_strdup(filename);
65
tr->
cons_f
= cons_f;
66
tr->
userdata
= userdata;
67
tr->
thread
= g_thread_create(
vfs_async_file_get_contents_worker
, tr,
FALSE
,
NULL
);
68
}
Generated by
1.8.1.2