View Single Post
Old 04-12-2020, 12:39 PM   #33
dhdurgee
Guru
dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.
 
Posts: 910
Karma: 3000002
Join Date: Jun 2010
Device: K3W, PW4
Quote:
Originally Posted by geek1011 View Post
I've extracted it from the latest update package. Also, gst-launch is present.

Code:
$ find update_kindle_all_new_paperwhite_v2_5.12.4 | grep -e gst-launch -e mixer
update_kindle_all_new_paperwhite_v2_5.12.4/fwo_rootfs/usr/share/alsa/smixer.conf
update_kindle_all_new_paperwhite_v2_5.12.4/fwo_rootfs/usr/bin/gst-launch-0.10
update_kindle_all_new_paperwhite_v2_5.12.4/fwo_rootfs/usr/bin/alsamixer
update_kindle_all_new_paperwhite_v2_5.12.4/fwo_rootfs/usr/bin/amixer
update_kindle_all_new_paperwhite_v2_5.12.4/fwo_rootfs/usr/bin/gst-launch
update_kindle_all_new_paperwhite_v2_5.12.4/fwo_rootfs/usr/lib/gstreamer-0.10/libgstmixersink.so
update_kindle_all_new_paperwhite_v2_5.12.4/fwo_rootfs/usr/lib/gstreamer-0.10/libgstmixersink.so.1.0
update_kindle_all_new_paperwhite_v2_5.12.4/fwo_rootfs/usr/lib/gstreamer-0.10/libgstmixersink.so.1
update_kindle_all_new_paperwhite_v2_5.12.4/fwo_rootfs/usr/lib/libmixerCommon.so.1
update_kindle_all_new_paperwhite_v2_5.12.4/fwo_rootfs/usr/lib/libmixerCommon.so.1.0
update_kindle_all_new_paperwhite_v2_5.12.4/fwo_rootfs/usr/lib/alsa-lib/smixer
update_kindle_all_new_paperwhite_v2_5.12.4/fwo_rootfs/usr/lib/alsa-lib/smixer/smixer-ac97.so
update_kindle_all_new_paperwhite_v2_5.12.4/fwo_rootfs/usr/lib/alsa-lib/smixer/smixer-hda.so
update_kindle_all_new_paperwhite_v2_5.12.4/fwo_rootfs/usr/lib/alsa-lib/smixer/smixer-sbase.so
update_kindle_all_new_paperwhite_v2_5.12.4/fwo_rootfs/usr/lib/libmixerAPI.so.1
update_kindle_all_new_paperwhite_v2_5.12.4/fwo_rootfs/usr/lib/libmixerCommon.so
update_kindle_all_new_paperwhite_v2_5.12.4/fwo_rootfs/usr/lib/libmixerAPI.so.1.0
update_kindle_all_new_paperwhite_v2_5.12.4/fwo_rootfs/usr/lib/libmixerAPI.so
The interface seems simple enough to use directly with dlsym. The lib seems to support both C++ (mixer::*) and C (Mixer*).

The easiest way to use it would probably to write an output adapter for miniaudio (a single-file C audio lib) or to use it through gstreamer (with gst-launch or directly).

Some random notes:
- It's thread-safe.
- The C interface is just a wrapper for the C++ one.
- /var/run/mixer
- */mstream

Try something like:
cat raw_audio_s16le_4800.bin | /usr/bin/gst-launch filesrc location=/dev/stdin ! rawaudioparse use-sink-caps=false format=pcm pcm-format=s16le sample-rate=48000 ! audioconvert ! audioresample ! mixersink
where raw_audio_s16le_4800.bin is raw audio from something like:
ffmpeg -i audio.file -f s16le -acodec pcm_s16le -ac 2 -ar 48000 raw_audio_s16le_4800.bin

Or, compile this, and run something like:
./audioconverter audio.file /dev/stdout | /usr/bin/gst-launch filesrc location=/dev/stdin ! wavparse ! audioconvert ! audioresample ! mixersink

libaudioclient (used by libasrEarcon) seems to have a higher-lever wrapper around libmixerAPI which supports playing WAV files. It should be simple enough to adapt it to play anything. /usr/bin/ivonattsd makes use of this.

Some more notes on libmixerAPI usage:
- MixerOpenPlay returns 1 (failure) or 0 (success).
- You need to use MixerGetSampleSizeBits to get the current bit depth (i.e. 16-bit).
- To play samples, do MixerGetBufPlay, memcpy the samples, then MixerReleaseBufPlay.
- MixerWaitTillAudioProcessed waits until the buffer has been emptied (i.e. to play audio, loop between MixerWaitTillAudioProcessed/MixerGetBufPlay/memcpy/MixerReleaseBufPlay/decode until there isn't any more audio left to play).
- MixerClose takes the address of the mixer and destroys it.
- If you use libaudioclient instead, it's as simple as audio_initializeStream/audio_playWaveSamples/audio_waitForCompletion/audio_destroyStream).


From your research I agree that libaudioclient appears to be the simplest approach. As from my earlier post, I had planned to use mplayer to originate the audio stream. I should be able to get mplayer to pipe a stream in WAV format, but I guess I will need a program to accept it and pass it on via libaudioclient. What resources available on the pw4 can be used for this purpose? As you noted ivonattsd makes use of libaudioclient, but it is dedicated for another purpose. I assume that there is no existing program on the pw4 right now that will address this problem, so one will need to be built.

Dave

Last edited by dhdurgee; 04-12-2020 at 12:41 PM. Reason: typo
dhdurgee is offline   Reply With Quote