私はaplay -l, lsusb
から次を得る:Raspberry PiでC++/libao/alsaを使用してUSBサウンドカード経由でオーディオを再生するには?
[email protected]:~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: Device [USB PnP Sound Device], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: Device_1 [USB PnP Sound Device], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
[email protected]:~ $ lsusb
Bus 001 Device 005: ID 046d:c31c Logitech, Inc. Keyboard K120 for Business
Bus 001 Device 008: ID 0d8c:013c C-Media Electronics, Inc. CM108 Audio Controller
Bus 001 Device 007: ID 0d8c:013c C-Media Electronics, Inc. CM108 Audio Controller
Bus 001 Device 006: ID 05e3:0606 Genesys Logic, Inc. USB 2.0 Hub/D-Link DUB-H4 USB 2.0 Hub
Bus 001 Device 004: ID 1bcf:0005 Sunplus Innovation Technology Inc.
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
私はlibaoでCM108オーディオコントローラを経由して、私のMP3を再生したいです。私はこれらを試しました:
ao_initialize();
ao_option aoption;
ao_option *poption;
poption = &aoption;
poption->key = (char*)"dev";
poption->value = (char*)"hw:0";
dev = ao_open_live(driver, &format, poption);
while (mpg123_read(mh, buffer, buffer_size, &done) == MPG123_OK)
ao_play(dev, (char *)buffer, done);
サウンドはPiを介して正常に再生されます。私はhw:0がPiのサウンドカードであることを理解しています。第1または第2のCM108オーディオコントローラで再生したい場合、hw:0の代わりに何を使うべきですか?私はすでにhw:1とhw:2を試しましたが、うまくいきません。
aplayでwaveファイルを再生できますか?このコマンドを使用してください。aplay -D 'hw:1' file.wav – Varun