Hi,

I recently created a new PA module (module-log-pcm) which is able to log PCM 
samples from any source/sink and its corresponding outputs/inputs. For testing 
audio quality, checking signal processing or verifying the right implementation 
of a sound device mixed in PA, application fields are many. One just needs to 
give a parameter list depending on what is wished to be logged. During the 
process, an audio tree, or parts of it, is probed and logged for post-treatment 
purposes. For design needs, sources and sinks are designated by "ends" and 
source outputs/sink inputs by "ports".

Module-log-pcm's main characteristics are :

- Core principles : given a source or a sink name, a working source output used 
only for log is created and plugged (to the sink.monitor in case of a sink). 
PCM samples are handled in the push callback and can be redirected to any log 
device. For ports (SO/SI), the only information available is the connected 
sink/source and the index. As a result, hooks in the pulsecore have been 
necessary to capture PCM chunks, before resampling for sink inputs and after 
resampling for source outputs.

- Choice between a local or remote target : this functionnality uses pa_object 
object-oriented library. Depending if the log is saved in a wave file or 
written to any other type of file descriptor (type of target), a "serializer" 
implementation does the logging of PCM samples. Each serializer 
(local-file-serializer or remote-device-serializer) is defined within 
PA_DEFINE_PUBLIC_CLASS that allows a kind of function polymorphism. Wave files 
are named per end or port names, e.g. "sink_name.wav" and for ports, the index 
is appended to the log file name, e.g. for index 2 :  "sink_name_2.wav".
For local log : libsndfile is used to log in wav files in the same manner as 
pacat. A directory is specified in parameter, where all the wav files can be 
stored.
For remote log (in opposite to local log..) : a header is attached at the 
beginning of the log file, containing sample spec informations, signal strength 
(volume ?), source/sink name...

- Log of sources/sinks with or without their outputs/inputs :
All or none of the ports can be logged by means of an option specified at the 
module loading : trace_ports=<yes/no> .

- Management of put, move, unlink events :
If an end is declared to be logged, it will be monitored whatever its creation 
comes after or before the loading of module-log-pcm, and for move events, a new 
log file will be created after each move to help distinguish the samples. The 
"move" prefix along with a number is appended to the log file name. Also when a 
device is unlinked, its corresponding log file will be closed.

- Support of most of the data sample formats :
Data formats like PA_SAMPLE_S24_32NE can also be logged, but a realignment of 
the 24 bits on 32 bits is necessary to ensure correct audio restitution in a 
wave file.


These are examples of logging different sinks/sources to a target :

Log specified sinks and one source with their ports, in wav files to directory 
wav_log_files :
Load module-log-pcm 
sinks_to_log=alsa_output.intel_mfld_msic_audio.earphone,sink.music 
sources_to_log=source.record trace_ports=yes 
log_target=/home/vincent/wav_log_files/

We shall get wave files like these : 
alsa_output.intel_mfld_msic_audio.earphone.wav
alsa_output.intel_mfld_msic_audio.earphone_0.wav
sink.music.wav
sink_music_1.wav
source.record.wav
source_record_2.wav

Log specified sinks and sources (note the .monitor is in the list of sources) 
without their ports to a remote device :
Load module-log-pcm sinks_to_log=alsa_output.intel_mfld_msic_audio.earphone 
sources_to_log=sink.hsandihf.monitor,source.record trace_ports=no 
log_target=/dev/remote_snd


The development might look a bit ackward and certainly still needs 
modifications but it macan be seen as the first stone of experimental logging..
Please feel free to comment.

Thanks,
Vincent

Vincent Becker (1):
  Log module: new module to log PCM chunks.

 src/Makefile.am                            |   11 +-
 src/modules/log/local-file-serializer.c    |  181 +++++
 src/modules/log/local-file-serializer.h    |   47 ++
 src/modules/log/log-pcm-serializer.c       |   50 ++
 src/modules/log/log-pcm-serializer.h       |   52 ++
 src/modules/log/module-log-pcm.c           | 1113 ++++++++++++++++++++++++++++
 src/modules/log/pcm-logger-data.h          |   57 ++
 src/modules/log/remote-device-serializer.c |  140 ++++
 src/modules/log/remote-device-serializer.h |   48 ++
 src/pulsecore/core.h                       |    2 +
 src/pulsecore/sink-input.c                 |   18 +
 src/pulsecore/sink-input.h                 |    5 +
 src/pulsecore/source-output.c              |   27 +-
 src/pulsecore/source-output.h              |    6 +
 14 files changed, 1753 insertions(+), 4 deletions(-)
 create mode 100755 src/modules/log/local-file-serializer.c
 create mode 100755 src/modules/log/local-file-serializer.h
 create mode 100755 src/modules/log/log-pcm-serializer.c
 create mode 100755 src/modules/log/log-pcm-serializer.h
 create mode 100755 src/modules/log/module-log-pcm.c
 create mode 100755 src/modules/log/pcm-logger-data.h
 create mode 100755 src/modules/log/remote-device-serializer.c
 create mode 100755 src/modules/log/remote-device-serializer.h

-- 
1.7.2.3

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

_______________________________________________
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss

Reply via email to