1 .TH AXFER\-TRANSFER 1 "28 November 2018" "alsa\-utils"
4 axfer\-transfer \- transferrer of audio data frame for sound devices and nodes.
27 .I \-\-separate\-channels filepath ...
34 common\-options = ( read
38 backend\-options = ( read
51 performs transmission of audio data frames for devices available in supported
52 backends. This program is essentially designed to use alsa\-lib APIs
53 (libasound backend) to handle sound devices supported by Linux sound subsystem
62 Operates for capture transmission.
66 Operates for playback transmission.
70 Filepath is handled as a path relative to current working directory of run time
71 if it\(aqs not full path from root directory.
73 The standard input or output is used if filepath is not specified or given as
77 For playback transmission, container format of given
79 is detected automatically and metadata is used for parameters of sample format,
80 channels, rate, duration. If nothing detected, content of given file path is
81 handled as raw data. In this case, the parameters should be indicated as
89 .I \-\-separate\-channels
90 option. In this case, standard input and output is not available. The same
92 is not allowed except for paths listed below:
103 Print help messages and finish run time.
107 Quiet mode. Suppress messages (not sound :))
111 Verbose mode. Runtime dumps supplemental information according to the number of
112 this option given in command line.
115 .B \-d, \-\-duration=#
116 Interrupt after # seconds. A value of zero means infinity. The default is zero,
117 so if this option is omitted then the transmission process will run until it is
122 option is available exclusively.
125 .B \-s, \-\-samples=#
126 Interrupt after transmission of # number of data frames. A value of zero means
127 infinity. The default is zero, so if this options is omitted then the
128 transmission process will run until it is killed. Either
132 option is available exclusively.
135 .B \-f, \-\-format=FORMAT
136 Indicate format of audio sample. This is required for capture transmission, or
137 playback transmission with files including raw audio data.
139 Available sample format is listed below:
140 - [S8|U8|S16|U16|S32|U32][_LE|_BE]
144 - IEC958_SUBFRAME[_LE|_BE]
148 - [S24|U24][_3LE|_3BE]
149 - [S20|U20][_3LE|_3BE]
150 - [S18|U18][_3LE|_3BE]
152 - DSD_[U16|U32][_LE|_BE]
154 If endian\-ness is omitted, host endian\-ness is used.
156 Some special formats are available:
157 - cd (16 bit little endian, 44100, stereo) [= \-f S16_LE \-c 2 \-r 44100]
158 - cdr (16 bit big endian, 44100, stereo) [= \-f S16_BE \-c 2 \-f 44100]
159 - dat (16 bit little endian, 48000, stereo) [= \-f S16_LE \-c 2 \-r 48000]
163 is used as a default. Actual available formats are restricted by each
164 transmission backend.
166 Unavailable sample format is listed below. These format has size of data frame
167 unaligned to byte unit.
179 .B \-c, \-\-channels=#
180 Indicate the number of audio data samples per frame. This is required for
181 capture transmission, or playback transmission with files including raw audio
182 data. The value should be between
187 is used as a default.
191 Indicate the number of audio data frame per second. This is required for
192 capture transmission, or playback transmission with files including raw audio
193 data. If the value is less than
195 , it\(aqs interpreted by
197 unit. The value should be between
203 is used as a default.
206 .B \-t, \-\-file\-type=TYPES
207 Indicate the type of file. This is required for capture transmission. Available
208 types are listed below:
209 - wav: Microsoft/IBM RIFF/Wave format
210 - au, sparc: Sparc AU format
211 - voc: Creative Tech. voice format
214 When nothing is indicated, for capture transmission, the type is decided
215 according to suffix of
219 type is used for fallback.
222 .B \-I, \-\-separate\-channels
223 Indicate this option when several files are going to be handled. For capture
224 transmission, if one filepath is given as
228 is generated in a formula \(aq<filepath>\-<sequential number>[.suffix]\(aq.
229 The suffix is omitted when raw format of container is used.
232 .B \-\-dump\-hw\-params
233 Dump hardware parameters and finish run time if backend supports it.
236 .B \-\-xfer\-backend=BACKEND
237 Select backend of transmission from a list below. The default is libasound.
240 - libffado (optional if compiled)
242 .SS Backend options for libasound
247 This option is used to select PCM node in libasound configuration space.
248 Available nodes are listed by
257 With this option, PCM substream is opened in non\-blocking mode. When audio
258 data frame is not available in buffer of the PCM substream, I/O operation
259 immediately returns without blocking process. This option implicitly uses
261 option as well to prevent heavy consumption of CPU time.
266 With this option, audio data frame is processed directly in buffer of PCM
267 substream if selected node supports this operation. Without the option,
268 temporary buffers are used to copy audio data frame for buffer of PCM substream.
269 This option implicitly uses
271 option as well to prevent heavy consumption of CPU time.
274 .B \-F, \-\-period\-size
276 This option configures given value to
278 hardware parameter of PCM substream. The parameter indicates the number of audio
279 data frame per period in buffer of the PCM substream. Actual number is decided
280 as a result of interaction between each implementation of PCM plugin chained
281 from the selected PCM node, and in\-kernel driver or PCM I/O plugins.
283 Ideally, the same amount of audio data frame as the value should be handled in
284 one I/O operation. Actually, it is not, depending on implementation of the PCM
285 plugins, in\-kernel driver, PCM I/O plugins and scheduling model. For \(aqhw\(aq
286 PCM plugin in \(aqirq\(aq scheduling model, the value is used to decide
287 intervals of hardware interrupt, thus the same amount of audio data frame as
288 the value is expected to be available for one I/O operation.
293 This option configures given value to
295 hardware parameter of PCM substream. This option is similar to
297 option, however its unit is micro\-second.
300 .B \-B, \-\-buffer\-size
302 This option configures given value to
304 hardware parameter of PCM substream. The parameter indicates the number of audio
305 data frame in buffer of PCM substream. Actual number is decided as a result of
306 interaction between each implementation of PCM plugin chained from the selected
307 PCM node, and in\-kernel driver or PCM I/O plugins.
309 Ideally, this is multiples of the number of audio data frame per period, thus
310 the size of period. Actually, it is not, depending on implementation of the PCM
311 plugins, in\-kernel driver and PCM I/O plugins.
316 This option configures given value to
318 hardware parameter of PCM substream. This option is similar to
320 option, however its unit is micro\-second.
325 This option indicates the type of waiter for event notification. At present,
326 four types are available;
336 type, \(aqsnd_pcm_wait()\(aq is used. With
338 type, \(aqselect(2)\(aq system call is used. With
340 type, \(aqpoll(2)\(aq system call is used. With
342 type, Linux\-specific \(aqepoll(7)\(aq system call is used.
344 This option should correspond to one of
353 Neither this option nor
355 is available at the same time.
360 This option selects scheduling model for process of this program. One of
364 is available. In detail, please read \(aqSCHEDULING MODEL\(aq section.
366 When nothing specified,
371 .B \-A, \-\-avail\-min
373 This option configures given value to
375 software parameter of PCM substream. In blocking mode, the value is used as
376 threshold of the number of available audio data frames in buffer of PCM
377 substream to wake up process blocked by I/O operation. In non\-blocking mode,
378 any I/O operation returns \-EAGAIN untill the available number of audio data frame reaches the threshold.
380 This option has an effect in cases neither
389 .B \-R, \-\-start\-delay
391 This option configures given value to
393 software parameter of PCM substream. The value is used as threshold to start
394 PCM substream automatically. At present, this option has an effect in cases
403 For playback transmission, when the number of accumulated audio data frame
404 in buffer of PCM substream to which this program writes out reaches the
405 threshold, the PCM substream starts automatically without an explicit call of
407 to the PCM substream.
409 For capture transmission, this option is useless. The number of
410 accumulated audio data frame is not increased without an explicit call of
412 to the PCM substream.
414 This option has an effect in cases neither
423 .B \-T, \-\-stop\-delay
425 This option configures given value to
427 software parameter of PCM substream. The value is used as threshold to stop PCM
428 substream automatically. At present, this option has an effect in cases neither
436 For capture transmission, when the number of accumulated audio data frame
437 in buffer of PCM substream to which a driver or alsa\-lib PCM plugins write
438 reaches the threshold, the PCM substream stops automatically without an explicit
441 to the PCM substream. This is a case that this program leaves the audio data
442 frames without reading for a while.
444 For playback transmission, when the number available audio data frame in buffer
445 of PCM substream from which a driver or alsa\-lib PCM plugins read reaches the
446 threshold, the PCM substream stops automatically without an explicit call of
448 to the PCM substream. This is a case that this program leaves the audio data
449 frames without writing for a while.
451 This option has an effect in cases neither
460 .B \-\-disable\-resample
462 This option has an effect for \(aqplug\(aq plugin in alsa\-lib to suppress
463 conversion of sampling rate for audio data frame.
466 .B \-\-disable\-channels
468 This option has an effect for \(aqplug\(aq plugin in alsa\-lib to suppress
469 conversion of channels for audio data frame.
472 .B \-\-disable\-format
474 This option has an effect for \(aqplug\(aq plugin in alsa\-lib to suppress
475 conversion of sample format for audio data frame.
478 .B \-\-disable\-softvol
480 This option has an effect for \(aqsoftvol\(aq plugin in alsa\-lib to suppress
481 conversion of samples for audio data frame via additional control element.
486 This option suppresses recovery operation from XRUN state of running PCM
487 substream, then process of this program is going to finish as usual.
492 This option disables any waiter for I/O event notification. I/O operations are
493 iterated till any of audio data frame is available. The option brings heavy
494 load in consumption of CPU time.
496 .SS Backend options for libffado
498 This backend is automatically available when configure script detects
499 .I ffado_streaming_init()
500 symbol in libffado shared object.
505 This option uses given value to decide which 1394 OHCI controller is used to
506 communicate. When Linux system has two 1394 OHCI controllers,
510 are available. Neither this option nor
512 is available at the same time. If nothing specified, libffado performs to
513 communicate to units on IEEE 1394 bus managed by all of 1394 OHCI controller available in Linux system.
518 This option uses given value to decide which unit is used to communicate. This
521 option to indicate which 1394 OHCI controller is used to communicate to the
527 This option uses given value to decide a target unit to communicate. The value
528 should be prefixed with '0x' and consists of hexadecimal literal letters
529 (0\-9, a\-f, A\-F). Neither this option nor
531 is available at the same time. If nothing specified, libffado performs to
532 communicate to units on IEEE 1394 bus managed by all of 1394 OHCI controller
533 available in Linux system.
536 .B \-\-frames\-per\-period
538 This option uses given value to decide the number of audio data frame in one
539 read/write operation. The operation is blocked till the number of available
540 audio data frame exceeds the given value. As a default, 512 audio data frames
544 .B \-\-periods\-per\-buffer
546 This option uses given value to decide the size of intermediate buffer between
547 this program and libffado. As a default, 2 periods per buffer is used.
552 This option allows this program to run slave mode. In this mode, libffado
553 adds unit directory into configuration ROM of 1394 OHCI controller where Linux
554 system runs. The unit directory can be found by the other node on the same bus.
555 Linux system running on the node can transfer isochronous packet with audio
556 data frame to the unit. This program can receive the packet and demultiplex the
562 This option allows this program to run snoop mode. In this mode, libffado
563 listens isochronous channels to which device transfers isochronous packet. When
564 isochronous communication starts by any unit on the same bus, the packets can
565 be handled by this program.
568 .B \-\-sched\-priority
571 .I pthread_setschedparam()
573 .I ffado_streaming_init()
575 scheduling policy and given value as its priority for threads related to
576 isochronous communication.
577 The given value should be within
579 parameter of process. Please read
588 will close handled files and PCM substream to be going to finish run time.
591 will suspend PCM substream and
593 will resume it. No XRUNs are expected. With libffado backend, the suspend/resume
594 is not supported and runtime is aboeted immediately.
596 The other signals perform default behaviours.
603 .B $ axfer transfer playback \-d 1 something
608 The above will transfer audio data frame in \(aqsomething\(aq file for playback
609 during 1 second. The sample format is detected automatically as a result to
610 parse \(aqsomething\(aq as long as it\(aqs compliant to one of Microsoft/IBM
611 RIFF/Wave, Sparc AU, Creative Tech. voice formats. If nothing detected,
620 should be given with special format.
625 .B $ axfer transfer playback \-r 22050 \-c 1 \-f S16_LE \-t raw something
630 The above will transfer audio data frame in \(aqsomething\(aq file including no
631 information of sample format, as sample format of 22050 Hz, monaural, signed 16
632 bit little endian PCM for playback. The transmission continues till catching
643 .B $ axfer transfer capture \-d 10 \-f cd something.wav
648 The above will transfer audio data frame to \(aqsomething.wav\(aq file as
649 sample format of 44.1 kHz, 2 channels, signed 16 bit little endian PCM, during
650 10 seconds. The file format is Microsoft/IBM RIFF/Wave according to suffix of
658 .B $ axfer transfer capture \-s 1024 \-r 48000 \-c 2 \-f S32_BE \-I \-t au channels
663 The above will transfer audio data frame as sample format of 48.0 kHz, 2
664 channels, signed 32 bit big endian PCM for 1,024 number of data frames to files
665 named \(aqchannels\-1.au\(aq and \(aqchannels\-2.au\(aq.
669 In a design of ALSA PCM core, runtime of PCM substream supports two modes;
672 .I no\-period\-wakeup.
673 These two modes are for different scheduling models.
675 .SS IRQ\-based scheduling model
679 mode is used. In this mode, in\-kernel drivers should operate hardware to
680 generate periodical notification for transmission of audio data frame. The
681 interval of notification is equivalent to the same amount of audio data frame
682 as one period of buffer, against actual time.
684 In a handler assigned to the notification, a helper function of ALSA PCM core
685 is called to update a position to head of hardware transmission, then compare
686 it with a position to head of application operation to judge overrun/underrun
687 (XRUN) and to wake up blocked processes.
689 For this purpose, hardware IRQ of controller for serial audio bus such as
690 Inter\-IC sound is typically used. In this case, the controller generates the
691 IRQ according to transmission on the serial audio bus. In the handler assigned
692 to the IRQ, direct media access (DMA) transmission is requested between
693 dedicated host memory and device memory.
695 If target hardware doesn't support this kind of mechanism, the periodical
696 notification should be emulated by any timer; e.g. hrtimer, kernel timer.
697 External PCM plugins generated by PCM plugin SDK in alsa\-lib should also
698 emulate the above behaviour.
700 In this mode, PCM applications are programmed according to typical way of I/O
701 operations. They execute blocking system calls to read/write audio data frame
702 in buffer of PCM substream, or blocking system calls to wait until any audio
703 data frame is available. In
707 scheduling model and a default behaviour. Users can explicitly configure this
714 .SS Timer\-based scheduling model
717 .I no\-period\-wakeup
718 mode is an optional mode of runtime of PCM substream. The mode assumes a
719 specific feature of hardware and assist of in\-kernel driver and PCM
720 applications. In this mode, in\-kernel drivers don't operate hardware to
721 generate periodical notification for transmission of audio data frame.
722 The hardware should automatically continue transmission of audio data frame
723 without periodical operation of the drivers; e.g. according to auto\-triggered
724 DMA transmission, a chain of registered descriptors.
726 In this mode, nothing wakes up blocked processes, therefore PCM applications
727 should be programmed without any blocking operation. For this reason, this mode
728 is enabled when the PCM applications explicitly configure hardware parameter to
729 runtime of PCM substream, to prevent disorder of existing applications.
730 Additionally, nothing maintains timing for transmission of audio data frame,
731 therefore the PCM applications should voluntarily handle any timer to queue
732 audio data frame in buffer of the PCM substream for lapse of time. Furthermore,
733 instead of driver, the PCM application should call a helper function of ALSA
734 PCM core to update a position to head of hardware transmission and to check
741 scheduling model and available as long as hardware/driver assists
742 .I no\-period\-wakeup
743 runtime. Users should explicitly set this mode by usage of
749 In the scheduling model, PCM applications need to care of available space on
750 PCM buffer by lapse of time, typically by yielding CPU and wait for
751 rescheduling. For the yielding, timeout is calculated for preferable amount of
752 PCM frames to process. This is convenient to a kind of applications, like sound
753 servers. when an I/O thread of the server wait for the timeout, the other
754 threads can process audio data frames for server clients. Furthermore, with
755 usage of rewinding/forwarding, applications can achieve low latency between
756 transmission position and handling position even if they uses large size of
759 .SS Advantages and issues
761 Ideally, timer\-based scheduling model has some advantages than IRQ\-based
762 scheduling model. At first, no interrupt context runs for PCM substream. The
763 PCM substream is handled in any process context only. No need to care of race
764 conditions between IRQ and process contexts. This reduces some concerns for
765 some developers of drivers and applications. Secondary, CPU time is not used
766 for handlers on the interrupt context. The CPU time can be dedicated for the
767 other tasks. This is good in a point of Time Sharing System. Thirdly, hardware
768 is not configured to generate interrupts. This is good in a point of reduction
769 of overall power consumption possibly.
771 In either scheduling model, the hardware should allow drivers to read the
772 number of audio data frame transferred between the dedicated memory and the
773 device memory for audio serial bus. However, in timer\-based scheduling model,
774 fine granularity and accuracy of the value is important. Actually hardware
775 performs transmission between dedicated memory and device memory for a small
776 batch of audio data frames or bytes. In a view of PCM applications, the
777 granularity in current transmission is required to decide correct timeout for
778 each I/O operation. As of Linux kernel v4.21, ALSA PCM interface between
779 kernel/userspace has no feature to report it.
781 .SH COMPATIBILITY TO APLAY
787 is designed to keep compatibility to aplay(1). However some options below are
788 not compatible due to several technical reasons.
791 .I \-I, \-\-separate\-channels
792 This option is supported just for files to store audio data frames corresponding
793 to each channel. In aplay(1) implementation, this option has an additional
794 effect to use PCM buffer aligned to non\-interleaved order if a target device
795 supports. As of 2018, PCM buffer of non\-interleaved order is hardly used by
799 .I \-A, \-\-avail\-min
800 This option indicates threshold to wake up blocked process in a unit of
801 audio data frame. Against aplay(1) implementation, this option has no effect
811 .I \-R, \-\-start\-delay
812 This option indicates threshold to start prepared PCM substream in a unit of
813 audio data frame. Against aplay(1) implementation, this option has no effect
823 .I \-T, \-\-stop\-delay
824 This option indicates threshold to stop running PCM substream in a unit of
825 audio data frame. Against aplay(1) implementation, this option has no effect
835 .I \-\-max\-file\-time=#
836 This option is unsupported. In aplay(1) implementation, the option has an
837 effect for capture transmission to save files up to the same number of data
838 frames as the given value by second unit, or the maximum number of data frames
839 supported by used file format. When reaching to the limitation, used file is
840 closed, then new file is opened and audio data frames are written. However, this
841 option requires extra handling of files and shall increase complexity of main
845 .I \-\-use\-strftime=FORMAT
846 This option is unsupported. In aplay(1) implementation, the option has an effect
847 for capture transmission to generate file paths according to given format in
848 which some extra formats are available as well as formats supported by
849 strftime(3). However, this option requires extra string processing for file
850 paths and it\(aqs bothersome if written in C language.
853 .I \-\-process\-id\-file=FILEPATH
854 This option is unsupported. In aplay(1) implementation, the option has an effect
855 to create a file for given value and write out process ID to it. This file
856 allows users to get process ID and send any POSIX signal to aplay process.
857 However, this idea has some troubles for file locking when multiple aplay
858 processes run with the same file.
861 .I \-V, \-\-vumeter=TYPE
862 This option is not supported at present. In aplay(1) implementation, this option
863 has an effect to occupy stdout with some terminal control characters and display
864 vumeter for monaural and stereo channels. However, some problems lay; this
865 feature is just for audio data frames with PCM format, this feature brings
866 disorder of terminal after aborting, stdout is not available for pipeline.
869 .I \-i, \-\-interactive
870 This option is not supported at present. In aplay(1) implementation, this option
871 has an effect to occupy stdin for key input and suspend/resume PCM substream
872 according to pushed enter key. However, this feature requires an additional
873 input handling in main loop and leave bothersome operation to maintain PCM
877 .I \-m, \-\-chmap=CH1,CH2,...
878 ALSA PCM core and control core doesn't support this feature, therefore
879 remapping should be done in userspace. This brings overhead to align audio
880 data frames, especially for mmap operation. Furthermore, as of alsa-lib v1.1.8,
881 some plugins don't support this feature expectedly, thus this option is a lack
882 of transparent operation. At present, this option is not supported yet not to
887 This performs suspend/resume of PCM substream. In aplay(1) implementation,
888 these operations bring XRUN state to the substream, and suspend/resume is done
889 in interactive mode in the above. Some developers use the signal for recovery
890 test from XRUN. At present, no alternative is supported for the test.
894 This is not supported. In aplay(1) implementation, this signal is assigned to a
895 handler to close a current file to store audio data frame and open a new file
896 to continue processing. However, as well as
897 .I \-\-max\-file\-time
898 option, this option should increase complexity of main loop of axfer.
902 .SS Modular structure
904 This program consists of three modules;
911 Each module has an abstraction layer to enable actual implementation.
914 -------- ---------- -------------
915 device <-> | xfer | <-> | mapper | <-> | container | <-> file
916 -------- ---------- -------------
925 module performs actual transmission to devices and nodes. The module can have
926 several transmission backends. As a default backend,
928 backend is used to perform transmission via alsa\-lib APIs. The module allows
929 each backend to parse own command line options.
933 module performs to read/write audio data frame via descriptor for file/stream
934 of multimedia container or raw data. The module automatically detect type of
935 multimedia container and parse parameters in its metadata of data header. At
936 present, three types of multimedia containers are supported; Microsoft/IBM
941 ) and Creative Technology voice (
943 ). Additionally, a special container is prepared for raw audio data (
949 module handles buffer layout and alignment for transmission of audio data frame.
950 The module has two implementations;
957 backend uses one container to construct the buffer. The
959 backend uses several containers to construct it.
961 .SS Care of copying audio data frame
967 module, a pointer to buffer including audio data frames is passed. This buffer
968 has two shapes for interleaved and non\-interleaved order. For the former, the
969 pointer points to one buffer. For the latter, the pointer points to an array in
970 which each element points to one buffer. Between the
974 module, a pointer to one buffer is passed because supported media containers
975 including raw type store audio data frames in interleaved order.
977 In passing audio data frame between the modules, axfer is programmed to avoid
978 copying between a buffer to another buffer as much as possible. For example, in
979 some scenarios below, no copying occurs between modules.
981 - xfer(mmap/interleaved), mapper(single), container(any)
982 - xfer(mmap/non\-interleaved), mapper(multiple), containers(any)
990 module, unit test is available. To run the tests, execute below command:
996 Each test iterates writing to file and reading to the file for many times and it
997 takes long time to finish. Please take care of the execution time if running on
1009 Takashi Sakamoto <o\-takashi@sakamocchi.jp>