Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 167071
b: refs/heads/master
c: 8dce39b
h: refs/heads/master
i:
  167069: 1b2a0c6
  167067: 2e655c8
  167063: ec7f5c7
  167055: 4d7deeb
  167039: 114e738
v: v3
  • Loading branch information
Krzysztof Helt authored and Takashi Iwai committed Oct 8, 2009
1 parent 6fedddb commit 2f0e103
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2bdf66331c3ff8d564efe7a054f1099133d520cd
refs/heads/master: 8dce39b8955be6164172cb6204ef8fc21de27431
28 changes: 20 additions & 8 deletions trunk/sound/drivers/opl3/opl3_midi.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ extern char snd_opl3_regmap[MAX_OPL2_VOICES][4];

extern int use_internal_drums;

static void snd_opl3_note_off_unsafe(void *p, int note, int vel,
struct snd_midi_channel *chan);
/*
* The next table looks magical, but it certainly is not. Its values have
* been calculated as table[i]=8*log(i/64)/log(2) with an obvious exception
Expand Down Expand Up @@ -242,16 +244,20 @@ void snd_opl3_timer_func(unsigned long data)
int again = 0;
int i;

spin_lock_irqsave(&opl3->sys_timer_lock, flags);
spin_lock_irqsave(&opl3->voice_lock, flags);
for (i = 0; i < opl3->max_voices; i++) {
struct snd_opl3_voice *vp = &opl3->voices[i];
if (vp->state > 0 && vp->note_off_check) {
if (vp->note_off == jiffies)
snd_opl3_note_off(opl3, vp->note, 0, vp->chan);
snd_opl3_note_off_unsafe(opl3, vp->note, 0,
vp->chan);
else
again++;
}
}
spin_unlock_irqrestore(&opl3->voice_lock, flags);

spin_lock_irqsave(&opl3->sys_timer_lock, flags);
if (again) {
opl3->tlist.expires = jiffies + 1; /* invoke again */
add_timer(&opl3->tlist);
Expand Down Expand Up @@ -658,28 +664,24 @@ static void snd_opl3_kill_voice(struct snd_opl3 *opl3, int voice)
/*
* Release a note in response to a midi note off.
*/
void snd_opl3_note_off(void *p, int note, int vel, struct snd_midi_channel *chan)
static void snd_opl3_note_off_unsafe(void *p, int note, int vel,
struct snd_midi_channel *chan)
{
struct snd_opl3 *opl3;

int voice;
struct snd_opl3_voice *vp;

unsigned long flags;

opl3 = p;

#ifdef DEBUG_MIDI
snd_printk(KERN_DEBUG "Note off, ch %i, inst %i, note %i\n",
chan->number, chan->midi_program, note);
#endif

spin_lock_irqsave(&opl3->voice_lock, flags);

if (opl3->synth_mode == SNDRV_OPL3_MODE_SEQ) {
if (chan->drum_channel && use_internal_drums) {
snd_opl3_drum_switch(opl3, note, vel, 0, chan);
spin_unlock_irqrestore(&opl3->voice_lock, flags);
return;
}
/* this loop will hopefully kill all extra voices, because
Expand All @@ -697,6 +699,16 @@ void snd_opl3_note_off(void *p, int note, int vel, struct snd_midi_channel *chan
snd_opl3_kill_voice(opl3, voice);
}
}
}

void snd_opl3_note_off(void *p, int note, int vel,
struct snd_midi_channel *chan)
{
struct snd_opl3 *opl3 = p;
unsigned long flags;

spin_lock_irqsave(&opl3->voice_lock, flags);
snd_opl3_note_off_unsafe(p, note, vel, chan);
spin_unlock_irqrestore(&opl3->voice_lock, flags);
}

Expand Down

0 comments on commit 2f0e103

Please sign in to comment.