Lines 72-78
Link Here
|
72 |
return result / oss->frame_bytes; |
72 |
return result / oss->frame_bytes; |
73 |
} |
73 |
} |
74 |
|
74 |
|
75 |
@@ -67,24 +101,60 @@ static snd_pcm_sframes_t oss_read(snd_pcm_ioplug_t *io |
75 |
@@ -67,24 +101,66 @@ static snd_pcm_sframes_t oss_read(snd_pcm_ioplug_t *io |
76 |
buf = (char *)areas->addr + (areas->first + areas->step * offset) / 8; |
76 |
buf = (char *)areas->addr + (areas->first + areas->step * offset) / 8; |
77 |
size *= oss->frame_bytes; |
77 |
size *= oss->frame_bytes; |
78 |
result = read(oss->fd, buf, size); |
78 |
result = read(oss->fd, buf, size); |
Lines 103-108
Link Here
|
103 |
- int ptr; |
103 |
- int ptr; |
104 |
+ audio_buf_info bi; |
104 |
+ audio_buf_info bi; |
105 |
+ ssize_t bytes; |
105 |
+ ssize_t bytes; |
|
|
106 |
+ ssize_t total; |
106 |
|
107 |
|
107 |
- if (ioctl(oss->fd, io->stream == SND_PCM_STREAM_PLAYBACK ? |
108 |
- if (ioctl(oss->fd, io->stream == SND_PCM_STREAM_PLAYBACK ? |
108 |
- SNDCTL_DSP_GETOPTR : SNDCTL_DSP_GETIPTR, &info) < 0) { |
109 |
- SNDCTL_DSP_GETOPTR : SNDCTL_DSP_GETIPTR, &info) < 0) { |
Lines 132-149
Link Here
|
132 |
+ if (io->stream == SND_PCM_STREAM_PLAYBACK) |
133 |
+ if (io->stream == SND_PCM_STREAM_PLAYBACK) |
133 |
+ bi.bytes = oss->bufsz - bi.bytes; |
134 |
+ bi.bytes = oss->bufsz - bi.bytes; |
134 |
+ |
135 |
+ |
|
|
136 |
+ /* ALSA and OSS may use different buffer sizes */ |
137 |
+ total = io->buffer_size * oss->frame_bytes; |
138 |
+ if (bi.bytes > total) |
139 |
+ bi.bytes = total; |
140 |
+ |
135 |
+ /* |
141 |
+ /* |
136 |
+ * Return exactly how many bytes can be read or written, |
142 |
+ * Return exactly how many bytes can be read or written, |
137 |
+ * relative to the current application pointer. |
143 |
+ * relative to the current application pointer. |
138 |
+ */ |
144 |
+ */ |
139 |
+ bytes = snd_pcm_frames_to_bytes(io->pcm, io->appl_ptr) + bi.bytes; |
145 |
+ bytes = snd_pcm_frames_to_bytes(io->pcm, io->appl_ptr) + bi.bytes; |
140 |
+ bytes %= io->buffer_size * oss->frame_bytes; |
146 |
+ bytes %= total; |
141 |
+ |
147 |
+ |
142 |
+ return snd_pcm_bytes_to_frames(io->pcm, bytes); |
148 |
+ return snd_pcm_bytes_to_frames(io->pcm, bytes); |
143 |
} |
149 |
} |
144 |
|
150 |
|
145 |
static int oss_start(snd_pcm_ioplug_t *io) |
151 |
static int oss_start(snd_pcm_ioplug_t *io) |
146 |
@@ -93,12 +163,23 @@ static int oss_start(snd_pcm_ioplug_t *io) |
152 |
@@ -93,12 +169,23 @@ static int oss_start(snd_pcm_ioplug_t *io) |
147 |
int tmp = io->stream == SND_PCM_STREAM_PLAYBACK ? |
153 |
int tmp = io->stream == SND_PCM_STREAM_PLAYBACK ? |
148 |
PCM_ENABLE_OUTPUT : PCM_ENABLE_INPUT; |
154 |
PCM_ENABLE_OUTPUT : PCM_ENABLE_INPUT; |
149 |
|
155 |
|
Lines 167-173
Link Here
|
167 |
return 0; |
173 |
return 0; |
168 |
} |
174 |
} |
169 |
|
175 |
|
170 |
@@ -107,6 +188,10 @@ static int oss_stop(snd_pcm_ioplug_t *io) |
176 |
@@ -107,6 +194,10 @@ static int oss_stop(snd_pcm_ioplug_t *io) |
171 |
snd_pcm_oss_t *oss = io->private_data; |
177 |
snd_pcm_oss_t *oss = io->private_data; |
172 |
int tmp = 0; |
178 |
int tmp = 0; |
173 |
|
179 |
|
Lines 178-184
Link Here
|
178 |
ioctl(oss->fd, SNDCTL_DSP_SETTRIGGER, &tmp); |
184 |
ioctl(oss->fd, SNDCTL_DSP_SETTRIGGER, &tmp); |
179 |
return 0; |
185 |
return 0; |
180 |
} |
186 |
} |
181 |
@@ -115,101 +200,176 @@ static int oss_drain(snd_pcm_ioplug_t *io) |
187 |
@@ -115,101 +206,176 @@ static int oss_drain(snd_pcm_ioplug_t *io) |
182 |
{ |
188 |
{ |
183 |
snd_pcm_oss_t *oss = io->private_data; |
189 |
snd_pcm_oss_t *oss = io->private_data; |
184 |
|
190 |
|
Lines 420-426
Link Here
|
420 |
if ((flags = fcntl(oss->fd, F_GETFL)) < 0) { |
426 |
if ((flags = fcntl(oss->fd, F_GETFL)) < 0) { |
421 |
err = -errno; |
427 |
err = -errno; |
422 |
perror("F_GETFL"); |
428 |
perror("F_GETFL"); |
423 |
@@ -229,16 +389,148 @@ static int oss_hw_params(snd_pcm_ioplug_t *io, |
429 |
@@ -229,16 +395,148 @@ static int oss_hw_params(snd_pcm_ioplug_t *io, |
424 |
return 0; |
430 |
return 0; |
425 |
} |
431 |
} |
426 |
|
432 |
|
Lines 571-577
Link Here
|
571 |
unsigned int format[5]; |
577 |
unsigned int format[5]; |
572 |
unsigned int nchannels; |
578 |
unsigned int nchannels; |
573 |
unsigned int channel[6]; |
579 |
unsigned int channel[6]; |
574 |
@@ -317,6 +609,7 @@ static int oss_hw_constraint(snd_pcm_oss_t *oss) |
580 |
@@ -317,6 +615,7 @@ static int oss_hw_constraint(snd_pcm_oss_t *oss) |
575 |
return err; |
581 |
return err; |
576 |
|
582 |
|
577 |
return 0; |
583 |
return 0; |
Lines 579-585
Link Here
|
579 |
} |
585 |
} |
580 |
|
586 |
|
581 |
|
587 |
|
582 |
@@ -324,6 +617,10 @@ static int oss_close(snd_pcm_ioplug_t *io) |
588 |
@@ -324,6 +623,10 @@ static int oss_close(snd_pcm_ioplug_t *io) |
583 |
{ |
589 |
{ |
584 |
snd_pcm_oss_t *oss = io->private_data; |
590 |
snd_pcm_oss_t *oss = io->private_data; |
585 |
|
591 |
|
Lines 590-596
Link Here
|
590 |
close(oss->fd); |
596 |
close(oss->fd); |
591 |
free(oss->device); |
597 |
free(oss->device); |
592 |
free(oss); |
598 |
free(oss); |
593 |
@@ -337,8 +634,8 @@ static const snd_pcm_ioplug_callback_t oss_playback_ca |
599 |
@@ -337,8 +640,8 @@ static const snd_pcm_ioplug_callback_t oss_playback_ca |
594 |
.pointer = oss_pointer, |
600 |
.pointer = oss_pointer, |
595 |
.close = oss_close, |
601 |
.close = oss_close, |
596 |
.hw_params = oss_hw_params, |
602 |
.hw_params = oss_hw_params, |
Lines 600-606
Link Here
|
600 |
}; |
606 |
}; |
601 |
|
607 |
|
602 |
static const snd_pcm_ioplug_callback_t oss_capture_callback = { |
608 |
static const snd_pcm_ioplug_callback_t oss_capture_callback = { |
603 |
@@ -348,8 +645,8 @@ static const snd_pcm_ioplug_callback_t oss_capture_cal |
609 |
@@ -348,8 +651,8 @@ static const snd_pcm_ioplug_callback_t oss_capture_cal |
604 |
.pointer = oss_pointer, |
610 |
.pointer = oss_pointer, |
605 |
.close = oss_close, |
611 |
.close = oss_close, |
606 |
.hw_params = oss_hw_params, |
612 |
.hw_params = oss_hw_params, |
Lines 610-616
Link Here
|
610 |
}; |
616 |
}; |
611 |
|
617 |
|
612 |
|
618 |
|
613 |
@@ -360,6 +657,10 @@ SND_PCM_PLUGIN_DEFINE_FUNC(oss) |
619 |
@@ -360,6 +663,10 @@ SND_PCM_PLUGIN_DEFINE_FUNC(oss) |
614 |
int err; |
620 |
int err; |
615 |
snd_pcm_oss_t *oss; |
621 |
snd_pcm_oss_t *oss; |
616 |
|
622 |
|