RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 961219 - Use 'wavcapture' command to capture audio to a wave file but the file was 0 bytes
Summary: Use 'wavcapture' command to capture audio to a wave file but the file was 0 b...
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: qemu-kvm
Version: 7.0
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: Gerd Hoffmann
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-05-09 07:17 UTC by Sibiao Luo
Modified: 2013-09-13 09:25 UTC (History)
11 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-09-13 09:25:36 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Sibiao Luo 2013-05-09 07:17:47 UTC
Description of problem:
Used 'wavcapture' command to capture audio to a wave file, but the file is 0 bytes, does it the expected result? It can be hit both in rhel6 and rhel7 host. I checked the bug 749830 #c15 and #16 comments that not zero bytes. 

Version-Release number of selected component (if applicable):
host info:
kernel-3.9.0-0.55.el7.x86_64
qemu-kvm-1.4.0-4.el7.x86_64
guest info:
kernel-3.9.0-0.55.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.launch a guest by.
# /usr/libexec/qemu-kvm -M pc-i440fx-1.4 -enable-kvm -m 2048 -smp 2,sockets=1,cores=2,threads=1 est -uuid `uuidgen` -rtc base=utc,clock=host,driftfix=slew -boot menu=on -drive file=/home/RHEL-Server-7.0-64-virtio.raw,if=none,id=drive-virtio-0-0,media=disk,format=raw,cache=none,werror=stop,rerror=stop -device virtio-blk-pci,drive=drive-virtio-0-0,id=virt0-0-0 -net none -usb -device usb-tablet,id=input1 -spice port=9000,disable-ticketing -vga qxl -global qxl-vga.vram_size=67108864 -monitor stdio -balloon none
2.Used 'wavcapture' command to capture audio to a wave file.
(qemu) wavcapture foo 44100 7
incorrect bit count 7, must be 8 or 16
Failed to add wave capture
(qemu) info capture 
(qemu) wavcapture test
(qemu) info capture 
[0]: Capturing audio(44100,16,2) to test: 0 bytes
(qemu) wavcapture test
(qemu) info capture 
[0]: Capturing audio(44100,16,2) to test: 0 bytes
[1]: Capturing audio(44100,16,2) to test: 0 bytes

Actual results:
Used 'wavcapture' command to capture audio to a wave file, but the file is 0 bytes.

Expected results:
it should not always 0 bytes, iy should have size.

Additional info:
I checked the related code from /root/qemu/audio/wavcapture.c
...
static void wav_capture (void *opaque, void *buf, int size)
{    
    WAVState *wav = opaque;
     
    if (fwrite (buf, size, 1, wav->f) != 1) {
        monitor_printf (cur_mon, "wav_capture: fwrite error\nReason: %s",
                        strerror (errno));
    }
    wav->bytes += size;
}
...
static void wav_capture_info (void *opaque)
{                                  
    WAVState *wav = opaque;        
    char *path = wav->path;        
                                   
    monitor_printf (cur_mon, "Capturing audio(%d,%d,%d) to %s: %d bytes\n",
                    wav->freq, wav->bits, wav->nchannels,       
                    path ? path : "<not available>", wav->bytes);
}

Comment 1 Markus Armbruster 2013-05-17 12:40:05 UTC
Your reproducer only starts a capture.  Starting a capture creates the
file and writes the file header (44 bytes for me).  However, the write
is buffered, and therefore the file's size on disk remains zero until
the buffer gets flushed.  stopcapture closes the file, flushing the
buffer.  If I do that before the guest had a chance to play audio, the
file contains exactly the header.

Does wavcapture behave as expected for you if you add stopcapture to
your reproducer?

Speaking of reproducer: each wavcapture should get its own disk file.
Your reproducer adds two captures to the same file "test", which I'd
expect to result in garbage.

Comment 2 Sibiao Luo 2013-05-21 02:11:22 UTC
(In reply to Markus Armbruster from comment #1)
> Your reproducer only starts a capture.  Starting a capture creates the
> file and writes the file header (44 bytes for me).  However, the write
> is buffered, and therefore the file's size on disk remains zero until
> the buffer gets flushed.  stopcapture closes the file, flushing the
> buffer.  If I do that before the guest had a chance to play audio, the
> file contains exactly the header.
> 
> Does wavcapture behave as expected for you if you add stopcapture to
> your reproducer?
> 
> Speaking of reproducer: each wavcapture should get its own disk file.
> Your reproducer adds two captures to the same file "test", which I'd
> expect to result in garbage.

yes, thanks for your kindly reminds, the workaround is:
1.play a video in the guest.
2.start a capture to create the file and writes the file header.
(qemu) wavcapture test
(qemu) info capture 
[0]: Capturing audio(44100,16,2) to test: 0 bytes
# ls -l test 
-rw-r--r--. 1 root root 0 May 21 09:59 test
3.stopcapture closes the file forflushing the buffer.
(qemu) stopcapture 0
(qemu) info capture
                  <-------nothing
# ls -lh test 
-rw-r--r--. 1 root root 44 May 21 10:04 test

Best Regards.
sluo

Comment 3 Gerd Hoffmann 2013-09-13 09:25:36 UTC
You havn't added any sound card to the vm, so the guest can't play audio.


Note You need to log in before you can comment on or make changes to this bug.