uint8_t level;
bool mute;
bool starting;
+ audio_sample_format_t format;
};
static int Open (vlc_object_t *);
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 */
const char *device;
free (devicebuf);
return VLC_EGENERIC;
}
-
- aout_sys_t *sys = malloc (sizeof (*sys));
- if (unlikely(sys == NULL))
- goto error;
- aout->sys = sys;
sys->fd = fd;
/* Select audio format */
}
}
+ sys->format = *fmt;
+
free (devicebuf);
- return 0;
+ return VLC_SUCCESS;
error:
free (sys);
close (fd);
aout_sys_t *sys = aout->sys;
int fd = sys->fd;
- var_DelCallback (obj, "audio-device", DeviceChanged, NULL);
- var_Destroy (obj, "audio-device");
+ var_DelCallback (aout, "audio-device", DeviceChanged, NULL);
+ var_Destroy (aout, "audio-device");
ioctl (fd, SNDCTL_DSP_HALT, NULL);
close (fd);
int delay;
if (ioctl (sys->fd, SNDCTL_DSP_GETODELAY, &delay) >= 0)
{
- mtime_t latency = (delay * CLOCK_FREQ * aout->format.i_frame_length)
- / (aout->format.i_rate * aout->format.i_bytes_per_frame);
+ mtime_t latency = (delay * CLOCK_FREQ * sys->format.i_frame_length)
+ / (sys->format.i_rate * sys->format.i_bytes_per_frame);
*drift = mdate () + latency - block->i_pts;
}
else
{
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 */
+ aout->sys = sys;
aout->start = Start;
aout->stop = Stop;
return VLC_SUCCESS;