*参照元 [#r16e1b74]
#backlinks

*説明 [#x336be29]
-パス: [[linux-2.6.33/sound/core/pcm_native.c]]

-FIXME: これは何?
--説明


**引数 [#l29a6049]
-struct file *file
--
--[[linux-2.6.33/file]]
-struct snd_pcm_substream *substream
--
--[[linux-2.6.33/snd_pcm_substream]]
-unsigned int cmd
--
-void __user *arg
--


**返り値 [#jcc438c9]
-int
--


**参考 [#kc9d150b]


*実装 [#w6ef25a2]
 static int snd_pcm_playback_ioctl1(struct file *file,
 				   struct snd_pcm_substream *substream,
 				   unsigned int cmd, void __user *arg)
 {
 	if (snd_BUG_ON(!substream))
 		return -ENXIO;
 	if (snd_BUG_ON(substream->stream != SNDRV_PCM_STREAM_PLAYBACK))
 		return -EINVAL;
-
--[[linux-2.6.33/snd_BUG_ON()]]
-
--[[linux-2.6.33/SNDRV_PCM_STREAM_PLAYBACK]]

 	switch (cmd) {
 	case SNDRV_PCM_IOCTL_WRITEI_FRAMES:
 	{
 		struct snd_xferi xferi;
 		struct snd_xferi __user *_xferi = arg;
 		struct snd_pcm_runtime *runtime = substream->runtime;
 		snd_pcm_sframes_t result;
-
--[[linux-2.6.33/SNDRV_PCM_IOCTL_WRITEI_FRAMES]]
-
--[[linux-2.6.33/snd_xferi]]
-
--[[linux-2.6.33/snd_pcm_runtime]]
-
--[[linux-2.6.33/snd_pcm_sframes_t]]

 		if (runtime->status->state == SNDRV_PCM_STATE_OPEN)
 			return -EBADFD;
-
--runtime->status は snd_pcm_mmap_status 型のメンバ
--[[linux-2.6.33/snd_pcm_mmap_status]]
-
--[[linux-2.6.33/SNDRV_PCM_STATE_OPEN]]

 		if (put_user(0, &_xferi->result))
 			return -EFAULT;
 		if (copy_from_user(&xferi, _xferi, sizeof(xferi)))
 			return -EFAULT;
-
--[[linux-2.6.33/put_user()]]
-
--[[linux-2.6.33/copy_from_user()]]

 		result = snd_pcm_lib_write(substream, xferi.buf, xferi.frames);
 		__put_user(result, &_xferi->result);
-
--[[linux-2.6.33/snd_pcm_lib_write()]]
-
--[[linux-2.6.33/__put_user()]]

 		return result < 0 ? result : 0;
 	}
 	case SNDRV_PCM_IOCTL_WRITEN_FRAMES:
 	{
 		struct snd_xfern xfern;
 		struct snd_xfern __user *_xfern = arg;
 		struct snd_pcm_runtime *runtime = substream->runtime;
 		void __user **bufs;
 		snd_pcm_sframes_t result;
-
--[[linux-2.6.33/SNDRV_PCM_IOCTL_WRITEN_FRAMES]]
-
--[[linux-2.6.33/snd_xfern]]

 		if (runtime->status->state == SNDRV_PCM_STATE_OPEN)
 			return -EBADFD;
 		if (runtime->channels > 128)
 			return -EINVAL;
 		if (put_user(0, &_xfern->result))
 			return -EFAULT;
 		if (copy_from_user(&xfern, _xfern, sizeof(xfern)))
 			return -EFAULT;
 
 		bufs = memdup_user(xfern.bufs,
 				   sizeof(void *) * runtime->channels);
 		if (IS_ERR(bufs))
 			return PTR_ERR(bufs);
-
--[[linux-2.6.33/memdup_user()]]
-
--[[linux-2.6.33/IS_ERR()]]
-
--[[linux-2.6.33/PTR_ERR()]]

 		result = snd_pcm_lib_writev(substream, bufs, xfern.frames);
 		kfree(bufs);
 		__put_user(result, &_xfern->result);
-
--[[linux-2.6.33/snd_pcm_lib_writev()]]
-
--[[linux-2.6.33/kfree()]]

 		return result < 0 ? result : 0;
 	}
 	case SNDRV_PCM_IOCTL_REWIND:
 	{
 		snd_pcm_uframes_t frames;
 		snd_pcm_uframes_t __user *_frames = arg;
 		snd_pcm_sframes_t result;
-
--[[linux-2.6.33/SNDRV_PCM_IOCTL_REWIND]]
-
--[[linux-2.6.33/snd_pcm_uframes_t]]

 		if (get_user(frames, _frames))
 			return -EFAULT;
 		if (put_user(0, _frames))
 			return -EFAULT;
 		result = snd_pcm_playback_rewind(substream, frames);
 		__put_user(result, _frames);
-
--[[linux-2.6.33/snd_pcm_playback_rewind()]]

 		return result < 0 ? result : 0;
 	}
 	case SNDRV_PCM_IOCTL_FORWARD:
 	{
 		snd_pcm_uframes_t frames;
 		snd_pcm_uframes_t __user *_frames = arg;
 		snd_pcm_sframes_t result;
-
--[[linux-2.6.33/SNDRV_PCM_IOCTL_FORWARD]]

 		if (get_user(frames, _frames))
 			return -EFAULT;
 		if (put_user(0, _frames))
 			return -EFAULT;
 		result = snd_pcm_playback_forward(substream, frames);
 		__put_user(result, _frames);
-
--[[linux-2.6.33/snd_pcm_playback_forward()]]

 		return result < 0 ? result : 0;
 	}
 	}
 	return snd_pcm_common_ioctl1(file, substream, cmd, arg);
-
--[[linux-2.6.33/snd_pcm_common_ioctl1()]]

 }


*コメント [#e770f748]

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS