1 #include <linux/kthread.h>
2 #include <linux/wait.h>
8 DECLARE_WAIT_QUEUE_HEAD(speakup_event
);
9 EXPORT_SYMBOL_GPL(speakup_event
);
11 int speakup_thread(void *data
)
15 struct bleep our_sound
;
19 our_sound
.jiffies
= 0;
21 mutex_lock(&spk_mutex
);
26 spin_lock_irqsave(&speakup_info
.spinlock
, flags
);
27 our_sound
= spk_unprocessed_sound
;
28 spk_unprocessed_sound
.active
= 0;
29 prepare_to_wait(&speakup_event
, &wait
,
31 should_break
= kthread_should_stop() ||
33 (synth
&& synth
->catch_up
&& synth
->alive
&&
34 (speakup_info
.flushing
||
35 !synth_buffer_empty()));
36 spin_unlock_irqrestore(&speakup_info
.spinlock
, flags
);
39 mutex_unlock(&spk_mutex
);
41 mutex_lock(&spk_mutex
);
43 finish_wait(&speakup_event
, &wait
);
44 if (kthread_should_stop())
48 kd_mksound(our_sound
.freq
, our_sound
.jiffies
);
49 if (synth
&& synth
->catch_up
&& synth
->alive
) {
50 /* It is up to the callee to take the lock, so that it
51 * can sleep whenever it likes */
52 synth
->catch_up(synth
);
57 mutex_unlock(&spk_mutex
);