@@ -632,6 +632,13 @@ static long snd_pcm_alsa_frames(struct snd_pcm_substream *substream, long bytes)
632632 return bytes_to_frames (runtime , (buffer_size * bytes ) / runtime -> oss .buffer_bytes );
633633}
634634
635+ static inline
636+ snd_pcm_uframes_t get_hw_ptr_period (struct snd_pcm_runtime * runtime )
637+ {
638+ snd_pcm_uframes_t ptr = runtime -> status -> hw_ptr ;
639+ return ptr - (ptr % runtime -> period_size );
640+ }
641+
635642/* define extended formats in the recent OSS versions (if any) */
636643/* linear formats */
637644#define AFMT_S32_LE 0x00001000
@@ -1102,7 +1109,7 @@ static int snd_pcm_oss_prepare(struct snd_pcm_substream *substream)
11021109 return err ;
11031110 }
11041111 runtime -> oss .prepare = 0 ;
1105- runtime -> oss .prev_hw_ptr_interrupt = 0 ;
1112+ runtime -> oss .prev_hw_ptr_period = 0 ;
11061113 runtime -> oss .period_ptr = 0 ;
11071114 runtime -> oss .buffer_used = 0 ;
11081115
@@ -1950,7 +1957,8 @@ static int snd_pcm_oss_get_caps(struct snd_pcm_oss_file *pcm_oss_file)
19501957 return result ;
19511958}
19521959
1953- static void snd_pcm_oss_simulate_fill (struct snd_pcm_substream * substream , snd_pcm_uframes_t hw_ptr )
1960+ static void snd_pcm_oss_simulate_fill (struct snd_pcm_substream * substream ,
1961+ snd_pcm_uframes_t hw_ptr )
19541962{
19551963 struct snd_pcm_runtime * runtime = substream -> runtime ;
19561964 snd_pcm_uframes_t appl_ptr ;
@@ -1986,7 +1994,8 @@ static int snd_pcm_oss_set_trigger(struct snd_pcm_oss_file *pcm_oss_file, int tr
19861994 if (runtime -> oss .trigger )
19871995 goto _skip1 ;
19881996 if (atomic_read (& psubstream -> mmap_count ))
1989- snd_pcm_oss_simulate_fill (psubstream , runtime -> hw_ptr_interrupt );
1997+ snd_pcm_oss_simulate_fill (psubstream ,
1998+ get_hw_ptr_period (runtime ));
19901999 runtime -> oss .trigger = 1 ;
19912000 runtime -> start_threshold = 1 ;
19922001 cmd = SNDRV_PCM_IOCTL_START ;
@@ -2105,11 +2114,12 @@ static int snd_pcm_oss_get_ptr(struct snd_pcm_oss_file *pcm_oss_file, int stream
21052114 info .ptr = snd_pcm_oss_bytes (substream , runtime -> status -> hw_ptr % runtime -> buffer_size );
21062115 if (atomic_read (& substream -> mmap_count )) {
21072116 snd_pcm_sframes_t n ;
2108- n = (delay = runtime -> hw_ptr_interrupt ) - runtime -> oss .prev_hw_ptr_interrupt ;
2117+ delay = get_hw_ptr_period (runtime );
2118+ n = delay - runtime -> oss .prev_hw_ptr_period ;
21092119 if (n < 0 )
21102120 n += runtime -> boundary ;
21112121 info .blocks = n / runtime -> period_size ;
2112- runtime -> oss .prev_hw_ptr_interrupt = delay ;
2122+ runtime -> oss .prev_hw_ptr_period = delay ;
21132123 if (substream -> stream == SNDRV_PCM_STREAM_PLAYBACK )
21142124 snd_pcm_oss_simulate_fill (substream , delay );
21152125 info .bytes = snd_pcm_oss_bytes (substream , runtime -> status -> hw_ptr ) & INT_MAX ;
@@ -2673,18 +2683,22 @@ static int snd_pcm_oss_playback_ready(struct snd_pcm_substream *substream)
26732683{
26742684 struct snd_pcm_runtime * runtime = substream -> runtime ;
26752685 if (atomic_read (& substream -> mmap_count ))
2676- return runtime -> oss .prev_hw_ptr_interrupt != runtime -> hw_ptr_interrupt ;
2686+ return runtime -> oss .prev_hw_ptr_period !=
2687+ get_hw_ptr_period (runtime );
26772688 else
2678- return snd_pcm_playback_avail (runtime ) >= runtime -> oss .period_frames ;
2689+ return snd_pcm_playback_avail (runtime ) >=
2690+ runtime -> oss .period_frames ;
26792691}
26802692
26812693static int snd_pcm_oss_capture_ready (struct snd_pcm_substream * substream )
26822694{
26832695 struct snd_pcm_runtime * runtime = substream -> runtime ;
26842696 if (atomic_read (& substream -> mmap_count ))
2685- return runtime -> oss .prev_hw_ptr_interrupt != runtime -> hw_ptr_interrupt ;
2697+ return runtime -> oss .prev_hw_ptr_period !=
2698+ get_hw_ptr_period (runtime );
26862699 else
2687- return snd_pcm_capture_avail (runtime ) >= runtime -> oss .period_frames ;
2700+ return snd_pcm_capture_avail (runtime ) >=
2701+ runtime -> oss .period_frames ;
26882702}
26892703
26902704static unsigned int snd_pcm_oss_poll (struct file * file , poll_table * wait )
0 commit comments