Commit 1a5aaf25 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

amem: correct opaque pointer for consecutive setup() calls

parent a762948c
...@@ -58,7 +58,11 @@ struct aout_sys_t ...@@ -58,7 +58,11 @@ struct aout_sys_t
int (*setup) (void **, char *, unsigned *, unsigned *); int (*setup) (void **, char *, unsigned *, unsigned *);
union union
{ {
void (*cleanup) (void *opaque); struct
{
void *setup_opaque;
void (*cleanup) (void *opaque);
};
struct struct
{ {
unsigned rate:18; unsigned rate:18;
...@@ -149,6 +153,7 @@ static int Start (audio_output_t *aout, audio_sample_format_t *fmt) ...@@ -149,6 +153,7 @@ static int Start (audio_output_t *aout, audio_sample_format_t *fmt)
{ {
channels = aout_FormatNbChannels(fmt); channels = aout_FormatNbChannels(fmt);
sys->opaque = sys->setup_opaque;
if (sys->setup (&sys->opaque, format, &fmt->i_rate, &channels)) if (sys->setup (&sys->opaque, format, &fmt->i_rate, &channels))
return VLC_EGENERIC; return VLC_EGENERIC;
} }
...@@ -223,13 +228,16 @@ static int Open (vlc_object_t *obj) ...@@ -223,13 +228,16 @@ static int Open (vlc_object_t *obj)
if (unlikely(sys == NULL)) if (unlikely(sys == NULL))
return VLC_ENOMEM; return VLC_ENOMEM;
aout->sys = sys; void *opaque = var_InheritAddress (obj, "amem-data");
sys->opaque = var_InheritAddress (obj, "amem-data");
sys->setup = var_InheritAddress (obj, "amem-setup"); sys->setup = var_InheritAddress (obj, "amem-setup");
if (sys->setup != NULL) if (sys->setup != NULL)
{
sys->setup_opaque = opaque;
sys->cleanup = var_InheritAddress (obj, "amem-cleanup"); sys->cleanup = var_InheritAddress (obj, "amem-cleanup");
}
else else
{ {
sys->opaque = opaque;
sys->rate = var_InheritInteger (obj, "amem-rate"); sys->rate = var_InheritInteger (obj, "amem-rate");
sys->channels = var_InheritInteger (obj, "amem-channels"); sys->channels = var_InheritInteger (obj, "amem-channels");
} }
...@@ -247,6 +255,7 @@ static int Open (vlc_object_t *obj) ...@@ -247,6 +255,7 @@ static int Open (vlc_object_t *obj)
return VLC_EGENERIC; return VLC_EGENERIC;
} }
aout->sys = sys;
aout->start = Start; aout->start = Start;
aout->stop = Stop; aout->stop = Stop;
aout->time_get = NULL; aout->time_get = NULL;
......
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