Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Steve Lhomme
VLC
Commits
a0783549
Commit
a0783549
authored
Jan 04, 2006
by
zorglub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for several message queues - please test
Initial support for registering and handling some shared stats
parent
d68a17b3
Changes
16
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
507 additions
and
171 deletions
+507
-171
Makefile.am
Makefile.am
+1
-0
include/vlc_common.h
include/vlc_common.h
+5
-0
include/vlc_messages.h
include/vlc_messages.h
+78
-20
include/vlc_objects.h
include/vlc_objects.h
+1
-0
include/vlc_symbols.h
include/vlc_symbols.h
+14
-6
modules/gui/beos/MessagesWindow.cpp
modules/gui/beos/MessagesWindow.cpp
+1
-1
modules/gui/macosx/intf.m
modules/gui/macosx/intf.m
+1
-1
modules/gui/ncurses.c
modules/gui/ncurses.c
+1
-1
modules/gui/skins2/src/skin_main.cpp
modules/gui/skins2/src/skin_main.cpp
+1
-1
modules/gui/wince/wince.cpp
modules/gui/wince/wince.cpp
+1
-1
modules/gui/wxwidgets/wxwidgets.cpp
modules/gui/wxwidgets/wxwidgets.cpp
+1
-1
modules/misc/logger.c
modules/misc/logger.c
+1
-1
src/misc/messages.c
src/misc/messages.c
+159
-135
src/misc/objects.c
src/misc/objects.c
+4
-0
src/misc/stats.c
src/misc/stats.c
+231
-0
src/network/httpd.c
src/network/httpd.c
+7
-3
No files found.
Makefile.am
View file @
a0783549
...
...
@@ -455,6 +455,7 @@ SOURCES_libvlc_common = \
src/misc/block.c
\
src/misc/modules.c
\
src/misc/threads.c
\
src/misc/stats.c
\
src/misc/unicode.c
\
src/misc/cpu.c
\
src/misc/configuration.c
\
...
...
include/vlc_common.h
View file @
a0783549
...
...
@@ -205,6 +205,7 @@ typedef struct date_t date_t;
/* Messages */
typedef
struct
msg_bank_t
msg_bank_t
;
typedef
struct
msg_queue_t
msg_queue_t
;
typedef
struct
msg_subscription_t
msg_subscription_t
;
/* Playlist */
...
...
@@ -415,6 +416,10 @@ typedef struct vlm_schedule_t vlm_schedule_t;
/* divers */
typedef
struct
vlc_meta_t
vlc_meta_t
;
typedef
struct
counter_t
counter_t
;
typedef
struct
counter_sample_t
counter_sample_t
;
typedef
struct
stats_handler_t
stats_handler_t
;
/*****************************************************************************
* Variable callbacks
...
...
include/vlc_messages.h
View file @
a0783549
...
...
@@ -45,12 +45,7 @@ typedef struct
char
*
psz_module
;
char
*
psz_msg
;
/**< the message itself */
#if 0
mtime_t date; /* date of the message */
char * psz_file; /* file in which the function was called */
char * psz_function; /* function from which the function was called */
int i_line; /* line at which the function was called */
#endif
mtime_t
date
;
/**< Message date */
}
msg_item_t
;
/* Message types */
...
...
@@ -63,14 +58,25 @@ typedef struct
/** debug messages */
#define VLC_MSG_DBG 3
#define MSG_QUEUE_NORMAL 0
#define MSG_QUEUE_HTTPD_ACCESS 1
/**
* Store all data requiered by messages interfaces.
*/
struct
msg_bank_t
{
vlc_mutex_t
lock
;
int
i_queues
;
msg_queue_t
**
pp_queues
;
};
struct
msg_queue_t
{
int
i_id
;
/** Message queue lock */
vlc_mutex_t
lock
;
vlc_bool_t
b_configured
;
vlc_bool_t
b_overflow
;
/* Message queue */
...
...
@@ -103,9 +109,9 @@ struct msg_subscription_t
/*****************************************************************************
* Prototypes
*****************************************************************************/
VLC_EXPORT
(
void
,
__msg_Generic
,
(
vlc_object_t
*
,
int
,
const
char
*
,
const
char
*
,
...
)
ATTRIBUTE_FORMAT
(
4
,
5
)
);
VLC_EXPORT
(
void
,
__msg_GenericVa
,
(
vlc_object_t
*
,
int
,
const
char
*
,
const
char
*
,
va_list
args
)
);
#define msg_GenericVa(a, b, c, d, e) __msg_GenericVa(VLC_OBJECT(a), b, c, d, e)
VLC_EXPORT
(
void
,
__msg_Generic
,
(
vlc_object_t
*
,
int
,
int
,
const
char
*
,
const
char
*
,
...
)
ATTRIBUTE_FORMAT
(
5
,
6
)
);
VLC_EXPORT
(
void
,
__msg_GenericVa
,
(
vlc_object_t
*
,
int
,
int
,
const
char
*
,
const
char
*
,
va_list
args
)
);
#define msg_GenericVa(a, b, c, d, e)
,f
__msg_GenericVa(VLC_OBJECT(a), b, c, d, e
,f
)
VLC_EXPORT
(
void
,
__msg_Info
,
(
vlc_object_t
*
,
const
char
*
,
...
)
ATTRIBUTE_FORMAT
(
2
,
3
)
);
VLC_EXPORT
(
void
,
__msg_Err
,
(
vlc_object_t
*
,
const
char
*
,
...
)
ATTRIBUTE_FORMAT
(
2
,
3
)
);
VLC_EXPORT
(
void
,
__msg_Warn
,
(
vlc_object_t
*
,
const
char
*
,
...
)
ATTRIBUTE_FORMAT
(
2
,
3
)
);
...
...
@@ -114,19 +120,19 @@ VLC_EXPORT( void, __msg_Dbg, ( vlc_object_t *, const char *, ... ) ATTRIBUTE_
#ifdef HAVE_VARIADIC_MACROS
# define msg_Info( p_this, psz_format, args... ) \
__msg_Generic( VLC_OBJECT(p_this), VLC_MSG_INFO, MODULE_STRING, \
__msg_Generic( VLC_OBJECT(p_this),
MSG_QUEUE_NORMAL,
VLC_MSG_INFO, MODULE_STRING, \
psz_format, ## args )
# define msg_Err( p_this, psz_format, args... ) \
__msg_Generic( VLC_OBJECT(p_this), VLC_MSG_ERR, MODULE_STRING, \
__msg_Generic( VLC_OBJECT(p_this),
MSG_QUEUE_NORMAL,
VLC_MSG_ERR, MODULE_STRING, \
psz_format, ## args )
# define msg_Warn( p_this, psz_format, args... ) \
__msg_Generic( VLC_OBJECT(p_this), VLC_MSG_WARN, MODULE_STRING, \
__msg_Generic( VLC_OBJECT(p_this),
MSG_QUEUE_NORMAL,
VLC_MSG_WARN, MODULE_STRING, \
psz_format, ## args )
# define msg_Dbg( p_this, psz_format, args... ) \
__msg_Generic( VLC_OBJECT(p_this), VLC_MSG_DBG, MODULE_STRING, \
__msg_Generic( VLC_OBJECT(p_this),
MSG_QUEUE_NORMAL,
VLC_MSG_DBG, MODULE_STRING, \
psz_format, ## args )
#elif defined(_MSC_VER)
/* To avoid warnings and even errors with c++ files */
...
...
@@ -135,7 +141,7 @@ inline void msg_Info( void *p_this, const char *psz_format, ... )
{
va_list
ap
;
va_start
(
ap
,
psz_format
);
__msg_GenericVa
(
(
vlc_object_t
*
)
p_this
,
VLC_MSG_INFO
,
MODULE_STRING
,
__msg_GenericVa
(
(
vlc_object_t
*
)
p_this
,
MSG_QUEUE_NORMAL
,
VLC_MSG_INFO
,
MODULE_STRING
,
psz_format
,
ap
);
va_end
(
ap
);
}
...
...
@@ -143,7 +149,7 @@ inline void msg_Err( void *p_this, const char *psz_format, ... )
{
va_list
ap
;
va_start
(
ap
,
psz_format
);
__msg_GenericVa
(
(
vlc_object_t
*
)
p_this
,
VLC_MSG_ERR
,
MODULE_STRING
,
__msg_GenericVa
(
(
vlc_object_t
*
)
p_this
,
MSG_QUEUE_NORMAL
,
VLC_MSG_ERR
,
MODULE_STRING
,
psz_format
,
ap
);
va_end
(
ap
);
}
...
...
@@ -151,7 +157,7 @@ inline void msg_Warn( void *p_this, const char *psz_format, ... )
{
va_list
ap
;
va_start
(
ap
,
psz_format
);
__msg_GenericVa
(
(
vlc_object_t
*
)
p_this
,
VLC_MSG_WARN
,
MODULE_STRING
,
__msg_GenericVa
(
(
vlc_object_t
*
)
p_this
,
MSG_QUEUE_NORMAL
,
VLC_MSG_WARN
,
MODULE_STRING
,
psz_format
,
ap
);
va_end
(
ap
);
}
...
...
@@ -159,7 +165,7 @@ inline void msg_Dbg( void *p_this, const char *psz_format, ... )
{
va_list
ap
;
va_start
(
ap
,
psz_format
);
__msg_GenericVa
(
(
vlc_object_t
*
)
p_this
,
VLC_MSG_DBG
,
MODULE_STRING
,
__msg_GenericVa
(
(
vlc_object_t
*
)
p_this
,
MSG_QUEUE_NORMAL
,
VLC_MSG_DBG
,
MODULE_STRING
,
psz_format
,
ap
);
va_end
(
ap
);
}
...
...
@@ -180,12 +186,64 @@ void __msg_Create ( vlc_object_t * );
void
__msg_Flush
(
vlc_object_t
*
);
void
__msg_Destroy
(
vlc_object_t
*
);
#define msg_Subscribe(a) __msg_Subscribe(VLC_OBJECT(a))
#define msg_Subscribe(a
,b
) __msg_Subscribe(VLC_OBJECT(a)
,b
)
#define msg_Unsubscribe(a,b) __msg_Unsubscribe(VLC_OBJECT(a),b)
VLC_EXPORT
(
msg_subscription_t
*
,
__msg_Subscribe
,
(
vlc_object_t
*
)
);
VLC_EXPORT
(
msg_subscription_t
*
,
__msg_Subscribe
,
(
vlc_object_t
*
,
int
)
);
VLC_EXPORT
(
void
,
__msg_Unsubscribe
,
(
vlc_object_t
*
,
msg_subscription_t
*
)
);
/**
* @}
*/
/**
* \defgroup statistics Statistics
*
* @{
*/
enum
{
STATS_LAST
,
STATS_COUNTER
,
STATS_MAX
,
STATS_MIN
,
};
struct
counter_sample_t
{
vlc_value_t
value
;
mtime_t
date
;
};
struct
counter_t
{
char
*
psz_name
;
int
i_source_object
;
int
i_compute_type
;
int
i_type
;
int
i_samples
;
counter_sample_t
**
pp_samples
;
};
struct
stats_handler_t
{
VLC_COMMON_MEMBERS
int
i_counters
;
counter_t
**
pp_counters
;
};
#define stats_Update( a,b,c) __stats_Update( VLC_OBJECT( a ), b, c )
VLC_EXPORT
(
int
,
__stats_Update
,
(
vlc_object_t
*
,
char
*
,
vlc_value_t
)
);
#define stats_Create( a,b,c,d ) __stats_Create( VLC_OBJECT(a), b, c, d )
VLC_EXPORT
(
int
,
__stats_Create
,
(
vlc_object_t
*
,
char
*
,
int
,
int
)
);
static
inline
int
__stats_UpdateInteger
(
vlc_object_t
*
p_obj
,
char
*
psz_name
,
int
i
)
{
vlc_value_t
val
;
val
.
i_int
=
i
;
return
__stats_Update
(
p_obj
,
psz_name
,
val
);
}
#define stats_UpdateInteger( a,b,c ) __stats_UpdateInteger( VLC_OBJECT(a),b,c )
include/vlc_objects.h
View file @
a0783549
...
...
@@ -60,6 +60,7 @@
#define VLC_OBJECT_SD (-26)
#define VLC_OBJECT_XML (-27)
#define VLC_OBJECT_OSDMENU (-28)
#define VLC_OBJECT_STATS (-29)
#define VLC_OBJECT_GENERIC (-666)
...
...
include/vlc_symbols.h
View file @
a0783549
...
...
@@ -62,6 +62,7 @@ int playlist_ItemSetName (playlist_item_t *, char *);
void
__osd_MenuShow
(
vlc_object_t
*
);
httpd_url_t
*
httpd_UrlNewUnique
(
httpd_host_t
*
,
const
char
*
psz_url
,
const
char
*
psz_user
,
const
char
*
psz_password
,
const
vlc_acl_t
*
p_acl
);
void
httpd_ClientModeStream
(
httpd_client_t
*
cl
);
int
__stats_Create
(
vlc_object_t
*
,
char
*
,
int
,
int
);
void
httpd_RedirectDelete
(
httpd_redirect_t
*
);
void
__sout_CfgParse
(
vlc_object_t
*
,
char
*
psz_prefix
,
const
char
**
ppsz_options
,
sout_cfg_t
*
);
vlm_media_t
*
vlm_MediaNew
(
vlm_t
*
,
const
char
*
,
int
);
...
...
@@ -118,6 +119,7 @@ void vlm_MessageDelete (vlm_message_t *);
void
vout_SynchroDecode
(
vout_synchro_t
*
);
int
playlist_Delete
(
playlist_t
*
,
int
);
void
aout_FiltersPlay
(
aout_instance_t
*
p_aout
,
aout_filter_t
**
pp_filters
,
int
i_nb_filters
,
aout_buffer_t
**
pp_input_buffer
);
int
__stats_Update
(
vlc_object_t
*
,
char
*
,
vlc_value_t
);
char
*
httpd_ClientIP
(
httpd_client_t
*
cl
,
char
*
psz_ip
);
int
__intf_UserProgress
(
vlc_object_t
*
,
const
char
*
,
const
char
*
,
float
);
void
httpd_FileDelete
(
httpd_file_t
*
);
...
...
@@ -204,7 +206,7 @@ struct dirent * vlc_readdir_wrapper (void *);
void
config_UnsetCallbacks
(
module_config_t
*
);
void
vout_SynchroRelease
(
vout_synchro_t
*
);
void
__intf_UserProgressUpdate
(
vlc_object_t
*
,
int
,
const
char
*
,
float
);
void
__msg_Generic
(
vlc_object_t
*
,
int
,
const
char
*
,
const
char
*
,
...
)
ATTRIBUTE_FORMAT
(
4
,
5
);
void
__msg_Generic
(
vlc_object_t
*
,
int
,
int
,
const
char
*
,
const
char
*
,
...
)
ATTRIBUTE_FORMAT
(
5
,
6
);
int
vlc_closedir_wrapper
(
void
*
);
int
playlist_ServicesDiscoveryAdd
(
playlist_t
*
,
const
char
*
);
char
*
vlc_strndup
(
const
char
*
s
,
size_t
n
);
...
...
@@ -339,7 +341,7 @@ int intf_RunThread (intf_thread_t *);
int
httpd_StreamSend
(
httpd_stream_t
*
,
uint8_t
*
p_data
,
int
i_data
);
decoder_t
*
input_DecoderNew
(
input_thread_t
*
,
es_format_t
*
,
vlc_bool_t
b_force_decoder
);
xml_t
*
__xml_Create
(
vlc_object_t
*
);
msg_subscription_t
*
__msg_Subscribe
(
vlc_object_t
*
);
msg_subscription_t
*
__msg_Subscribe
(
vlc_object_t
*
,
int
);
const
char
*
VLC_Version
(
void
);
session_descriptor_t
*
sout_AnnounceRegisterSDP
(
sout_instance_t
*
,
const
char
*
,
const
char
*
,
announce_method_t
*
);
char
*
stream_ReadLine
(
stream_t
*
);
...
...
@@ -380,7 +382,7 @@ char * ToLocale (const char *);
int
vlm_Load
(
vlm_t
*
,
const
char
*
);
int
aout_FiltersCreatePipeline
(
aout_instance_t
*
p_aout
,
aout_filter_t
**
pp_filters
,
int
*
pi_nb_filters
,
const
audio_sample_format_t
*
p_input_format
,
const
audio_sample_format_t
*
p_output_format
);
playlist_item_t
*
playlist_ChildSearchName
(
playlist_item_t
*
,
const
char
*
);
void
__msg_GenericVa
(
vlc_object_t
*
,
int
,
const
char
*
,
const
char
*
,
va_list
args
);
void
__msg_GenericVa
(
vlc_object_t
*
,
int
,
int
,
const
char
*
,
const
char
*
,
va_list
args
);
int
aout_ChannelsRestart
(
vlc_object_t
*
,
const
char
*
,
vlc_value_t
,
vlc_value_t
,
void
*
);
char
const
*
vlc_error
(
int
);
int
playlist_NodeGroup
(
playlist_t
*
,
int
,
playlist_item_t
*
,
playlist_item_t
**
,
int
,
int
,
int
);
...
...
@@ -669,13 +671,13 @@ struct module_symbols_t
int
(
*
intf_RunThread_inner
)
(
intf_thread_t
*
);
void
(
*
intf_StopThread_inner
)
(
intf_thread_t
*
);
void
(
*
intf_Destroy_inner
)
(
intf_thread_t
*
);
void
(
*
__msg_Generic_inner
)
(
vlc_object_t
*
,
int
,
const
char
*
,
const
char
*
,
...
)
ATTRIBUTE_FORMAT
(
4
,
5
);
void
(
*
__msg_GenericVa_inner
)
(
vlc_object_t
*
,
int
,
const
char
*
,
const
char
*
,
va_list
args
);
void
(
*
__msg_Generic_inner
)
(
vlc_object_t
*
,
int
,
int
,
const
char
*
,
const
char
*
,
...
)
ATTRIBUTE_FORMAT
(
5
,
6
);
void
(
*
__msg_GenericVa_inner
)
(
vlc_object_t
*
,
int
,
int
,
const
char
*
,
const
char
*
,
va_list
args
);
void
(
*
__msg_Info_inner
)
(
vlc_object_t
*
,
const
char
*
,
...
)
ATTRIBUTE_FORMAT
(
2
,
3
);
void
(
*
__msg_Err_inner
)
(
vlc_object_t
*
,
const
char
*
,
...
)
ATTRIBUTE_FORMAT
(
2
,
3
);
void
(
*
__msg_Warn_inner
)
(
vlc_object_t
*
,
const
char
*
,
...
)
ATTRIBUTE_FORMAT
(
2
,
3
);
void
(
*
__msg_Dbg_inner
)
(
vlc_object_t
*
,
const
char
*
,
...
)
ATTRIBUTE_FORMAT
(
2
,
3
);
msg_subscription_t
*
(
*
__msg_Subscribe_inner
)
(
vlc_object_t
*
);
msg_subscription_t
*
(
*
__msg_Subscribe_inner
)
(
vlc_object_t
*
,
int
);
void
(
*
__msg_Unsubscribe_inner
)
(
vlc_object_t
*
,
msg_subscription_t
*
);
void
*
(
*
__vlc_object_create_inner
)
(
vlc_object_t
*
,
int
);
void
(
*
__vlc_object_destroy_inner
)
(
vlc_object_t
*
);
...
...
@@ -869,6 +871,8 @@ struct module_symbols_t
int
(
*
__intf_UserProgress_inner
)
(
vlc_object_t
*
,
const
char
*
,
const
char
*
,
float
);
void
(
*
__intf_UserProgressUpdate_inner
)
(
vlc_object_t
*
,
int
,
const
char
*
,
float
);
void
(
*
__intf_UserHide_inner
)
(
vlc_object_t
*
,
int
);
int
(
*
__stats_Create_inner
)
(
vlc_object_t
*
,
char
*
,
int
,
int
);
int
(
*
__stats_Update_inner
)
(
vlc_object_t
*
,
char
*
,
vlc_value_t
);
};
# if defined (__PLUGIN__)
# define aout_FiltersCreatePipeline (p_symbols)->aout_FiltersCreatePipeline_inner
...
...
@@ -1289,6 +1293,8 @@ struct module_symbols_t
# define __intf_UserProgress (p_symbols)->__intf_UserProgress_inner
# define __intf_UserProgressUpdate (p_symbols)->__intf_UserProgressUpdate_inner
# define __intf_UserHide (p_symbols)->__intf_UserHide_inner
# define __stats_Create (p_symbols)->__stats_Create_inner
# define __stats_Update (p_symbols)->__stats_Update_inner
# elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__)
/******************************************************************
* STORE_SYMBOLS: store VLC APIs into p_symbols for plugin access.
...
...
@@ -1712,6 +1718,8 @@ struct module_symbols_t
((p_symbols)->__intf_UserProgress_inner) = __intf_UserProgress; \
((p_symbols)->__intf_UserProgressUpdate_inner) = __intf_UserProgressUpdate; \
((p_symbols)->__intf_UserHide_inner) = __intf_UserHide; \
((p_symbols)->__stats_Create_inner) = __stats_Create; \
((p_symbols)->__stats_Update_inner) = __stats_Update; \
(p_symbols)->net_ConvertIPv4_deprecated = NULL; \
# endif
/* __PLUGIN__ */
...
...
modules/gui/beos/MessagesWindow.cpp
View file @
a0783549
...
...
@@ -135,7 +135,7 @@ MessagesWindow::MessagesWindow( intf_thread_t * _p_intf,
{
SetSizeLimits
(
400
,
2000
,
200
,
2000
);
p_sub
=
msg_Subscribe
(
p_intf
);
p_sub
=
msg_Subscribe
(
p_intf
,
MSG_QUEUE_NORMAL
);
BRect
rect
,
textRect
;
...
...
modules/gui/macosx/intf.m
View file @
a0783549
...
...
@@ -75,7 +75,7 @@ int E_(OpenIntf) ( vlc_object_t *p_this )
[
NSThread
detachNewThreadSelector
:
@selector
(
self
)
toTarget
:[
NSString
string
]
withObject
:
nil
];
p_intf
->
p_sys
->
o_sendport
=
[[
NSPort
port
]
retain
];
p_intf
->
p_sys
->
p_sub
=
msg_Subscribe
(
p_intf
);
p_intf
->
p_sys
->
p_sub
=
msg_Subscribe
(
p_intf
,
MSG_QUEUE_NORMAL
);
p_intf
->
b_play
=
VLC_TRUE
;
p_intf
->
pf_run
=
Run
;
...
...
modules/gui/ncurses.c
View file @
a0783549
...
...
@@ -200,7 +200,7 @@ static int Open( vlc_object_t *p_this )
p_sys
->
i_box_plidx
=
0
;
p_sys
->
p_plnode
=
NULL
;
p_sys
->
i_box_bidx
=
0
;
p_sys
->
p_sub
=
msg_Subscribe
(
p_intf
);
p_sys
->
p_sub
=
msg_Subscribe
(
p_intf
,
MSG_QUEUE_NORMAL
);
/* Initialize the curses library */
p_sys
->
w
=
initscr
();
...
...
modules/gui/skins2/src/skin_main.cpp
View file @
a0783549
...
...
@@ -77,7 +77,7 @@ static int Open( vlc_object_t *p_this )
p_intf
->
pf_run
=
Run
;
// Suscribe to messages bank
p_intf
->
p_sys
->
p_sub
=
msg_Subscribe
(
p_intf
);
p_intf
->
p_sys
->
p_sub
=
msg_Subscribe
(
p_intf
,
MSG_QUEUE_NORMAL
);
p_intf
->
p_sys
->
p_input
=
NULL
;
p_intf
->
p_sys
->
p_playlist
=
(
playlist_t
*
)
vlc_object_find
(
p_intf
,
...
...
modules/gui/wince/wince.cpp
View file @
a0783549
...
...
@@ -112,7 +112,7 @@ static int Open( vlc_object_t *p_this )
}
// Suscribe to messages bank
p_intf
->
p_sys
->
p_sub
=
msg_Subscribe
(
p_intf
);
p_intf
->
p_sys
->
p_sub
=
msg_Subscribe
(
p_intf
,
MSG_QUEUE_NORMAL
);
// Misc init
p_intf
->
p_sys
->
p_audio_menu
=
NULL
;
...
...
modules/gui/wxwidgets/wxwidgets.cpp
View file @
a0783549
...
...
@@ -173,7 +173,7 @@ static int Open( vlc_object_t *p_this )
p_intf
->
pf_run
=
Run
;
p_intf
->
p_sys
->
p_sub
=
msg_Subscribe
(
p_intf
);
p_intf
->
p_sys
->
p_sub
=
msg_Subscribe
(
p_intf
,
MSG_QUEUE_NORMAL
);
/* Initialize wxWidgets thread */
p_intf
->
p_sys
->
b_playing
=
0
;
...
...
modules/misc/logger.c
View file @
a0783549
...
...
@@ -262,7 +262,7 @@ static int Open( vlc_object_t *p_this )
#endif
}
p_intf
->
p_sys
->
p_sub
=
msg_Subscribe
(
p_intf
);
p_intf
->
p_sys
->
p_sub
=
msg_Subscribe
(
p_intf
,
MSG_QUEUE_NORMAL
);
p_intf
->
pf_run
=
Run
;
return
0
;
...
...
src/misc/messages.c
View file @
a0783549
...
...
@@ -60,115 +60,136 @@
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static
void
QueueMsg
(
vlc_object_t
*
,
int
,
const
char
*
,
static
void
QueueMsg
(
vlc_object_t
*
,
int
,
int
,
const
char
*
,
const
char
*
,
va_list
);
static
void
FlushMsg
(
msg_
bank
_t
*
);
static
void
FlushMsg
(
msg_
queue
_t
*
);
static
void
PrintMsg
(
vlc_object_t
*
,
msg_item_t
*
);
static
void
CreateMsgQueue
(
vlc_object_t
*
p_this
,
int
i_queue
);
/**
* Initialize messages interface
*
* This functions has to be called before any call to other msg_* functions.
* It set up the locks and the message queue if it is used.
* Initialize messages queues
* This function initializes all message queues
*/
void
__msg_Create
(
vlc_object_t
*
p_this
)
{
/* Message queue initialization */
vlc_mutex_init
(
p_this
,
&
p_this
->
p_libvlc
->
msg_bank
.
lock
);
p_this
->
p_libvlc
->
msg_bank
.
b_configured
=
VLC_FALSE
;
p_this
->
p_libvlc
->
msg_bank
.
b_overflow
=
VLC_FALSE
;
p_this
->
p_libvlc
->
msg_bank
.
i_start
=
0
;
p_this
->
p_libvlc
->
msg_bank
.
i_stop
=
0
;
p_this
->
p_libvlc
->
msg_bank
.
i_sub
=
0
;
p_this
->
p_libvlc
->
msg_bank
.
pp_sub
=
NULL
;
CreateMsgQueue
(
p_this
,
MSG_QUEUE_NORMAL
);
CreateMsgQueue
(
p_this
,
MSG_QUEUE_HTTPD_ACCESS
);
#ifdef UNDER_CE
p_this
->
p_libvlc
->
msg_bank
.
logfile
=
p_this
->
p_libvlc
->
msg_bank
.
pp_queues
[
MSG_QUEUE_NORMAL
]
->
logfile
=
CreateFile
(
L"vlc-log.txt"
,
GENERIC_WRITE
,
FILE_SHARE_READ
|
FILE_SHARE_WRITE
,
NULL
,
CREATE_ALWAYS
,
0
,
NULL
);
SetFilePointer
(
p_this
->
p_libvlc
->
msg_bank
.
logfile
,
0
,
NULL
,
FILE_END
);
SetFilePointer
(
p_this
->
p_libvlc
->
msg_bank
.
pp_queues
[
MSG_QUEUE_NORMAL
]
->
logfile
,
0
,
NULL
,
FILE_END
);
#endif
}
static
void
CreateMsgQueue
(
vlc_object_t
*
p_this
,
int
i_queue
)
{
msg_queue_t
*
p_queue
=
(
msg_queue_t
*
)
malloc
(
sizeof
(
msg_queue_t
)
);
vlc_mutex_init
(
p_this
,
&
p_queue
->
lock
);
p_queue
->
b_overflow
=
VLC_FALSE
;
p_queue
->
i_id
=
i_queue
;
p_queue
->
i_start
=
0
;
p_queue
->
i_stop
=
0
;
p_queue
->
i_sub
=
0
;
p_queue
->
pp_sub
=
NULL
;
INSERT_ELEM
(
p_this
->
p_libvlc
->
msg_bank
.
pp_queues
,
p_this
->
p_libvlc
->
msg_bank
.
i_queues
,
i_queue
,
p_queue
);
}
/**
* Flush
the
message queue
* Flush
all
message queue
s
*/
void
__msg_Flush
(
vlc_object_t
*
p_this
)
{
vlc_mutex_lock
(
&
p_this
->
p_libvlc
->
msg_bank
.
lock
)
;
int
i
;
p_this
->
p_libvlc
->
msg_bank
.
b_configured
=
VLC_TRUE
;
#if 0
/* Some messages remain in the queue, dont rewrite them */
for( i_index = p_this->p_libvlc->msg_bank.i_start;
i_index != p_this->p_libvlc->msg_bank.i_stop;
i_index = (i_index+1) % VLC_MSG_QSIZE )
for
(
i
=
0
;
i
<
p_this
->
p_libvlc
->
msg_bank
.
i_queues
;
i
++
)
{
PrintMsg( p_this, &p_this->p_libvlc->msg_bank.msg[i_index] );
vlc_mutex_lock
(
&
p_this
->
p_libvlc
->
msg_bank
.
pp_queues
[
i
]
->
lock
);
FlushMsg
(
p_this
->
p_libvlc
->
msg_bank
.
pp_queues
[
i
]
);
vlc_mutex_unlock
(
&
p_this
->
p_libvlc
->
msg_bank
.
pp_queues
[
i
]
->
lock
);
}
#endif
FlushMsg
(
&
p_this
->
p_libvlc
->
msg_bank
);
vlc_mutex_unlock
(
&
p_this
->
p_libvlc
->
msg_bank
.
lock
);
}
/**
* Free resources allocated by msg_Create
*
* This functions prints all messages remaining in
queue, then free all the
*
resources allocated by msg_Create.
* This functions prints all messages remaining in
the normal queue,
*
then frees all the allocated ressources
* No other messages interface functions should be called after this one.
*/
void
__msg_Destroy
(
vlc_object_t
*
p_this
)
{
if
(
p_this
->
p_libvlc
->
msg_bank
.
i_sub
)
{
msg_Err
(
p_this
,
"stale interface subscribers"
);
}
/* Flush the queue */
if
(
!
p_this
->
p_libvlc
->
msg_bank
.
b_configured
)
int
i
;
for
(
i
=
0
;
i
<
p_this
->
p_libvlc
->
msg_bank
.
i_queues
;
i
++
)
{
msg_Flush
(
p_this
);
}
else
msg_queue_t
*
p_queue
=
p_this
->
p_libvlc
->
msg_bank
.
pp_queues
[
i
];
if
(
p_queue
->
i_sub
)
{
FlushMsg
(
&
p_this
->
p_libvlc
->
msg_bank
);
msg_Err
(
p_this
,
"stale interface subscribers"
);
}
FlushMsg
(
p_queue
);
#ifdef UNDER_CE
CloseHandle
(
p_this
->
p_libvlc
->
msg_bank
.
logfile
);
if
(
i
==
MSG_STREAM_NORMAL
)
CloseHandle
(
p_this
->
p_libvlc
->
msg_bank
.
pp_queues
[
MSG_QUEUE_NORMAL
]
->
logfile
);
#endif
/* Destroy lock */
vlc_mutex_destroy
(
&
p_this
->
p_libvlc
->
msg_bank
.
lock
);
vlc_mutex_destroy
(
&
p_queue
->
lock
);
}
}
/**
* Subscribe to the message queue.
*/
msg_subscription_t
*
__msg_Subscribe
(
vlc_object_t
*
p_this
)
msg_subscription_t
*
__msg_Subscribe
(
vlc_object_t
*
p_this
,
int
i_queue
)
{
msg_bank_t
*
p_bank
=
&
p_this
->
p_libvlc
->
msg_bank
;
msg_subscription_t
*
p_sub
=
malloc
(
sizeof
(
msg_subscription_t
)
);
msg_queue_t
*
p_queue
=
NULL
;
int
i
;
vlc_mutex_lock
(
&
p_bank
->
lock
);
for
(
i
=
0
;
i
<
p_bank
->
i_queues
;
i
++
)
{
if
(
p_bank
->
pp_queues
[
i
]
->
i_id
==
i_queue
)
{
p_queue
=
p_bank
->
pp_queues
[
i
];
}
}
if
(
p_queue
==
NULL
)
{
vlc_mutex_unlock
(
&
p_bank
->
lock
);
return
NULL
;
}
vlc_mutex_lock
(
&
p_queue
->
lock
);
/* Add subscription to the list */
INSERT_ELEM
(
p_bank
->
pp_sub
,
p_bank
->
i_sub
,
p_bank
->
i_sub
,
p_sub
);
INSERT_ELEM
(
p_bank
->
pp_queues
[
i_queue
]
->
pp_sub
,
p_bank
->
pp_queues
[
i_queue
]
->
i_sub
,
p_bank
->
pp_queues
[
i_queue
]
->
i_sub
,
p_sub
);
p_sub
->
i_start
=
p_
bank
->
i_start
;
p_sub
->
pi_stop
=
&
p_
bank
->
i_stop
;
p_sub
->
i_start
=
p_
queue
->
i_start
;
p_sub
->
pi_stop
=
&
p_
queue
->
i_stop
;
p_sub
->
p_msg
=
p_
bank
->
msg
;
p_sub
->
p_lock
=
&
p_
bank
->
lock
;
p_sub
->
p_msg
=
p_
queue
->
msg
;
p_sub
->
p_lock
=
&
p_
queue
->
lock
;
vlc_mutex_unlock
(
&
p_queue
->
lock
);
vlc_mutex_unlock
(
&
p_bank
->
lock
);
return
p_sub
;
...
...
@@ -180,37 +201,26 @@ msg_subscription_t *__msg_Subscribe( vlc_object_t *p_this )
void
__msg_Unsubscribe
(
vlc_object_t
*
p_this
,
msg_subscription_t
*
p_sub
)
{
msg_bank_t
*
p_bank
=
&
p_this
->
p_libvlc
->
msg_bank
;
int
i
_index
;
int
i
,
j
;
vlc_mutex_lock
(
&
p_bank
->
lock
);
/* Sanity check */
if
(
!
p_bank
->
i_sub
)
for
(
i
=
0
;
i
<
p_bank
->
i_queues
;
i
++
)
{
msg_Err
(
p_this
,
"no subscriber in the list"
);
return
;
}
/* Look for the appropriate subscription */
for
(
i_index
=
0
;
i_index
<
p_bank
->
i_sub
;
i_index
++
)
vlc_mutex_lock
(
&
p_bank
->
pp_queues
[
i
]
->
lock
);
for
(
j
=
0
;
j
<
p_bank
->
pp_queues
[
i
]
->
i_sub
;
j
++
)
{
if
(
p_bank
->
pp_
sub
[
i_index
]
==
p_sub
)
if
(
p_bank
->
pp_
queues
[
i
]
->
pp_sub
[
j
]
==
p_sub
)
{
break
;
REMOVE_ELEM
(
p_bank
->
pp_queues
[
i
]
->
pp_sub
,
p_bank
->
pp_queues
[
i
]
->
i_sub
,
j
);
if
(
p_sub
)
free
(
p_sub
);
}
}
if
(
p_bank
->
pp_sub
[
i_index
]
!=
p_sub
)
{
msg_Err
(
p_this
,
"subscriber not found"
);
vlc_mutex_unlock
(
&
p_bank
->
lock
);
return
;
vlc_mutex_unlock
(
&
p_bank
->
pp_queues
[
i
]
->
lock
);
}
/* Remove this subscription */
REMOVE_ELEM
(
p_bank
->
pp_sub
,
p_bank
->
i_sub
,
i_index
);
if
(
p_sub
)
free
(
p_sub
);
vlc_mutex_unlock
(
&
p_bank
->
lock
);
}
...
...
@@ -219,20 +229,22 @@ void __msg_Unsubscribe( vlc_object_t *p_this, msg_subscription_t *p_sub )
*****************************************************************************
* These functions queue a message for later printing.
*****************************************************************************/
void
__msg_Generic
(
vlc_object_t
*
p_this
,
int
i_type
,
const
char
*
psz_module
,