Commit 152b1687 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Merge branch 1.0-bugfix into master

Conflicts:
	modules/video_output/drawable.c
	src/control/libvlc_internal.h
parents 4d4f701e 0577234c
...@@ -128,12 +128,14 @@ static aout_buffer_t *DecodeBlock (decoder_t *p_dec, block_t **pp_block) ...@@ -128,12 +128,14 @@ static aout_buffer_t *DecodeBlock (decoder_t *p_dec, block_t **pp_block)
{ {
block_t *p_block; block_t *p_block;
decoder_sys_t *p_sys = p_dec->p_sys; decoder_sys_t *p_sys = p_dec->p_sys;
aout_buffer_t *p_out = NULL;
if (pp_block == NULL) if (pp_block == NULL)
return NULL; return NULL;
p_block = *pp_block; p_block = *pp_block;
if (p_block == NULL) if (p_block == NULL)
return NULL; return NULL;
*pp_block = NULL;
if (p_block->i_pts && !aout_DateGet (&p_sys->end_date)) if (p_block->i_pts && !aout_DateGet (&p_sys->end_date))
aout_DateSet (&p_sys->end_date, p_block->i_pts); aout_DateSet (&p_sys->end_date, p_block->i_pts);
...@@ -141,12 +143,11 @@ static aout_buffer_t *DecodeBlock (decoder_t *p_dec, block_t **pp_block) ...@@ -141,12 +143,11 @@ static aout_buffer_t *DecodeBlock (decoder_t *p_dec, block_t **pp_block)
if (p_block->i_pts < aout_DateGet (&p_sys->end_date)) if (p_block->i_pts < aout_DateGet (&p_sys->end_date))
{ {
msg_Warn (p_dec, "MIDI message in the past?"); msg_Warn (p_dec, "MIDI message in the past?");
block_Release (p_block); goto drop;
return NULL;
} }
if (p_block->i_buffer < 1) if (p_block->i_buffer < 1)
return NULL; goto drop;
uint8_t channel = p_block->p_buffer[0] & 0xf; uint8_t channel = p_block->p_buffer[0] & 0xf;
uint8_t p1 = (p_block->i_buffer > 1) ? (p_block->p_buffer[1] & 0x7f) : 0; uint8_t p1 = (p_block->i_buffer > 1) ? (p_block->p_buffer[1] & 0x7f) : 0;
...@@ -170,25 +171,22 @@ static aout_buffer_t *DecodeBlock (decoder_t *p_dec, block_t **pp_block) ...@@ -170,25 +171,22 @@ static aout_buffer_t *DecodeBlock (decoder_t *p_dec, block_t **pp_block)
fluid_synth_pitch_bend (p_sys->synth, channel, (p1 << 7) | p2); fluid_synth_pitch_bend (p_sys->synth, channel, (p1 << 7) | p2);
break; break;
} }
p_block->p_buffer += p_block->i_buffer;
p_block->i_buffer = 0;
unsigned samples = unsigned samples =
(p_block->i_pts - aout_DateGet (&p_sys->end_date)) * 441 / 10000; (p_block->i_pts - aout_DateGet (&p_sys->end_date)) * 441 / 10000;
if (samples == 0) if (samples == 0)
return NULL; return NULL;
aout_buffer_t *p_out = decoder_NewAudioBuffer (p_dec, samples); p_out = decoder_NewAudioBuffer (p_dec, samples);
if (p_out == NULL) if (p_out == NULL)
{ goto drop;
block_Release (p_block);
return NULL;
}
p_out->start_date = aout_DateGet (&p_sys->end_date ); p_out->start_date = aout_DateGet (&p_sys->end_date );
p_out->end_date = aout_DateIncrement (&p_sys->end_date, samples); p_out->end_date = aout_DateIncrement (&p_sys->end_date, samples);
fluid_synth_write_float (p_sys->synth, samples, fluid_synth_write_float (p_sys->synth, samples,
p_out->p_buffer, 0, 2, p_out->p_buffer, 0, 2,
p_out->p_buffer, 1, 2); p_out->p_buffer, 1, 2);
drop:
block_Release (p_block);
return p_out; return p_out;
} }
...@@ -64,32 +64,80 @@ vlc_module_end () ...@@ -64,32 +64,80 @@ vlc_module_end ()
static int Control (vout_window_t *, int, va_list); static int Control (vout_window_t *, int, va_list);
/* TODO: move to vlc_variables.h */
static inline void *var_GetAddress (vlc_object_t *o, const char *name)
{
vlc_value_t val;
return var_Get (o, name, &val) ? NULL : val.p_address;
}
static vlc_mutex_t serializer = VLC_STATIC_MUTEX;
/** /**
* Find the drawable set by libvlc application. * Find the drawable set by libvlc application.
*/ */
static int Open (vlc_object_t *obj, const char *varname, bool ptr) static int Open (vlc_object_t *obj, const char *varname, bool ptr)
{ {
vout_window_t *wnd = (vout_window_t *)obj; vout_window_t *wnd = (vout_window_t *)obj;
vlc_value_t val; void **used, *val;
size_t n = 0;
if (var_Create (obj, varname, VLC_VAR_DOINHERIT if (var_Create (obj->p_libvlc, "drawables-in-use", VLC_VAR_ADDRESS)
|| var_Create (obj, varname, VLC_VAR_DOINHERIT
| (ptr ? VLC_VAR_ADDRESS : VLC_VAR_INTEGER))) | (ptr ? VLC_VAR_ADDRESS : VLC_VAR_INTEGER)))
return VLC_ENOMEM; return VLC_ENOMEM;
var_Get (obj, varname, &val);
if (ptr)
val = var_GetAddress (obj, varname);
else
val = (void *)(uintptr_t)var_GetInteger (obj, varname);
var_Destroy (obj, varname); var_Destroy (obj, varname);
msg_Err (wnd, "%zu, %p", n, val);
/* Keep a list of busy drawables, so we don't overlap videos if there are
* more than one video track in the stream. */
vlc_mutex_lock (&serializer);
/* TODO: per-type list of busy drawables */
used = var_GetAddress (VLC_OBJECT (obj->p_libvlc), "drawables-in-use");
if (used != NULL)
{
while (used[n] != NULL)
{
if (used[n] == val)
goto skip;
n++;
}
}
if (ptr ? (val.p_address == NULL) : (val.i_int == 0)) used = realloc (used, sizeof (*used) * (n + 2));
if (used != NULL)
{
used[n] = val;
used[n + 1] = NULL;
var_SetAddress (obj->p_libvlc, "drawables-in-use", used);
}
else
{
skip:
msg_Warn (wnd, "drawable %p is busy", val);
val = NULL;
}
vlc_mutex_unlock (&serializer);
msg_Err (wnd, "%zu, %p", n, val);
if (val == NULL)
return VLC_EGENERIC; return VLC_EGENERIC;
if (ptr) if (ptr)
wnd->handle.hwnd = val.p_address; wnd->handle.hwnd = val;
else else
wnd->handle.xid = val.i_int; wnd->handle.xid = (uintptr_t)val;
/* FIXME: check that X server matches --x11-display (if specified) */ /* FIXME: check that X server matches --x11-display (if specified) */
/* FIXME: get window size (in platform-dependent ways) */ /* FIXME: get window size (in platform-dependent ways) */
wnd->control = Control; wnd->control = Control;
wnd->p_sys = val;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -109,7 +157,32 @@ static int OpenHWND (vlc_object_t *obj) ...@@ -109,7 +157,32 @@ static int OpenHWND (vlc_object_t *obj)
*/ */
static void Close (vlc_object_t *obj) static void Close (vlc_object_t *obj)
{ {
(void)obj; vout_window_t *wnd = (vout_window_t *)obj;
void **used, *val = wnd->p_sys;
size_t n = 0;
/* Remove this drawable from the list of busy ones */
vlc_mutex_lock (&serializer);
used = var_GetAddress (VLC_OBJECT (obj->p_libvlc), "drawables-in-use");
assert (used);
while (used[n] != val)
{
assert (used[n]);
n++;
}
do
used[n] = used[n + 1];
while (used[n + 1] != NULL);
if (n == 0)
/* should not be needed (var_Destroy...) but better safe than sorry: */
var_SetAddress (obj->p_libvlc, "drawables-in-use", NULL);
vlc_mutex_unlock (&serializer);
if (n == 0)
free (used);
/* Variables are reference-counted... */
var_Destroy (obj->p_libvlc, "drawables-in-use");
} }
......
...@@ -115,7 +115,10 @@ static int Open (vlc_object_t *obj) ...@@ -115,7 +115,10 @@ static int Open (vlc_object_t *obj)
/* Connect to X */ /* Connect to X */
p_sys->conn = Connect (obj); p_sys->conn = Connect (obj);
if (p_sys->conn == NULL) if (p_sys->conn == NULL)
{
free (p_sys);
return VLC_EGENERIC; return VLC_EGENERIC;
}
/* Get window */ /* Get window */
const xcb_screen_t *scr; const xcb_screen_t *scr;
...@@ -123,6 +126,7 @@ static int Open (vlc_object_t *obj) ...@@ -123,6 +126,7 @@ static int Open (vlc_object_t *obj)
if (p_sys->embed == NULL) if (p_sys->embed == NULL)
{ {
xcb_disconnect (p_sys->conn); xcb_disconnect (p_sys->conn);
free (p_sys);
return VLC_EGENERIC; return VLC_EGENERIC;
} }
......
...@@ -159,12 +159,16 @@ static int Open (vlc_object_t *obj) ...@@ -159,12 +159,16 @@ static int Open (vlc_object_t *obj)
/* Connect to X */ /* Connect to X */
p_sys->conn = Connect (obj); p_sys->conn = Connect (obj);
if (p_sys->conn == NULL) if (p_sys->conn == NULL)
{
free (p_sys);
return VLC_EGENERIC; return VLC_EGENERIC;
}
if (!CheckXVideo (vout, p_sys->conn)) if (!CheckXVideo (vout, p_sys->conn))
{ {
msg_Warn (vout, "Please enable XVideo 2.2 for faster video display"); msg_Warn (vout, "Please enable XVideo 2.2 for faster video display");
xcb_disconnect (p_sys->conn); xcb_disconnect (p_sys->conn);
free (p_sys);
return VLC_EGENERIC; return VLC_EGENERIC;
} }
...@@ -173,6 +177,7 @@ static int Open (vlc_object_t *obj) ...@@ -173,6 +177,7 @@ static int Open (vlc_object_t *obj)
if (p_sys->embed == NULL) if (p_sys->embed == NULL)
{ {
xcb_disconnect (p_sys->conn); xcb_disconnect (p_sys->conn);
free (p_sys);
return VLC_EGENERIC; return VLC_EGENERIC;
} }
......
...@@ -980,7 +980,7 @@ msgid "" ...@@ -980,7 +980,7 @@ msgid ""
"VLC does not support the audio or video format \"%4.4s\". Unfortunately " "VLC does not support the audio or video format \"%4.4s\". Unfortunately "
"there is no way for you to fix this." "there is no way for you to fix this."
msgstr "" msgstr ""
"VLC ne supporte probablement pas le format audio ou vidéo « %4.4s »." "VLC ne supporte probablement pas le format audio ou vidéo « %4.4s ». "
"Malheureusement il n’y a rien à faire." "Malheureusement il n’y a rien à faire."
#: src/input/es_out.c:911 src/input/es_out.c:916 src/libvlc-module.c:346 #: src/input/es_out.c:911 src/input/es_out.c:916 src/libvlc-module.c:346
......
...@@ -164,18 +164,6 @@ struct libvlc_media_player_t ...@@ -164,18 +164,6 @@ struct libvlc_media_player_t
} drawable; } drawable;
}; };
struct libvlc_media_list_player_t
{
libvlc_event_manager_t * p_event_manager;
libvlc_instance_t * p_libvlc_instance;
unsigned i_refcount;
vlc_mutex_t object_lock;
libvlc_media_list_path_t current_playing_item_path;
libvlc_media_t * p_current_playing_item;
libvlc_media_list_t * p_mlist;
libvlc_media_player_t * p_mi;
};
struct libvlc_media_library_t struct libvlc_media_library_t
{ {
libvlc_event_manager_t * p_event_manager; libvlc_event_manager_t * p_event_manager;
......
...@@ -24,6 +24,19 @@ ...@@ -24,6 +24,19 @@
#include <vlc/libvlc.h> #include <vlc/libvlc.h>
#include "media_list_path.h" #include "media_list_path.h"
struct libvlc_media_list_player_t
{
libvlc_event_manager_t * p_event_manager;
libvlc_instance_t * p_libvlc_instance;
int i_refcount;
vlc_mutex_t object_lock;
libvlc_media_list_path_t current_playing_item_path;
libvlc_media_t * p_current_playing_item;
libvlc_media_list_t * p_mlist;
libvlc_media_player_t * p_mi;
};
/* /*
* Private functions * Private functions
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment