jack: Write only valid values to the internal hw_ptr
PATCH 1/1 jack: Write only valid values to the internal hw_ptr
From: Timo Wischer <[email protected]>
Otherwise the ALSA thread could for example read a hw_ptr > buffer_size
jack/pcm_jack.c +7 -4
@@ -137,6 +137,7 @@ static int snd_pcm_jack_process_cb(jack_nframes_t nframes, snd_pcm_ioplug_t *io) { snd_pcm_jack_t *jack = io->private_data; +snd_pcm_uframes_t hw_ptr;const snd_pcm_channel_area_t *areas;snd_pcm_uframes_t xfer =0 ;unsigned int channel;
@@ -155,12 +156,13 @@ snd_pcm_jack_process_cb(jack_nframes_t nframes, snd_pcm_ioplug_t *io)return 0 ; } } - + + hw_ptr = jack->hw_ptr; areas =snd_pcm_ioplug_mmap_areas (io);while (xfer < nframes) {snd_pcm_uframes_t frames = nframes - xfer; -snd_pcm_uframes_t offset = jack->hw_ptr; +snd_pcm_uframes_t offset = hw_ptr;snd_pcm_uframes_t cont = io->buffer_size - offset;if (cont < frames)
@@ -173,10 +175,11 @@ snd_pcm_jack_process_cb(jack_nframes_t nframes, snd_pcm_ioplug_t *io)snd_pcm_area_copy (&areas[channel], offset, &jack->areas[channel], xfer, frames, io->format); } - jack->hw_ptr += frames; - jack->hw_ptr %= io->buffer_size; + hw_ptr += frames; + hw_ptr %= io->buffer_size; xfer += frames; } + jack->hw_ptr = hw_ptr;pcm_poll_unblock_check (io);/* unblock socket for polling if needed */
Signature · 1 line
2.7.4
Hello all,
any comments so far?
It would be great if someone could have a look
because I have some further fixes pending.
Best regards
Timo Wischer
Advanced Driver Information Technology GmbH
Engineering Software Base (ADITG/ESB)
Robert-Bosch-Str. 200
31139 Hildesheim
Germany
Tel. +49 5121 49 6938
Fax +49 5121 49 6999
[email protected]
ADIT is a joint venture company of Robert Bosch GmbH/Robert Bosch Car Multimedia GmbH and DENSO Corporation
Sitz: Hildesheim, Registergericht: Amtsgericht Hildesheim HRB 3438
Geschäftsführung: Wilhelm Grabow, Ken Yaguchi
________________________________________
From: Wischer, Timo (ADITG/ESB)
Sent: Monday, January 22, 2018 9:37 AM
To: [email protected]
Cc: [email protected]; Wischer, Timo (ADITG/ESB)
Subject: [PATCH - JACK PCM plugin] jack: Write only valid values to the internal hw_ptr
From: Timo Wischer <[email protected]>
Otherwise the ALSA thread could for example read a hw_ptr > buffer_size
jack/pcm_jack.c +7 -4
@@ -137,6 +137,7 @@ static int snd_pcm_jack_process_cb(jack_nframes_t nframes, snd_pcm_ioplug_t *io) { snd_pcm_jack_t *jack = io->private_data; +snd_pcm_uframes_t hw_ptr;const snd_pcm_channel_area_t *areas;snd_pcm_uframes_t xfer =0 ;unsigned int channel;
@@ -155,12 +156,13 @@ snd_pcm_jack_process_cb(jack_nframes_t nframes, snd_pcm_ioplug_t *io)return 0 ; } } - + + hw_ptr = jack->hw_ptr; areas =snd_pcm_ioplug_mmap_areas (io);while (xfer < nframes) {snd_pcm_uframes_t frames = nframes - xfer; -snd_pcm_uframes_t offset = jack->hw_ptr; +snd_pcm_uframes_t offset = hw_ptr;snd_pcm_uframes_t cont = io->buffer_size - offset;if (cont < frames)
@@ -173,10 +175,11 @@ snd_pcm_jack_process_cb(jack_nframes_t nframes, snd_pcm_ioplug_t *io)snd_pcm_area_copy (&areas[channel], offset, &jack->areas[channel], xfer, frames, io->format); } - jack->hw_ptr += frames; - jack->hw_ptr %= io->buffer_size; + hw_ptr += frames; + hw_ptr %= io->buffer_size; xfer += frames; } + jack->hw_ptr = hw_ptr;pcm_poll_unblock_check (io);/* unblock socket for polling if needed */
--
2.7.4
Dne 8.2.2018 v 09:49 Wischer, Timo (ADITG/ESB) napsal(a):
Quoted 3 lines
Hello all,
any comments so far?
The patch looks good. Applied. Thanks.
Jaroslav
Quoted 86 lines
It would be great if someone could have a look
because I have some further fixes pending.Best regards
Timo Wischer
Advanced Driver Information Technology GmbH
Engineering Software Base (ADITG/ESB)
Robert-Bosch-Str. 200
31139 Hildesheim
GermanyTel. +49 5121 49 6938
Fax +49 5121 49 6999
[email protected]ADIT is a joint venture company of Robert Bosch GmbH/Robert Bosch Car Multimedia GmbH and DENSO Corporation
Sitz: Hildesheim, Registergericht: Amtsgericht Hildesheim HRB 3438
Geschäftsführung: Wilhelm Grabow, Ken Yaguchi________________________________________
From: Wischer, Timo (ADITG/ESB)
Sent: Monday, January 22, 2018 9:37 AM
To: [email protected]
Cc: [email protected]; Wischer, Timo (ADITG/ESB)
Subject: [PATCH - JACK PCM plugin] jack: Write only valid values to the internalhw_ptrFrom: Timo Wischer <[email protected]>
Otherwise the ALSA thread could for example read a
hw_ptr>buffer_sizeSigned-off-by Timo Wischer <[email protected]>jack/pcm_jack.c +7
-5@@ -137,6 +137,7 @@ static int snd_pcm_jack_process_cb(jack_nframes_t nframes, snd_pcm_ioplug_t *io) { snd_pcm_jack_t *jack = io->private_data; +snd_pcm_uframes_t hw_ptr;const snd_pcm_channel_area_t *areas;snd_pcm_uframes_t xfer =0 ;unsigned int channel;@@ -155,12 +156,13 @@ snd_pcm_jack_process_cb(jack_nframes_t nframes, snd_pcm_ioplug_t *io)return 0 ; } } - + + hw_ptr = jack->hw_ptr; areas =snd_pcm_ioplug_mmap_areas (io);while (xfer < nframes) {snd_pcm_uframes_t frames = nframes - xfer; -snd_pcm_uframes_t offset = jack->hw_ptr; +snd_pcm_uframes_t offset = hw_ptr;snd_pcm_uframes_t cont = io->buffer_size - offset;if (cont < frames)@@ -173,10 +175,11 @@ snd_pcm_jack_process_cb(jack_nframes_t nframes, snd_pcm_ioplug_t *io)snd_pcm_area_copy (&areas[channel], offset, &jack->areas[channel], xfer, frames, io->format); } - jack->hw_ptr += frames; - jack->hw_ptr %= io->buffer_size; + hw_ptr += frames; + hw_ptr %= io->buffer_size; xfer += frames; } + jack->hw_ptr = hw_ptr;pcm_poll_unblock_check (io);/* unblock socket for polling if needed */ --2.7.4
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Signature · 6 lines
Jaroslav Kysela <[email protected]> Linux Sound Maintainer; ALSA Project; Red Hat, Inc. _______________________________________________ Alsa-devel mailing list [email protected] http://mailman.alsa-project.org/mailman/listinfo/alsa-devel