Commit b771bc38 authored by Jorge Zapata's avatar Jorge Zapata Committed by Jean-Paul Saman

Fix NON BLOCKING issue with the sound driver

Signed-off-by: default avatarJean-Paul Saman <jpsaman@videolan.org>
parent 8184f9f5
...@@ -507,6 +507,7 @@ audio_write(struct file *file, const char *buffer, size_t count, loff_t * ppos) ...@@ -507,6 +507,7 @@ audio_write(struct file *file, const char *buffer, size_t count, loff_t * ppos)
audio_state_t *state = file->private_data; audio_state_t *state = file->private_data;
audio_stream_t *s = state->output_stream; audio_stream_t *s = state->output_stream;
int chunksize, ret = 0; int chunksize, ret = 0;
unsigned long flags;
DPRINTK("audio_write: count=%d\n", count); DPRINTK("audio_write: count=%d\n", count);
if (*ppos != file->f_pos) { if (*ppos != file->f_pos) {
...@@ -528,9 +529,14 @@ audio_write(struct file *file, const char *buffer, size_t count, loff_t * ppos) ...@@ -528,9 +529,14 @@ audio_write(struct file *file, const char *buffer, size_t count, loff_t * ppos)
/* Wait for a buffer to become free */ /* Wait for a buffer to become free */
if (file->f_flags & O_NONBLOCK) { if (file->f_flags & O_NONBLOCK) {
ret = -EAGAIN; if (!s->wfc.done) {
if (!s->wfc.done) ret = -EAGAIN;
break; break;
} else {
local_irq_save(flags);
s->wfc.done--;
local_irq_restore(flags);
}
} else { } else {
ret = -ERESTARTSYS; ret = -ERESTARTSYS;
if (wait_for_completion_interruptible(&s->wfc)) if (wait_for_completion_interruptible(&s->wfc))
...@@ -558,13 +564,14 @@ audio_write(struct file *file, const char *buffer, size_t count, loff_t * ppos) ...@@ -558,13 +564,14 @@ audio_write(struct file *file, const char *buffer, size_t count, loff_t * ppos)
} }
/* Update pointers and send current fragment to DMA */ /* Update pointers and send current fragment to DMA */
local_irq_save(flags);
b->offset = 0; b->offset = 0;
if (++s->usr_head >= s->nbfrags) if (++s->usr_head >= s->nbfrags)
s->usr_head = 0; s->usr_head = 0;
/* Add the num of frags pending */ /* Add the num of frags pending */
s->pending_frags++; s->pending_frags++;
s->active = 1; s->active = 1;
local_irq_restore(flags);
audio_process_dma(s); audio_process_dma(s);
} }
...@@ -614,9 +621,14 @@ audio_read(struct file *file, char *buffer, size_t count, loff_t * ppos) ...@@ -614,9 +621,14 @@ audio_read(struct file *file, char *buffer, size_t count, loff_t * ppos)
/* Wait for a buffer to become full */ /* Wait for a buffer to become full */
if (file->f_flags & O_NONBLOCK) { if (file->f_flags & O_NONBLOCK) {
ret = -EAGAIN; if (!s->wfc.done) {
if(!s->done_flag) ret = -EAGAIN;
break; break;
} else {
local_irq_save(flags);
s->wfc.done--;
local_irq_restore(flags);
}
} else { } else {
ret = -ERESTARTSYS; ret = -ERESTARTSYS;
if (wait_for_completion_interruptible(&s->wfc)) if (wait_for_completion_interruptible(&s->wfc))
......
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