File operations that manipulate the state of the encoder, or video or audio
subdevices or some of the stream flags need to be serialized. Add the
serilization locks to cx18-alsa in a manner consistent with the locking for
the v4l2 file operations.
Signed-off-by: Andy Walls <awalls@radix.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
int ret;
/* Instruct the cx18 to start sending packets */
int ret;
/* Instruct the cx18 to start sending packets */
s = &cx->streams[CX18_ENC_STREAM_TYPE_PCM];
/* Allocate memory */
item = kmalloc(sizeof(struct cx18_open_id), GFP_KERNEL);
s = &cx->streams[CX18_ENC_STREAM_TYPE_PCM];
/* Allocate memory */
item = kmalloc(sizeof(struct cx18_open_id), GFP_KERNEL);
+ if (NULL == item) {
+ snd_cx18_unlock(cxsc);
item->cx = cx;
item->type = s->type;
item->cx = cx;
item->type = s->type;
if (cx18_claim_stream(item, item->type)) {
/* No, it's already in use */
kfree(item);
if (cx18_claim_stream(item, item->type)) {
/* No, it's already in use */
kfree(item);
return -EBUSY;
}
if (test_bit(CX18_F_S_STREAMOFF, &s->s_flags) ||
test_and_set_bit(CX18_F_S_STREAMING, &s->s_flags)) {
/* We're already streaming. No additional action required */
return -EBUSY;
}
if (test_bit(CX18_F_S_STREAMOFF, &s->s_flags) ||
test_and_set_bit(CX18_F_S_STREAMING, &s->s_flags)) {
/* We're already streaming. No additional action required */
/* Not currently streaming, so start it up */
set_bit(CX18_F_S_STREAMING, &s->s_flags);
ret = cx18_start_v4l2_encode_stream(s);
/* Not currently streaming, so start it up */
set_bit(CX18_F_S_STREAMING, &s->s_flags);
ret = cx18_start_v4l2_encode_stream(s);
int ret;
/* Instruct the cx18 to stop sending packets */
int ret;
/* Instruct the cx18 to stop sending packets */
s = &cx->streams[CX18_ENC_STREAM_TYPE_PCM];
ret = cx18_stop_v4l2_encode_stream(s, 0);
clear_bit(CX18_F_S_STREAMING, &s->s_flags);
s = &cx->streams[CX18_ENC_STREAM_TYPE_PCM];
ret = cx18_stop_v4l2_encode_stream(s, 0);
clear_bit(CX18_F_S_STREAMING, &s->s_flags);
cx18_release_stream(s);
cx->pcm_announce_callback = NULL;
cx18_release_stream(s);
cx->pcm_announce_callback = NULL;