Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 233710
b: refs/heads/master
c: 382225e
h: refs/heads/master
v: v3
  • Loading branch information
Takashi Iwai committed Feb 23, 2011
1 parent 4ddf5ee commit 0dc8806
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 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: 306496761745942d8167e9193a738b559a7fb0b3
refs/heads/master: 382225e62bdb8059b7f915b133426425516dd300
4 changes: 4 additions & 0 deletions trunk/sound/usb/card.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx,
return -ENOMEM;
}

mutex_init(&chip->shutdown_mutex);
chip->index = idx;
chip->dev = dev;
chip->card = card;
Expand Down Expand Up @@ -531,6 +532,7 @@ static void snd_usb_audio_disconnect(struct usb_device *dev, void *ptr)
chip = ptr;
card = chip->card;
mutex_lock(&register_mutex);
mutex_lock(&chip->shutdown_mutex);
chip->shutdown = 1;
chip->num_interfaces--;
if (chip->num_interfaces <= 0) {
Expand All @@ -548,9 +550,11 @@ static void snd_usb_audio_disconnect(struct usb_device *dev, void *ptr)
snd_usb_mixer_disconnect(p);
}
usb_chip[chip->index] = NULL;
mutex_unlock(&chip->shutdown_mutex);
mutex_unlock(&register_mutex);
snd_card_free_when_closed(card);
} else {
mutex_unlock(&chip->shutdown_mutex);
mutex_unlock(&register_mutex);
}
}
Expand Down
7 changes: 5 additions & 2 deletions trunk/sound/usb/pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,13 +361,15 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream,
}

if (changed) {
mutex_lock(&subs->stream->chip->shutdown_mutex);
/* format changed */
snd_usb_release_substream_urbs(subs, 0);
/* influenced: period_bytes, channels, rate, format, */
ret = snd_usb_init_substream_urbs(subs, params_period_bytes(hw_params),
params_rate(hw_params),
snd_pcm_format_physical_width(params_format(hw_params)) *
params_channels(hw_params));
mutex_unlock(&subs->stream->chip->shutdown_mutex);
}

return ret;
Expand All @@ -385,8 +387,9 @@ static int snd_usb_hw_free(struct snd_pcm_substream *substream)
subs->cur_audiofmt = NULL;
subs->cur_rate = 0;
subs->period_bytes = 0;
if (!subs->stream->chip->shutdown)
snd_usb_release_substream_urbs(subs, 0);
mutex_lock(&subs->stream->chip->shutdown_mutex);
snd_usb_release_substream_urbs(subs, 0);
mutex_unlock(&subs->stream->chip->shutdown_mutex);
return snd_pcm_lib_free_vmalloc_buffer(substream);
}

Expand Down
1 change: 1 addition & 0 deletions trunk/sound/usb/usbaudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ struct snd_usb_audio {
struct snd_card *card;
u32 usb_id;
int shutdown;
struct mutex shutdown_mutex;
unsigned int txfr_quirk:1; /* Subframe boundaries on transfers */
int num_interfaces;
int num_suspended_intf;
Expand Down

0 comments on commit 0dc8806

Please sign in to comment.