mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-11-01 17:08:10 +00:00
63e20df1e5
The current code deals with the stream start / stop solely via line6_pcm_acquire() and line6_pcm_release(). This was (supposedly) intended to avoid the races, but it doesn't work as expected. The concurrent acquire and release calls can be performed without proper protections, thus this might result in memory corruption. Furthermore, we can't take a mutex to protect the whole function because it can be called from the PCM trigger callback that is an atomic context. Also spinlock isn't appropriate because the function allocates with kmalloc with GFP_KERNEL. That is, these function just lead to singular problems. This is an attempt to reduce the existing races. First off, separate both the stream buffer management and the stream URB management. The former is protected via a newly introduced state_mutex while the latter is protected via each line6_pcm_stream lock. Secondly, the stream state are now managed in opened and running bit flags of each line6_pcm_stream. Not only this a bit clearer than previous combined bit flags, this also gives a better abstraction. These rewrites allows us to make common hw_params and hw_free callbacks for both playback and capture directions. For the monitor and impulse operations, still line6_pcm_acquire() and line6_pcm_release() are used. They call internally the corresponding functions for both playback and capture streams with proper lock or mutex. Unlike the previous versions, these function don't take the bit masks but the only single type value. Also they are supposed to be applied only as duplex operations. Tested-by: Chris Rorvick <chris@rorvick.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
29 lines
793 B
C
29 lines
793 B
C
/*
|
|
* Line 6 Linux USB driver
|
|
*
|
|
* Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License as
|
|
* published by the Free Software Foundation, version 2.
|
|
*
|
|
*/
|
|
|
|
#ifndef CAPTURE_H
|
|
#define CAPTURE_H
|
|
|
|
#include <sound/pcm.h>
|
|
|
|
#include "driver.h"
|
|
#include "pcm.h"
|
|
|
|
extern struct snd_pcm_ops snd_line6_capture_ops;
|
|
|
|
extern void line6_capture_copy(struct snd_line6_pcm *line6pcm, char *fbuf,
|
|
int fsize);
|
|
extern void line6_capture_check_period(struct snd_line6_pcm *line6pcm,
|
|
int length);
|
|
extern int line6_create_audio_in_urbs(struct snd_line6_pcm *line6pcm);
|
|
extern int line6_submit_audio_in_all_urbs(struct snd_line6_pcm *line6pcm);
|
|
|
|
#endif
|