Lines Matching refs:pcm

83 static int set_params(struct pcm *pcm)  in set_params()  argument
90 unsigned int requestedRate = pcm->rate; in set_params()
91 int channels = (pcm->flags & PCM_MONO) ? 1 : ((pcm->flags & PCM_5POINT1)? 6 : 2 ); in set_params()
102 … (pcm->flags & PCM_MMAP)? SNDRV_PCM_ACCESS_MMAP_INTERLEAVED : SNDRV_PCM_ACCESS_RW_INTERLEAVED); in set_params()
103 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT, pcm->format); in set_params()
112 pcm->channels * 16); in set_params()
114 pcm->channels); in set_params()
115 param_set_int(params, SNDRV_PCM_HW_PARAM_RATE, pcm->rate); in set_params()
116 param_set_hw_refine(pcm, params); in set_params()
118 if (param_set_hw_params(pcm, params)) { in set_params()
125 pcm->buffer_size = pcm_buffer_size(params); in set_params()
126 pcm->period_size = pcm_period_size(params); in set_params()
127 pcm->period_cnt = pcm->buffer_size/pcm->period_size; in set_params()
129 fprintf (stderr,"period_cnt = %d\n", pcm->period_cnt); in set_params()
130 fprintf (stderr,"period_size = %d\n", pcm->period_size); in set_params()
131 fprintf (stderr,"buffer_size = %d\n", pcm->buffer_size); in set_params()
142 sparams->avail_min = pcm->period_size/(channels * 2) ; in set_params()
143 sparams->start_threshold = pcm->period_size/(channels * 2) ; in set_params()
144 sparams->stop_threshold = pcm->buffer_size ; in set_params()
145 sparams->xfer_align = pcm->period_size/(channels * 2) ; /* needed for old kernels */ in set_params()
150 if (param_set_sw_params(pcm, sparams)) { in set_params()
167 struct pcm *pcm; in play_file() local
196 pcm = pcm_open(flags, device); in play_file()
197 if (pcm < 0) in play_file()
198 return pcm; in play_file()
200 if (!pcm_ready(pcm)) { in play_file()
201 pcm_close(pcm); in play_file()
209 if (ioctl(pcm->fd, SNDRV_COMPRESS_GET_CAPS, &compr_cap)) { in play_file()
211 pcm_close(pcm); in play_file()
227 if (ioctl(pcm->fd, SNDRV_COMPRESS_SET_PARAMS, &compr_params)) { in play_file()
229 pcm_close(pcm); in play_file()
234 pcm->channels = channels; in play_file()
235 pcm->rate = rate; in play_file()
236 pcm->flags = flags; in play_file()
237 pcm->format = format; in play_file()
238 if (set_params(pcm)) { in play_file()
240 pcm_close(pcm); in play_file()
245 if (pcm_prepare(pcm)) { in play_file()
247 pcm_close(pcm); in play_file()
250 if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_START)) { in play_file()
252 pcm_close(pcm); in play_file()
262 struct snd_pcm_sync_ptr *sync_ptr1 = pcm->sync_ptr; in play_file()
263 if (mmap_buffer(pcm)) { in play_file()
265 pcm_close(pcm); in play_file()
268 if (pcm_prepare(pcm)) { in play_file()
270 pcm_close(pcm); in play_file()
274 bufsize = pcm->period_size; in play_file()
278 pfd[0].fd = pcm->timer_fd; in play_file()
281 frames = (pcm->flags & PCM_MONO) ? (bufsize / 2) : (bufsize / 4); in play_file()
283 if (!pcm->running) { in play_file()
284 if (pcm_prepare(pcm)) { in play_file()
286 pcm_close(pcm); in play_file()
289 pcm->running = 1; in play_file()
293pcm->sync_ptr->flags = SNDRV_PCM_SYNC_PTR_APPL | SNDRV_PCM_SYNC_PTR_AVAIL_MIN;//SNDRV_PCM_SYNC_PTR… in play_file()
294 err = sync_ptr(pcm); in play_file()
298 pcm->underruns++; in play_file()
299 pcm->running = 0; in play_file()
306 avail = pcm_avail(pcm); in play_file()
309 pcm_close(pcm); in play_file()
312 if (avail < pcm->sw_p->avail_min) { in play_file()
321 dst_addr = dst_address(pcm); in play_file()
327 pcm->sync_ptr->s.status.hw_ptr, in play_file()
328 pcm->buffer_size, in play_file()
329 pcm->sync_ptr->c.control.appl_ptr); in play_file()
341 frames = (pcm->flags & PCM_MONO) ? (remainingData / 2) : (remainingData / 4); in play_file()
361 pcm->sync_ptr->c.control.appl_ptr += frames; in play_file()
362 pcm->sync_ptr->flags = 0; in play_file()
364 err = sync_ptr(pcm); in play_file()
368 pcm->underruns++; in play_file()
369 pcm->running = 0; in play_file()
375 pcm->sync_ptr->s.status.hw_ptr, in play_file()
376 pcm->sync_ptr->c.control.appl_ptr); in play_file()
380 if (ioctl(pcm->fd, SNDRV_COMPRESS_TSTAMP, &tstamp)) in play_file()
393 if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_START)) { in play_file()
398 pcm->underruns++; in play_file()
399 pcm->running = 0; in play_file()
403 pcm_close(pcm); in play_file()
413pcm->sync_ptr->flags = SNDRV_PCM_SYNC_PTR_APPL | SNDRV_PCM_SYNC_PTR_AVAIL_MIN;//SNDRV_PCM_SYNC_PTR… in play_file()
414 sync_ptr(pcm); in play_file()
419 if (pcm->sync_ptr->s.status.hw_ptr >= pcm->sync_ptr->c.control.appl_ptr) { in play_file()
421 pcm->sync_ptr->s.status.hw_ptr, in play_file()
422 pcm->sync_ptr->c.control.appl_ptr); in play_file()
428 if (pcm_prepare(pcm)) { in play_file()
430 pcm_close(pcm); in play_file()
434 bufsize = pcm->period_size; in play_file()
439 pcm_close(pcm); in play_file()
449 if (pcm_write(pcm, data, bufsize)){ in play_file()
452 pcm_close(pcm); in play_file()
468 pcm_close(pcm); in play_file()