Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-gpu
Commits
e996cbef
Commit
e996cbef
authored
Aug 09, 2009
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
LibVLC: per-thread error message API
parent
3fb6bc11
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
200 additions
and
2 deletions
+200
-2
include/vlc/libvlc.h
include/vlc/libvlc.h
+44
-0
src/Makefile.am
src/Makefile.am
+1
-0
src/control/core.c
src/control/core.c
+16
-2
src/control/error.c
src/control/error.c
+131
-0
src/control/libvlc_internal.h
src/control/libvlc_internal.h
+4
-0
src/libvlc.sym
src/libvlc.sym
+4
-0
No files found.
include/vlc/libvlc.h
View file @
e996cbef
...
...
@@ -58,6 +58,7 @@
extern
"C"
{
# endif
#include <stdarg.h>
#include <vlc/libvlc_structures.h>
/*****************************************************************************
...
...
@@ -117,6 +118,49 @@ libvlc_exception_get_message( const libvlc_exception_t *p_exception );
/**@} */
/*****************************************************************************
* Error handling
*****************************************************************************/
/** \defgroup libvlc_error libvlc_error
* \ingroup libvlc_core
* LibVLC error handling
* @{
*/
/**
* A human-readable error message for the last LibVLC error in the calling
* thread. The resulting string is valid until another error occurs (at least
* until the next LibVLC call).
*
* @warning
* This will be NULL if there was no error.
*/
const
char
*
libvlc_errmsg
(
void
);
/**
* Clears the LibVLC error status for the current thread. This is optional.
* By default, the error status is automatically overriden when a new error
* occurs, and destroyed when the thread exits.
*/
void
libvlc_clearerr
(
void
);
/**
* Sets the LibVLC error status and message for the current thread.
* Any previous error is overriden.
* @return a nul terminated string in any case
*/
const
char
*
libvlc_vprinterr
(
const
char
*
fmt
,
va_list
ap
);
/**
* Sets the LibVLC error status and message for the current thread.
* Any previous error is overriden.
* @return a nul terminated string in any case
*/
const
char
*
libvlc_printerr
(
const
char
*
fmt
,
...);
/**@} */
/*****************************************************************************
* Core handling
*****************************************************************************/
...
...
src/Makefile.am
View file @
e996cbef
...
...
@@ -460,6 +460,7 @@ SOURCES_libvlc_control = \
control/media_list_view_internal.h
\
control/media_player_internal.h
\
control/core.c
\
control/error.c
\
control/log.c
\
control/playlist.c
\
control/vlm.c
\
...
...
src/control/core.c
View file @
e996cbef
...
...
@@ -111,11 +111,22 @@ libvlc_instance_t * libvlc_new( int argc, const char *const *argv,
{
libvlc_instance_t
*
p_new
;
int
i_ret
;
libvlc_init_threads
();
libvlc_int_t
*
p_libvlc_int
=
libvlc_InternalCreate
();
if
(
!
p_libvlc_int
)
RAISENULL
(
"VLC initialization failed"
);
if
(
!
p_libvlc_int
)
{
libvlc_deinit_threads
();
RAISENULL
(
"VLC initialization failed"
);
}
p_new
=
malloc
(
sizeof
(
libvlc_instance_t
)
);
if
(
!
p_new
)
RAISENULL
(
"Out of memory"
);
if
(
!
p_new
)
{
libvlc_deinit_threads
();
RAISENULL
(
"Out of memory"
);
}
const
char
*
my_argv
[
argc
+
2
];
...
...
@@ -132,6 +143,8 @@ libvlc_instance_t * libvlc_new( int argc, const char *const *argv,
{
libvlc_InternalDestroy
(
p_libvlc_int
);
free
(
p_new
);
libvlc_deinit_threads
();
if
(
i_ret
==
VLC_EEXITSUCCESS
)
return
NULL
;
else
...
...
@@ -181,6 +194,7 @@ void libvlc_release( libvlc_instance_t *p_instance )
libvlc_InternalCleanup
(
p_instance
->
p_libvlc_int
);
libvlc_InternalDestroy
(
p_instance
->
p_libvlc_int
);
free
(
p_instance
);
libvlc_deinit_threads
();
}
}
...
...
src/control/error.c
0 → 100644
View file @
e996cbef
/*****************************************************************************
* error.c: Error handling for libvlc
*****************************************************************************
* Copyright (C) 2009 Rémi Denis-Courmont
*
* 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.
*****************************************************************************/
#include "libvlc_internal.h"
#include <stdarg.h>
#include <stdio.h>
#include <assert.h>
#include <vlc/libvlc.h>
static
const
char
oom
[]
=
"Out of memory"
;
/* TODO: use only one thread-specific key for whole libvlc */
static
vlc_threadvar_t
context
;
static
void
libvlc_setup_threads
(
bool
init
)
{
static
vlc_mutex_t
lock
=
VLC_STATIC_MUTEX
;
static
uintptr_t
refs
=
0
;
vlc_mutex_lock
(
&
lock
);
if
(
init
)
{
if
(
refs
++
==
0
)
vlc_threadvar_create
(
&
context
,
free
);
}
else
{
assert
(
refs
>
0
);
if
(
--
refs
==
0
)
vlc_threadvar_delete
(
&
context
);
}
vlc_mutex_unlock
(
&
lock
);
}
void
libvlc_init_threads
(
void
)
{
libvlc_setup_threads
(
true
);
}
void
libvlc_deinit_threads
(
void
)
{
libvlc_setup_threads
(
false
);
}
static
char
*
get_error
(
void
)
{
return
vlc_threadvar_get
(
context
);
}
static
void
free_error
(
void
)
{
char
*
msg
=
get_error
();
if
(
msg
!=
oom
)
free
(
msg
);
}
/**
* Gets a human-readable error message for the last LibVLC error in the calling
* thread. The resulting string is valid until another error occurs (at least
* until the next LibVLC call).
*
* @return NULL if there was no error, a nul-terminated string otherwise.
*/
const
char
*
libvlc_errmsg
(
void
)
{
return
get_error
();
}
/**
* Clears the LibVLC error status for the current thread. This is optional.
* By default, the error status is automatically overriden when a new error
* occurs, and destroyed when the thread exits.
*/
void
libvlc_clearerr
(
void
)
{
free_error
();
vlc_threadvar_set
(
context
,
NULL
);
}
/**
* Sets the LibVLC error status and message for the current thread.
* Any previous error is overriden.
* @return a nul terminated string (always)
*/
const
char
*
libvlc_vprinterr
(
const
char
*
fmt
,
va_list
ap
)
{
char
*
msg
;
assert
(
fmt
!=
NULL
);
if
(
vasprintf
(
&
msg
,
fmt
,
ap
)
==
-
1
)
msg
=
(
char
*
)
oom
;
free_error
();
vlc_threadvar_set
(
context
,
msg
);
return
msg
;
}
/**
* Sets the LibVLC error status and message for the current thread.
* Any previous error is overriden.
* @return a nul terminated string (always)
*/
const
char
*
libvlc_printerr
(
const
char
*
fmt
,
...)
{
va_list
ap
;
const
char
*
msg
;
va_start
(
ap
,
fmt
);
msg
=
libvlc_vprinterr
(
fmt
,
ap
);
va_end
(
ap
);
return
msg
;
}
src/control/libvlc_internal.h
View file @
e996cbef
...
...
@@ -83,6 +83,10 @@ struct libvlc_instance_t
* Other internal functions
***************************************************************************/
/* Thread context */
void
libvlc_init_threads
(
void
);
void
libvlc_deinit_threads
(
void
);
/* Events */
libvlc_event_manager_t
*
libvlc_event_manager_new
(
void
*
p_obj
,
libvlc_instance_t
*
p_libvlc_inst
,
...
...
src/libvlc.sym
View file @
e996cbef
libvlc_errmsg
libvlc_clearerr
libvlc_printerr
libvlc_vprinterr
libvlc_add_intf
libvlc_audio_output_device_count
libvlc_audio_output_device_id
...
...
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