Commit acd42fb5 authored by Edward Wang's avatar Edward Wang Committed by Jean-Baptiste Kempf

oss: Compilation fixes and cleanup

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent b04188b4
...@@ -56,6 +56,7 @@ struct aout_sys_t ...@@ -56,6 +56,7 @@ struct aout_sys_t
uint8_t level; uint8_t level;
bool mute; bool mute;
bool starting; bool starting;
audio_sample_format_t format;
}; };
static int Open (vlc_object_t *); static int Open (vlc_object_t *);
...@@ -94,7 +95,7 @@ static int DeviceChanged (vlc_object_t *obj, const char *varname, ...@@ -94,7 +95,7 @@ static int DeviceChanged (vlc_object_t *obj, const char *varname,
static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt) static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt)
{ {
audio_output_t *aout = (audio_output_t *)obj; aout_sys_t* sys = aout->sys;
/* Open the device */ /* Open the device */
const char *device; const char *device;
...@@ -114,11 +115,6 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt) ...@@ -114,11 +115,6 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt)
free (devicebuf); free (devicebuf);
return VLC_EGENERIC; return VLC_EGENERIC;
} }
aout_sys_t *sys = malloc (sizeof (*sys));
if (unlikely(sys == NULL))
goto error;
aout->sys = sys;
sys->fd = fd; sys->fd = fd;
/* Select audio format */ /* Select audio format */
...@@ -288,8 +284,10 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt) ...@@ -288,8 +284,10 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt)
} }
} }
sys->format = *fmt;
free (devicebuf); free (devicebuf);
return 0; return VLC_SUCCESS;
error: error:
free (sys); free (sys);
close (fd); close (fd);
...@@ -305,8 +303,8 @@ static void Stop (audio_output_t *aout) ...@@ -305,8 +303,8 @@ static void Stop (audio_output_t *aout)
aout_sys_t *sys = aout->sys; aout_sys_t *sys = aout->sys;
int fd = sys->fd; int fd = sys->fd;
var_DelCallback (obj, "audio-device", DeviceChanged, NULL); var_DelCallback (aout, "audio-device", DeviceChanged, NULL);
var_Destroy (obj, "audio-device"); var_Destroy (aout, "audio-device");
ioctl (fd, SNDCTL_DSP_HALT, NULL); ioctl (fd, SNDCTL_DSP_HALT, NULL);
close (fd); close (fd);
...@@ -325,8 +323,8 @@ static void Play (audio_output_t *aout, block_t *block, ...@@ -325,8 +323,8 @@ static void Play (audio_output_t *aout, block_t *block,
int delay; int delay;
if (ioctl (sys->fd, SNDCTL_DSP_GETODELAY, &delay) >= 0) if (ioctl (sys->fd, SNDCTL_DSP_GETODELAY, &delay) >= 0)
{ {
mtime_t latency = (delay * CLOCK_FREQ * aout->format.i_frame_length) mtime_t latency = (delay * CLOCK_FREQ * sys->format.i_frame_length)
/ (aout->format.i_rate * aout->format.i_bytes_per_frame); / (sys->format.i_rate * sys->format.i_bytes_per_frame);
*drift = mdate () + latency - block->i_pts; *drift = mdate () + latency - block->i_pts;
} }
else else
...@@ -446,7 +444,12 @@ static int Open (vlc_object_t *obj) ...@@ -446,7 +444,12 @@ static int Open (vlc_object_t *obj)
{ {
audio_output_t *aout = (audio_output_t *)obj; audio_output_t *aout = (audio_output_t *)obj;
aout_sys_t *sys = malloc (sizeof (*sys));
if(unlikely( sys == NULL ))
return VLC_ENOMEM;
/* FIXME: set volume/mute here */ /* FIXME: set volume/mute here */
aout->sys = sys;
aout->start = Start; aout->start = Start;
aout->stop = Stop; aout->stop = Stop;
return VLC_SUCCESS; return VLC_SUCCESS;
......
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