From patchwork Tue May 5 13:25:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 283382 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1259BC47258 for ; Tue, 5 May 2020 13:34:14 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D0991206FA for ; Tue, 5 May 2020 13:34:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="N6yIwQow" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D0991206FA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:40314 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jVxi8-0006K8-R1 for qemu-devel@archiver.kernel.org; Tue, 05 May 2020 09:34:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46282) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jVxaL-0005s1-Lt for qemu-devel@nongnu.org; Tue, 05 May 2020 09:26:09 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:54015) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jVxaK-0001l9-NP for qemu-devel@nongnu.org; Tue, 05 May 2020 09:26:09 -0400 Received: by mail-wm1-x341.google.com with SMTP id k12so2288430wmj.3 for ; Tue, 05 May 2020 06:26:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oqvwShux9LDNmahM4qg2/vpiuCh8jcL3zHNsGjzvE7U=; b=N6yIwQowLQUHtdJt/xYFpn9ccEoNmRmI8q6vcIqGCq1RteQJk+fXlXmVrSeFR54UZD BJ9kTUbpk+YhCR06/SBp+smklA894p6XqOyGvp3JDrrLS9Gib9nb5lDsSaCpwYuQs2sk yEUHaRdXdnKW5hxz7qETI+iIxjhSF9sKwpCWDThJbBSaFB7Acksk0dK8odHCn8tbOyVd H1Ar3dby52L00NUwf4IOCi2AQo8veeASqxsz/GoVOVjJ8c8CMIa1sIVGp/CLVmayQK5Y beQ2LmXzk/1s3mpjwwjo/ySb9opfQlEjbtTbeR1ndahqKVTttHcHluPZyM9Nuv+y84mH yn8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=oqvwShux9LDNmahM4qg2/vpiuCh8jcL3zHNsGjzvE7U=; b=uhfC2lrqmsLfyyapkxvGL+niWLuePrVYD+PMH4Ngf8MDibcFVS3icMOSSi4sMt/xMx izZtyu6QKM3nrM17GRLOxHlcbhvNQc08RYF3ISDSjYqo9wifjnF2VhjI1eCc8/JvRPCX SPWne20e0IM9mDRddTMZVkhoV5unpuh2NIFKnS0wsR9Dq84nxzmW//SN523zhQXgbyoa ocO1bbMYlhBMx9tsTUy3S/JFSGKBTYrLdQjJ15fTFK+Gl0b/4SWKwZo+hPcfNg1i2C3N u9ujLd5slGU43rZZECVUoMhkN0754XJhzh9z5AQF2dNWc55t2X9EDYC9Ton65cgmy9Se J8Ng== X-Gm-Message-State: AGi0PuauULJi92RKU9kbkBhTlFRzkUFLG3JjIxS+D94F4JBoZp9N8IHW LR6qI23cjhEY+J5OsUXYVf81u+HG X-Google-Smtp-Source: APiQypJnNx2njHHEiZuDoGYrdLC8jwzQ8cx+QCP55qWw/MbJEND6BnjGhDc7w82/K48EFOZntt6YbA== X-Received: by 2002:a05:600c:2255:: with SMTP id a21mr3548134wmm.150.1588685166817; Tue, 05 May 2020 06:26:06 -0700 (PDT) Received: from x1w.redhat.com (26.red-88-21-207.staticip.rima-tde.net. [88.21.207.26]) by smtp.gmail.com with ESMTPSA id n6sm3427424wrs.81.2020.05.05.06.26.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 May 2020 06:26:06 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 1/7] audio: Let audio_sample_to_uint64() use const samples argument Date: Tue, 5 May 2020 15:25:57 +0200 Message-Id: <20200505132603.8575-2-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200505132603.8575-1-f4bug@amsat.org> References: <20200505132603.8575-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::341; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x341.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Volker_R=C3=BCmelin?= , Gerd Hoffmann , =?utf-8?b?S8WRdsOhZ8OzIFpvbHTDoW4=?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The samples are the input to convert to u64. As we should not modify them, mark the argument const. Signed-off-by: Philippe Mathieu-Daudé --- audio/audio.h | 2 +- audio/mixeng.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/audio/audio.h b/audio/audio.h index 0db3c7dd5e..f27a12298f 100644 --- a/audio/audio.h +++ b/audio/audio.h @@ -163,7 +163,7 @@ int wav_start_capture(AudioState *state, CaptureState *s, const char *path, bool audio_is_cleaning_up(void); void audio_cleanup(void); -void audio_sample_to_uint64(void *samples, int pos, +void audio_sample_to_uint64(const void *samples, int pos, uint64_t *left, uint64_t *right); void audio_sample_from_uint64(void *samples, int pos, uint64_t left, uint64_t right); diff --git a/audio/mixeng.c b/audio/mixeng.c index 739a500449..75f000e49f 100644 --- a/audio/mixeng.c +++ b/audio/mixeng.c @@ -338,10 +338,10 @@ f_sample *mixeng_clip_float[2] = { clip_natural_float_from_stereo, }; -void audio_sample_to_uint64(void *samples, int pos, +void audio_sample_to_uint64(const void *samples, int pos, uint64_t *left, uint64_t *right) { - struct st_sample *sample = samples; + const struct st_sample *sample = samples; sample += pos; #ifdef FLOAT_MIXENG error_report( From patchwork Tue May 5 13:26:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 283381 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8EE7AC47247 for ; Tue, 5 May 2020 13:36:23 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 580B2206A5 for ; Tue, 5 May 2020 13:36:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UJlbfFnR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 580B2206A5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:45566 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jVxkE-00008X-CT for qemu-devel@archiver.kernel.org; Tue, 05 May 2020 09:36:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46302) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jVxaO-0005vn-Ik for qemu-devel@nongnu.org; Tue, 05 May 2020 09:26:12 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:54016) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jVxaN-000255-Rg for qemu-devel@nongnu.org; Tue, 05 May 2020 09:26:12 -0400 Received: by mail-wm1-x341.google.com with SMTP id k12so2288658wmj.3 for ; Tue, 05 May 2020 06:26:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cGQyVlItBWg+QMCBMM+TrrsDfjaKkcl5GXGLKiX+zsQ=; b=UJlbfFnRKlo08E6WJSlA71vOjywdkQaq8JSMrcJFkLurvuD973FqV9NTTSz5Pfy1bB 4Zm7yZudlNVXRl/QprENSqpS4x0AbPD60mBuwQSLRtiYKtpz9IX4hFYgCAWg80bSJL3l lzNiYrc4o8gRF5v3twMs+GAqVH7RMDpn/KC4MkA+A7ICzhQSJmks5eriF8Yz5JxDdnv3 QYGsWO7FXLRRfC+OqwvUFuwAqVtGVV4ESHPEWeVVUEvM6Yaio+7ZJxXYDWDEy8+JOloj KjtkSLQ3PfFBvpOFEl2M3JSR8qOX9jKK9/7etYtXKadYfGI0wq4fkQYtRPfkVpeEpmQC rG5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=cGQyVlItBWg+QMCBMM+TrrsDfjaKkcl5GXGLKiX+zsQ=; b=FYWqCeV/Cnot+sWWxL9Mc6nCYewK+h7rvOnR5l9b1tjX7F9xm54TPd+yABTFg4wtfa //XuSIgWgMJ66JVZMEY1RTbKJh+oMFsVwv/06JxrPv6LXN4tEZpSmKKvYtBbTx5zJkgc n0CTsSiMYesOZDEXAjgY7tvnFE0lnWKVYuVOGYlkdWGG7ODQ7c1U4sC65wLWsXMz8hoZ 3YpEIWEhOVM7MkoYO6FGdGYheIG3MNgk/09d96KHdZDq2oBd/pKoS7X4ESuSAslXnpbB AbobPcCXS7ssXlJlFVL42enivbzwbJ7ubduk/OXJmHUMUlxgE9PV79BFy+/UCSGw6Bhs 1kGw== X-Gm-Message-State: AGi0PubLO9riENjKbJoJ7IyhDoSzgw7M+qoHhQ/anxT8Qs/LoF/c2PN8 BvUVM8NXDxMrjOE1eiugG2gLbILz X-Google-Smtp-Source: APiQypLJ/z+3NkSEkmxOy4PTp0XwOVusVsKCgTEjSFF/yKI03zb6t0HWCfth41qc8Mm86GY4ej/2ow== X-Received: by 2002:a7b:c104:: with SMTP id w4mr3495155wmi.8.1588685170316; Tue, 05 May 2020 06:26:10 -0700 (PDT) Received: from x1w.redhat.com (26.red-88-21-207.staticip.rima-tde.net. [88.21.207.26]) by smtp.gmail.com with ESMTPSA id n6sm3427424wrs.81.2020.05.05.06.26.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 May 2020 06:26:09 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 4/7] audio: Split advance() helper as in() and out() Date: Tue, 5 May 2020 15:26:00 +0200 Message-Id: <20200505132603.8575-5-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200505132603.8575-1-f4bug@amsat.org> References: <20200505132603.8575-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::341; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x341.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Volker_R=C3=BCmelin?= , Gerd Hoffmann , =?utf-8?b?S8WRdsOhZ8OzIFpvbHTDoW4=?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" When the buffer is to be filled, rename as advance_in(). When the buffer is already filled, use advance_out(). Signed-off-by: Philippe Mathieu-Daudé --- audio/audio_int.h | 8 +++++++- audio/alsaaudio.c | 4 ++-- audio/audio.c | 2 +- audio/ossaudio.c | 4 ++-- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/audio/audio_int.h b/audio/audio_int.h index fb6947c435..62829de4e8 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -255,12 +255,18 @@ static inline size_t audio_ring_dist(size_t dst, size_t src, size_t len) return (dst >= src) ? (dst - src) : (len - src + dst); } -static inline void *advance(void *p, int incr) +static inline void *advance_in(void *p, int incr) { uint8_t *d = p; return d + incr; } +static inline const void *advance_out(const void *p, int incr) +{ + const uint8_t *d = p; + return d + incr; +} + #define dolog(fmt, ...) AUD_log(AUDIO_CAP, fmt, ## __VA_ARGS__) #ifdef DEBUG diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index a8e62542f9..a32db8ff39 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -615,7 +615,7 @@ static size_t alsa_write(HWVoiceOut *hw, void *buf, size_t len) size_t len_frames = len / hw->info.bytes_per_frame; while (len_frames) { - char *src = advance(buf, pos); + const char *src = advance_out(buf, pos); snd_pcm_sframes_t written; written = snd_pcm_writei(alsa->handle, src, len_frames); @@ -809,7 +809,7 @@ static size_t alsa_read(HWVoiceIn *hw, void *buf, size_t len) size_t pos = 0; while (len) { - void *dst = advance(buf, pos); + void *dst = advance_in(buf, pos); snd_pcm_sframes_t nread; nread = snd_pcm_readi( diff --git a/audio/audio.c b/audio/audio.c index 7a9e680355..c75455bbb5 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -571,7 +571,7 @@ static void audio_pcm_hw_clip_out(HWVoiceOut *hw, void *pcm_buf, size_t len) while (len) { st_sample *src = hw->mix_buf->samples + pos; - uint8_t *dst = advance(pcm_buf, clipped * hw->info.bytes_per_frame); + uint8_t *dst = advance_in(pcm_buf, clipped * hw->info.bytes_per_frame); size_t samples_till_end_of_buf = hw->mix_buf->size - pos; size_t samples_to_clip = MIN(len, samples_till_end_of_buf); diff --git a/audio/ossaudio.c b/audio/ossaudio.c index f88d076ec2..7778138df5 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -439,7 +439,7 @@ static size_t oss_write(HWVoiceOut *hw, void *buf, size_t len) pos = 0; while (len) { ssize_t bytes_written; - void *pcm = advance(buf, pos); + const void *pcm = advance_out(buf, pos); bytes_written = write(oss->fd, pcm, len); if (bytes_written < 0) { @@ -678,7 +678,7 @@ static size_t oss_read(HWVoiceIn *hw, void *buf, size_t len) while (len) { ssize_t nread; - void *dst = advance(buf, pos); + void *dst = advance_in(buf, pos); nread = read(oss->fd, dst, len); if (nread == -1) { From patchwork Tue May 5 13:26:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 283380 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 517F1C47247 for ; Tue, 5 May 2020 13:37:38 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0A0FF206A5 for ; Tue, 5 May 2020 13:37:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VgDI4E9Z" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0A0FF206A5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:49910 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jVxlR-0001yX-7Z for qemu-devel@archiver.kernel.org; Tue, 05 May 2020 09:37:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46310) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jVxaQ-00060V-Gp for qemu-devel@nongnu.org; Tue, 05 May 2020 09:26:14 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:39492) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jVxaP-0002Gd-AY for qemu-devel@nongnu.org; Tue, 05 May 2020 09:26:14 -0400 Received: by mail-wm1-x343.google.com with SMTP id y24so2326746wma.4 for ; Tue, 05 May 2020 06:26:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sBpc5qlzjGqkmrHk8rD3OooXVUoJuabxAfTsEBnyYZk=; b=VgDI4E9Zz2O4SFW1sz6gdFVSrJAMPiBrsfnkIYykLC+HNBRqyY9F32EoJqUSKw6OSU X43aGmUUsMceYu27PQW72vtsKsauyTdTZCX8PWPFJyboV/Xouga0Xw+ohFn5phCMJ9qQ PKZUkFpH4XEJtKyIgtcKinpsOg55+zCz/qI5NLawk1+z6i7tG6k6060ZYOisbbsk2I/T kQ+xhOS0ysJzaLtn/WMpvMdHBvDKagoPioUOy9rS4etjKS1nP8O2uKzA2scUBzhdaeY4 GgcoxiCpcVKLLHK4WC33/KWoHbGkSvZxACinU9oEaTCTP0jj90Emi7hPe5VdZxGBJvGU g/Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=sBpc5qlzjGqkmrHk8rD3OooXVUoJuabxAfTsEBnyYZk=; b=mPU1dqggck7eMH0/DMnY+LCT4f6V3+YJWbZMiig8x+teivzWFRbzVEAMKl1sPeEk8Y SUqvv/LkFVEYxMJyy8dYNHpSLZ0pfR3xoaLIL5mzimvPsprROZTym0iynzpMsyut4gVi AKw4mKzLsuOoIM3NUyTYtjg2iw2fHMfINvPP53Kzr37+nBbYaTFLlXPrl371xfDcb2YS zTvZ3OqsTut5UtWy10+/gve2WGVnlRRt446Ie3+/73l1AIobUfB4vcAN9R9Hi8qZ2QOq /OHskr/rEmrnPeL+OzW5FEsHGVyfsQeUDLqwZrOdZO45hd+EYaMaHvgFN62zBfKufaQP X23Q== X-Gm-Message-State: AGi0Pua2TcdWMkIJ1gGyp93vdr7+0j1dM5ZLpopQXxSpdbYIW/27O/Dn IjfF2W5Z50K/UtV2xT+fGtuOwUNu X-Google-Smtp-Source: APiQypIKXOPRrVr8kimDuwztc2W8JAGeGxvUPRDvJi40iYhBxMRz4/xBaz8MJNvpHM2f5ERAb+k9fw== X-Received: by 2002:a1c:5446:: with SMTP id p6mr3501348wmi.172.1588685171597; Tue, 05 May 2020 06:26:11 -0700 (PDT) Received: from x1w.redhat.com (26.red-88-21-207.staticip.rima-tde.net. [88.21.207.26]) by smtp.gmail.com with ESMTPSA id n6sm3427424wrs.81.2020.05.05.06.26.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 May 2020 06:26:10 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 5/7] audio: Let HWVoice write() handlers take a const buffer Date: Tue, 5 May 2020 15:26:01 +0200 Message-Id: <20200505132603.8575-6-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200505132603.8575-1-f4bug@amsat.org> References: <20200505132603.8575-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::343; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x343.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Volker_R=C3=BCmelin?= , Gerd Hoffmann , =?utf-8?b?S8WRdsOhZ8OzIFpvbHTDoW4=?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The various write() and put_buffer() handlers should not modify their buffer argument. Make it const. Signed-off-by: Philippe Mathieu-Daudé --- audio/audio_int.h | 13 +++++++------ audio/alsaaudio.c | 2 +- audio/audio.c | 11 ++++++----- audio/coreaudio.c | 5 +++-- audio/dsoundaudio.c | 2 +- audio/noaudio.c | 2 +- audio/ossaudio.c | 4 ++-- audio/paaudio.c | 4 ++-- audio/sdlaudio.c | 6 ++++-- audio/spiceaudio.c | 2 +- audio/wavaudio.c | 2 +- 11 files changed, 29 insertions(+), 24 deletions(-) diff --git a/audio/audio_int.h b/audio/audio_int.h index 62829de4e8..d23722ae7c 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -152,7 +152,7 @@ struct audio_driver { struct audio_pcm_ops { int (*init_out)(HWVoiceOut *hw, audsettings *as, void *drv_opaque); void (*fini_out)(HWVoiceOut *hw); - size_t (*write) (HWVoiceOut *hw, void *buf, size_t size); + size_t (*write) (HWVoiceOut *hw, const void *buf, size_t size); void (*run_buffer_out)(HWVoiceOut *hw); /* * get a buffer that after later can be passed to put_buffer_out; optional @@ -165,7 +165,7 @@ struct audio_pcm_ops { * buf must be equal the pointer returned by get_buffer_out, * size may be smaller */ - size_t (*put_buffer_out)(HWVoiceOut *hw, void *buf, size_t size); + size_t (*put_buffer_out)(HWVoiceOut *hw, const void *buf, size_t size); void (*enable_out)(HWVoiceOut *hw, bool enable); void (*volume_out)(HWVoiceOut *hw, Volume *vol); @@ -173,17 +173,18 @@ struct audio_pcm_ops { void (*fini_in) (HWVoiceIn *hw); size_t (*read) (HWVoiceIn *hw, void *buf, size_t size); void *(*get_buffer_in)(HWVoiceIn *hw, size_t *size); - void (*put_buffer_in)(HWVoiceIn *hw, void *buf, size_t size); + void (*put_buffer_in)(HWVoiceIn *hw, const void *buf, size_t size); void (*enable_in)(HWVoiceIn *hw, bool enable); void (*volume_in)(HWVoiceIn *hw, Volume *vol); }; void *audio_generic_get_buffer_in(HWVoiceIn *hw, size_t *size); -void audio_generic_put_buffer_in(HWVoiceIn *hw, void *buf, size_t size); +void audio_generic_put_buffer_in(HWVoiceIn *hw, const void *buf, size_t size); void audio_generic_run_buffer_out(HWVoiceOut *hw); void *audio_generic_get_buffer_out(HWVoiceOut *hw, size_t *size); -size_t audio_generic_put_buffer_out(HWVoiceOut *hw, void *buf, size_t size); -size_t audio_generic_write(HWVoiceOut *hw, void *buf, size_t size); +size_t audio_generic_put_buffer_out(HWVoiceOut *hw, + const void *buf, size_t size); +size_t audio_generic_write(HWVoiceOut *hw, const void *buf, size_t size); size_t audio_generic_read(HWVoiceIn *hw, void *buf, size_t size); struct capture_callback { diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index a32db8ff39..7692ee5524 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -608,7 +608,7 @@ static int alsa_open(bool in, struct alsa_params_req *req, return -1; } -static size_t alsa_write(HWVoiceOut *hw, void *buf, size_t len) +static size_t alsa_write(HWVoiceOut *hw, const void *buf, size_t len) { ALSAVoiceOut *alsa = (ALSAVoiceOut *) hw; size_t pos = 0; diff --git a/audio/audio.c b/audio/audio.c index c75455bbb5..e2932da4f0 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1253,7 +1253,7 @@ static size_t audio_pcm_hw_run_in(HWVoiceIn *hw, size_t samples) while (samples) { size_t proc; size_t size = samples * hw->info.bytes_per_frame; - void *buf = hw->pcm_ops->get_buffer_in(hw, &size); + const void *buf = hw->pcm_ops->get_buffer_in(hw, &size); assert(size % hw->info.bytes_per_frame == 0); if (size == 0) { @@ -1425,7 +1425,7 @@ void *audio_generic_get_buffer_in(HWVoiceIn *hw, size_t *size) return hw->buf_emul + start; } -void audio_generic_put_buffer_in(HWVoiceIn *hw, void *buf, size_t size) +void audio_generic_put_buffer_in(HWVoiceIn *hw, const void *buf, size_t size) { assert(size <= hw->pending_emul); hw->pending_emul -= size; @@ -1468,7 +1468,8 @@ void *audio_generic_get_buffer_out(HWVoiceOut *hw, size_t *size) return hw->buf_emul + hw->pos_emul; } -size_t audio_generic_put_buffer_out(HWVoiceOut *hw, void *buf, size_t size) +size_t audio_generic_put_buffer_out(HWVoiceOut *hw, + const void *buf, size_t size) { assert(buf == hw->buf_emul + hw->pos_emul && size + hw->pending_emul <= hw->size_emul); @@ -1479,7 +1480,7 @@ size_t audio_generic_put_buffer_out(HWVoiceOut *hw, void *buf, size_t size) return size; } -size_t audio_generic_write(HWVoiceOut *hw, void *buf, size_t size) +size_t audio_generic_write(HWVoiceOut *hw, const void *buf, size_t size) { size_t dst_size, copy_size; void *dst = hw->pcm_ops->get_buffer_out(hw, &dst_size); @@ -1491,7 +1492,7 @@ size_t audio_generic_write(HWVoiceOut *hw, void *buf, size_t size) size_t audio_generic_read(HWVoiceIn *hw, void *buf, size_t size) { - void *src = hw->pcm_ops->get_buffer_in(hw, &size); + const void *src = hw->pcm_ops->get_buffer_in(hw, &size); memcpy(buf, src, size); hw->pcm_ops->put_buffer_in(hw, src, size); diff --git a/audio/coreaudio.c b/audio/coreaudio.c index 4b4365660f..5258871c9c 100644 --- a/audio/coreaudio.c +++ b/audio/coreaudio.c @@ -412,9 +412,10 @@ static int coreaudio_unlock (coreaudioVoiceOut *core, const char *fn_name) COREAUDIO_WRAPPER_FUNC(get_buffer_out, void *, (HWVoiceOut *hw, size_t *size), (hw, size)) COREAUDIO_WRAPPER_FUNC(put_buffer_out, size_t, - (HWVoiceOut *hw, void *buf, size_t size), + (HWVoiceOut *hw, const void *buf, size_t size), (hw, buf, size)) -COREAUDIO_WRAPPER_FUNC(write, size_t, (HWVoiceOut *hw, void *buf, size_t size), +COREAUDIO_WRAPPER_FUNC(write, size_t, + (HWVoiceOut *hw, const void *buf, size_t size), (hw, buf, size)) #undef COREAUDIO_WRAPPER_FUNC diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c index 4cdf19ab67..bba6bafda4 100644 --- a/audio/dsoundaudio.c +++ b/audio/dsoundaudio.c @@ -454,7 +454,7 @@ static void *dsound_get_buffer_out(HWVoiceOut *hw, size_t *size) return ret; } -static size_t dsound_put_buffer_out(HWVoiceOut *hw, void *buf, size_t len) +static size_t dsound_put_buffer_out(HWVoiceOut *hw, const void *buf, size_t len) { DSoundVoiceOut *ds = (DSoundVoiceOut *) hw; LPDIRECTSOUNDBUFFER dsb = ds->dsound_buffer; diff --git a/audio/noaudio.c b/audio/noaudio.c index 05798ea210..21995c7d9b 100644 --- a/audio/noaudio.c +++ b/audio/noaudio.c @@ -41,7 +41,7 @@ typedef struct NoVoiceIn { RateCtl rate; } NoVoiceIn; -static size_t no_write(HWVoiceOut *hw, void *buf, size_t len) +static size_t no_write(HWVoiceOut *hw, const void *buf, size_t len) { NoVoiceOut *no = (NoVoiceOut *) hw; return audio_rate_get_bytes(&hw->info, &no->rate, len); diff --git a/audio/ossaudio.c b/audio/ossaudio.c index 7778138df5..97bde0256e 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -402,7 +402,7 @@ static void *oss_get_buffer_out(HWVoiceOut *hw, size_t *size) } } -static size_t oss_put_buffer_out(HWVoiceOut *hw, void *buf, size_t size) +static size_t oss_put_buffer_out(HWVoiceOut *hw, const void *buf, size_t size) { OSSVoiceOut *oss = (OSSVoiceOut *) hw; if (oss->mmapped) { @@ -415,7 +415,7 @@ static size_t oss_put_buffer_out(HWVoiceOut *hw, void *buf, size_t size) } } -static size_t oss_write(HWVoiceOut *hw, void *buf, size_t len) +static size_t oss_write(HWVoiceOut *hw, const void *buf, size_t len) { OSSVoiceOut *oss = (OSSVoiceOut *) hw; size_t pos; diff --git a/audio/paaudio.c b/audio/paaudio.c index b052084698..b50df15ea7 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -125,7 +125,7 @@ unlock_and_fail: return NULL; } -static void qpa_put_buffer_in(HWVoiceIn *hw, void *buf, size_t size) +static void qpa_put_buffer_in(HWVoiceIn *hw, const void *buf, size_t size) { PAVoiceIn *p = (PAVoiceIn *) hw; PAConnection *c = p->g->conn; @@ -228,7 +228,7 @@ unlock_and_fail: return NULL; } -static size_t qpa_write(HWVoiceOut *hw, void *data, size_t length) +static size_t qpa_write(HWVoiceOut *hw, const void *data, size_t length) { PAVoiceOut *p = (PAVoiceOut *) hw; PAConnection *c = p->g->conn; diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index 21b7a0484b..9d740186cc 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -256,10 +256,12 @@ static void sdl_callback (void *opaque, Uint8 *buf, int len) SDL_WRAPPER_FUNC(get_buffer_out, void *, (HWVoiceOut *hw, size_t *size), (hw, size), *size = 0, sdl_unlock) SDL_WRAPPER_FUNC(put_buffer_out, size_t, - (HWVoiceOut *hw, void *buf, size_t size), (hw, buf, size), + (HWVoiceOut *hw, const void *buf, size_t size), + (hw, buf, size), /*nothing*/, sdl_unlock_and_post) SDL_WRAPPER_FUNC(write, size_t, - (HWVoiceOut *hw, void *buf, size_t size), (hw, buf, size), + (HWVoiceOut *hw, const void *buf, size_t size), + (hw, buf, size), /*nothing*/, sdl_unlock_and_post) #undef SDL_WRAPPER_FUNC diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c index b6b5da4812..0aa6a0a671 100644 --- a/audio/spiceaudio.c +++ b/audio/spiceaudio.c @@ -139,7 +139,7 @@ static void *line_out_get_buffer(HWVoiceOut *hw, size_t *size) return out->frame + out->fpos; } -static size_t line_out_put_buffer(HWVoiceOut *hw, void *buf, size_t size) +static size_t line_out_put_buffer(HWVoiceOut *hw, const void *buf, size_t size) { SpiceVoiceOut *out = container_of(hw, SpiceVoiceOut, hw); diff --git a/audio/wavaudio.c b/audio/wavaudio.c index 20e6853f85..64d7142a97 100644 --- a/audio/wavaudio.c +++ b/audio/wavaudio.c @@ -39,7 +39,7 @@ typedef struct WAVVoiceOut { int total_samples; } WAVVoiceOut; -static size_t wav_write_out(HWVoiceOut *hw, void *buf, size_t len) +static size_t wav_write_out(HWVoiceOut *hw, const void *buf, size_t len) { WAVVoiceOut *wav = (WAVVoiceOut *) hw; int64_t bytes = audio_rate_get_bytes(&hw->info, &wav->rate, len); From patchwork Tue May 5 13:26:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 283384 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BFF7BC47247 for ; Tue, 5 May 2020 13:28:39 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 83F7A20661 for ; Tue, 5 May 2020 13:28:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Hs3isSMq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 83F7A20661 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:54506 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jVxck-0000QU-ML for qemu-devel@archiver.kernel.org; Tue, 05 May 2020 09:28:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46314) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jVxaQ-00061v-UT for qemu-devel@nongnu.org; Tue, 05 May 2020 09:26:14 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:50942) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jVxaQ-0002Ok-7W for qemu-devel@nongnu.org; Tue, 05 May 2020 09:26:14 -0400 Received: by mail-wm1-x341.google.com with SMTP id x25so2306115wmc.0 for ; Tue, 05 May 2020 06:26:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3L18rNpXpkfeoHL8SK4N5mRbwiSg/mgs7+xst3LggJg=; b=Hs3isSMq3dMVH/b+DXr6sBt+9a4lpLQkB5MraOL6g47/ItAQSsEqqhHE48EDMHBB4g 1enwXkIqnkjLgIbLSTGuLGJsuNkv/QXCFRGCgCQEDqTHxE/OrfqbVgLA0CQLYkLMXalS rXO2KgEBY0m6NBIysYkoAezCEyCSUPAyk9ZvIqrFJmWqA+HR+Ag1APk0eGrvavHRj/Tg Ag1jqchT23kfA0FpjHNoWi1pHy/nd5t3KHJyvw18t3f6Hk3llzHmHzM2S5n6FB2woDgL sEqiV6q3r+FDXSDN09tC0pz83N6yju/v9a8TY7ouPRnNf0lOPBiPy+Yv9aZPulbDLzlF GPDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=3L18rNpXpkfeoHL8SK4N5mRbwiSg/mgs7+xst3LggJg=; b=D9mFJ5fakGGfK/Eha1mU6QaHGXxPHHofngfZ/4+rDEGERAxfrq/DWsstw7wHah9PSz kmNW0Miwo902Dd4UiR6sYBeF9wi1sG3+MUUyiwrVaKaB20nfYoDPiHoCbroWJgbsARuB 0lpV1WffxVbNCNAW02UD1Gx8scjvFNOG+T4wMvkPrRleDeryO2RboQ8zwUaf2VHv6OLL 5pvLUXnR0NWQJTDeVOCND1stWic6D+4gYCXaMkEtlwjh6lHyCZsJ53LdcI1+EFWppugC Dqhd8VtZsU8K4tE8AOuYtA6Vb/4LX+/X8bwbUp+nhSMHzHfVLmpMA7MVOphJclHP9qQZ guXw== X-Gm-Message-State: AGi0PuZYzCtuxLrn6UeU8mj1M8nek4D/dDq2izTyg6zBvopr4smjrsQK l7RVKZ7VOmBYx6jteGMSZJo1snPG X-Google-Smtp-Source: APiQypJwi/rICiXWjPLNKnqBmpDv80bjzKZ0KGYRd/kaNmHbQbFW1FCMGkKXkOlDVEYaYabA48HfYA== X-Received: by 2002:a1c:bd54:: with SMTP id n81mr3228626wmf.141.1588685172745; Tue, 05 May 2020 06:26:12 -0700 (PDT) Received: from x1w.redhat.com (26.red-88-21-207.staticip.rima-tde.net. [88.21.207.26]) by smtp.gmail.com with ESMTPSA id n6sm3427424wrs.81.2020.05.05.06.26.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 May 2020 06:26:12 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 6/7] audio: Let AUD_write() use a const buffer argument Date: Tue, 5 May 2020 15:26:02 +0200 Message-Id: <20200505132603.8575-7-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200505132603.8575-1-f4bug@amsat.org> References: <20200505132603.8575-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::341; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x341.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Volker_R=C3=BCmelin?= , Gerd Hoffmann , =?utf-8?b?S8WRdsOhZ8OzIFpvbHTDoW4=?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" AUD_write() is to let backends process an existing data. As we are not supposed to modify this buffer, make the argument const. Signed-off-by: Philippe Mathieu-Daudé --- audio/audio.h | 2 +- audio/audio.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/audio/audio.h b/audio/audio.h index 9d759d644b..7956b32d0a 100644 --- a/audio/audio.h +++ b/audio/audio.h @@ -113,7 +113,7 @@ SWVoiceOut *AUD_open_out ( ); void AUD_close_out (QEMUSoundCard *card, SWVoiceOut *sw); -size_t AUD_write (SWVoiceOut *sw, void *pcm_buf, size_t size); +size_t AUD_write (SWVoiceOut *sw, const void *pcm_buf, size_t size); int AUD_get_buffer_size_out (SWVoiceOut *sw); void AUD_set_active_out (SWVoiceOut *sw, int on); int AUD_is_active_out (SWVoiceOut *sw); diff --git a/audio/audio.c b/audio/audio.c index e2932da4f0..2672cf0885 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -703,7 +703,7 @@ static size_t audio_pcm_hw_get_live_out (HWVoiceOut *hw, int *nb_live) /* * Soft voice (playback) */ -static size_t audio_pcm_sw_write(SWVoiceOut *sw, void *buf, size_t size) +static size_t audio_pcm_sw_write(SWVoiceOut *sw, const void *buf, size_t size) { size_t hwsamples, samples, isamp, osamp, wpos, live, dead, left, swlim, blck; size_t ret = 0, pos = 0, total = 0; @@ -850,7 +850,7 @@ static void audio_timer (void *opaque) /* * Public API */ -size_t AUD_write(SWVoiceOut *sw, void *buf, size_t size) +size_t AUD_write(SWVoiceOut *sw, const void *buf, size_t size) { HWVoiceOut *hw; From patchwork Tue May 5 13:26:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 283383 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC930C47258 for ; Tue, 5 May 2020 13:29:52 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A89DA2073B for ; Tue, 5 May 2020 13:29:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="F9rUkkLy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A89DA2073B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:58624 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jVxdu-00027u-TA for qemu-devel@archiver.kernel.org; Tue, 05 May 2020 09:29:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46334) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jVxaS-00066M-Pa for qemu-devel@nongnu.org; Tue, 05 May 2020 09:26:16 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:35362) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jVxaR-0002UZ-Pm for qemu-devel@nongnu.org; Tue, 05 May 2020 09:26:16 -0400 Received: by mail-wm1-x342.google.com with SMTP id r26so2357626wmh.0 for ; Tue, 05 May 2020 06:26:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=g+biD/0WLVeYiErHCpqybenqY21TPO7hOVUcj0/N2cI=; b=F9rUkkLyXU9zbzd+ayRbfob6YYG0gvE+B/oQOdN3Ga29hdRAVsfRHfHi6JR+Szh9qA cB4dDAoZ7oPhwynvbbwH15tyz9W8DsSqhOxplcUQ7UnqJnmt79qOJz9VW+7HJ4UqDzTa MSQ2SC1mLL74S/A8V9bCoqcqPAroAuXgd/3WWbXocVSWWE+j/AfsWHhqFYu7H75Ujw9W GOUx35ATpEersH5WqhOM4xIwcJDVf9bPUjL5wBn8sIsvW4ggnQT5pW86dQqz8WFgDf9L Jdg6mGG1zMfvRpWDxj10JH+eEK7JBcTFC3oBLmqJOc3x9KpBQ4BecTM9RCkZLyK7cdPW jDkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=g+biD/0WLVeYiErHCpqybenqY21TPO7hOVUcj0/N2cI=; b=N5kPnx4n7HhWJrzehZBPXHvFKz3SLeyX/YJeFxJxXGNmCn1jTaSSRVg2EcTb4smv70 zXCwsQu7KqTW37Fyj2PA5DpFLbHrNqYC1bYyoOQ5uf5CjCBcYZGa3089HoNrbtha9gqO D5vkGFwXiizMeq2/M7lUqBmOH4gcUgBiw4ZIL1V+WFN4Fc9JS08hCo/vxi1wbfb3/MJj xJE3vW7yReI56ASjqNdkfC1KtOBURTCv51k498Hu1mhLmwyINSpjIgLb9HZ7dParXR7q +W5lNJNAf9Y09uE4MmdxF6w574rSwETbutuw4GmMDJelhepAYsPeMOi4Akqm47g7/Mb4 JTtA== X-Gm-Message-State: AGi0PuZL+Avx5uUHBzHVCk3q2Tel/n0kbbuDF/hD7TOCKglzBPUafj2T vcsRDwlUk2XLAjZ68/K9C3X/gQRi X-Google-Smtp-Source: APiQypJhsSxpQ/lVr1Q49xgr+HCka+5SYORYglGzD95getHkuX51gjLQZjtR38kxRDkLc2ALgMI2Ug== X-Received: by 2002:a1c:1fcf:: with SMTP id f198mr3585939wmf.16.1588685174056; Tue, 05 May 2020 06:26:14 -0700 (PDT) Received: from x1w.redhat.com (26.red-88-21-207.staticip.rima-tde.net. [88.21.207.26]) by smtp.gmail.com with ESMTPSA id n6sm3427424wrs.81.2020.05.05.06.26.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 May 2020 06:26:13 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 7/7] audio: Expose 'audio/audio.h' under the include/ directory Date: Tue, 5 May 2020 15:26:03 +0200 Message-Id: <20200505132603.8575-8-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200505132603.8575-1-f4bug@amsat.org> References: <20200505132603.8575-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::342; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x342.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Volker_R=C3=BCmelin?= , Gerd Hoffmann , =?utf-8?b?S8WRdsOhZ8OzIFpvbHTDoW4=?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The 'audio/audio.h' header is consumed by the hardware models: $ git grep -l audio/audio.h hw/ hw/arm/omap2.c hw/arm/palm.c hw/arm/spitz.c hw/arm/z2.c hw/audio/ac97.c hw/audio/adlib.c hw/audio/cs4231a.c hw/audio/es1370.c hw/audio/gus.c hw/audio/hda-codec.c hw/audio/lm4549.c hw/audio/lm4549.h hw/audio/marvell_88w8618.c hw/audio/milkymist-ac97.c hw/audio/pcspk.c hw/audio/sb16.c hw/audio/wm8750.c hw/core/qdev-properties-system.c hw/input/tsc210x.c hw/mips/mips_fulong2e.c hw/usb/dev-audio.c Move it to the public include/ directory. Signed-off-by: Philippe Mathieu-Daudé --- {audio => include/audio}/audio.h | 2 +- audio/alsaaudio.c | 2 +- audio/audio.c | 2 +- audio/audio_legacy.c | 2 +- audio/audio_win_int.c | 2 +- audio/coreaudio.c | 2 +- audio/dsoundaudio.c | 2 +- audio/mixeng.c | 2 +- audio/noaudio.c | 2 +- audio/ossaudio.c | 2 +- audio/paaudio.c | 2 +- audio/sdlaudio.c | 2 +- audio/spiceaudio.c | 2 +- audio/wavaudio.c | 2 +- audio/wavcapture.c | 2 +- MAINTAINERS | 1 + 16 files changed, 16 insertions(+), 15 deletions(-) rename {audio => include/audio}/audio.h (100%) diff --git a/audio/audio.h b/include/audio/audio.h similarity index 100% rename from audio/audio.h rename to include/audio/audio.h index 7956b32d0a..b5c51d87b6 100644 --- a/audio/audio.h +++ b/include/audio/audio.h @@ -95,6 +95,7 @@ void AUD_log (const char *cap, const char *fmt, ...) GCC_FMT_ATTR(2, 3); void AUD_register_card (const char *name, QEMUSoundCard *card); void AUD_remove_card (QEMUSoundCard *card); + CaptureVoiceOut *AUD_add_capture( AudioState *s, struct audsettings *as, @@ -111,7 +112,6 @@ SWVoiceOut *AUD_open_out ( audio_callback_fn callback_fn, struct audsettings *settings ); - void AUD_close_out (QEMUSoundCard *card, SWVoiceOut *sw); size_t AUD_write (SWVoiceOut *sw, const void *pcm_buf, size_t size); int AUD_get_buffer_size_out (SWVoiceOut *sw); diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index 7692ee5524..72b0a37dad 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -26,7 +26,7 @@ #include #include "qemu/main-loop.h" #include "qemu/module.h" -#include "audio.h" +#include "audio/audio.h" #include "trace.h" #pragma GCC diagnostic ignored "-Waddress" diff --git a/audio/audio.c b/audio/audio.c index 2672cf0885..d0fb794378 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -23,7 +23,7 @@ */ #include "qemu/osdep.h" -#include "audio.h" +#include "audio/audio.h" #include "migration/vmstate.h" #include "monitor/monitor.h" #include "qemu/timer.h" diff --git a/audio/audio_legacy.c b/audio/audio_legacy.c index ebd7d9fa0d..4321a84b47 100644 --- a/audio/audio_legacy.c +++ b/audio/audio_legacy.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #include "qemu/osdep.h" -#include "audio.h" +#include "audio/audio.h" #include "audio_int.h" #include "qemu/cutils.h" #include "qemu/timer.h" diff --git a/audio/audio_win_int.c b/audio/audio_win_int.c index b938fd667b..cd8cde527b 100644 --- a/audio/audio_win_int.c +++ b/audio/audio_win_int.c @@ -7,7 +7,7 @@ #include #include -#include "audio.h" +#include "audio/audio.h" #include "audio_int.h" #include "audio_win_int.h" diff --git a/audio/coreaudio.c b/audio/coreaudio.c index 5258871c9c..f1656bb98b 100644 --- a/audio/coreaudio.c +++ b/audio/coreaudio.c @@ -27,7 +27,7 @@ #include /* pthread_X */ #include "qemu/module.h" -#include "audio.h" +#include "audio/audio.h" #define AUDIO_CAP "coreaudio" #include "audio_int.h" diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c index bba6bafda4..3c0b4f0f9b 100644 --- a/audio/dsoundaudio.c +++ b/audio/dsoundaudio.c @@ -27,7 +27,7 @@ */ #include "qemu/osdep.h" -#include "audio.h" +#include "audio/audio.h" #define AUDIO_CAP "dsound" #include "audio_int.h" diff --git a/audio/mixeng.c b/audio/mixeng.c index 75f000e49f..5a47594fa0 100644 --- a/audio/mixeng.c +++ b/audio/mixeng.c @@ -25,7 +25,7 @@ #include "qemu/osdep.h" #include "qemu/bswap.h" #include "qemu/error-report.h" -#include "audio.h" +#include "audio/audio.h" #define AUDIO_CAP "mixeng" #include "audio_int.h" diff --git a/audio/noaudio.c b/audio/noaudio.c index 21995c7d9b..e6a5e35060 100644 --- a/audio/noaudio.c +++ b/audio/noaudio.c @@ -25,7 +25,7 @@ #include "qemu/osdep.h" #include "qemu/host-utils.h" #include "qemu/module.h" -#include "audio.h" +#include "audio/audio.h" #include "qemu/timer.h" #define AUDIO_CAP "noaudio" diff --git a/audio/ossaudio.c b/audio/ossaudio.c index 97bde0256e..7dddbd11d1 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -28,7 +28,7 @@ #include "qemu/main-loop.h" #include "qemu/module.h" #include "qemu/host-utils.h" -#include "audio.h" +#include "audio/audio.h" #include "trace.h" #define AUDIO_CAP "oss" diff --git a/audio/paaudio.c b/audio/paaudio.c index b50df15ea7..63b97c93df 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -3,7 +3,7 @@ #include "qemu/osdep.h" #include "qemu/module.h" #include "qemu-common.h" -#include "audio.h" +#include "audio/audio.h" #include "qapi/opts-visitor.h" #include diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index 9d740186cc..4c4d58457d 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -26,7 +26,7 @@ #include #include #include "qemu/module.h" -#include "audio.h" +#include "audio/audio.h" #ifndef _WIN32 #ifdef __sun__ diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c index 0aa6a0a671..5802f60d1d 100644 --- a/audio/spiceaudio.c +++ b/audio/spiceaudio.c @@ -25,7 +25,7 @@ #include "ui/qemu-spice.h" #define AUDIO_CAP "spice" -#include "audio.h" +#include "audio/audio.h" #include "audio_int.h" #if SPICE_INTERFACE_PLAYBACK_MAJOR > 1 || SPICE_INTERFACE_PLAYBACK_MINOR >= 3 diff --git a/audio/wavaudio.c b/audio/wavaudio.c index 64d7142a97..4241f1ad96 100644 --- a/audio/wavaudio.c +++ b/audio/wavaudio.c @@ -27,7 +27,7 @@ #include "qemu/module.h" #include "qemu/timer.h" #include "qapi/opts-visitor.h" -#include "audio.h" +#include "audio/audio.h" #define AUDIO_CAP "wav" #include "audio_int.h" diff --git a/audio/wavcapture.c b/audio/wavcapture.c index 17e87ed6f4..c0ad928e80 100644 --- a/audio/wavcapture.c +++ b/audio/wavcapture.c @@ -2,7 +2,7 @@ #include "monitor/monitor.h" #include "qapi/error.h" #include "qemu/error-report.h" -#include "audio.h" +#include "audio/audio.h" typedef struct { FILE *f; diff --git a/MAINTAINERS b/MAINTAINERS index 8aa8efaf1d..b332611717 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1927,6 +1927,7 @@ M: Gerd Hoffmann S: Maintained F: audio/ F: hw/audio/ +F: include/audio/ F: include/hw/audio/ F: tests/qtest/ac97-test.c F: tests/qtest/es1370-test.c