📄 audio.cc
字号:
//// Copyright (c) 2002 by Istv醤 V醨adi//// This file is part of dxr3Player, a DVD player written specifically // for the DXR3 (aka Hollywood+) decoder card.// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.//// You should have received a copy of the GNU General Public License// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA//------------------------------------------------------------------------------#include "Audio.h"#include "DXR3.h"#include "util/Log.h"#include <linux/em8300.h>#include <linux/soundcard.h>//------------------------------------------------------------------------------using dxr3::Audio;//------------------------------------------------------------------------------void Audio::executeCommand(int command){ dxr3.executeCommand(27, command, 28, command); // FIXME: register constants}//------------------------------------------------------------------------------void Audio::initialize(unsigned deviceNumber){ stream.open(deviceNumber, O_RDWR|O_NONBLOCK, "ma"); setup(AM_ANALOGUE, 48000, true);}//------------------------------------------------------------------------------void Audio::setup(audioMode_t mode, unsigned rate, bool s){ audioMode = mode; sampleRate = rate; stereo = s; int dspFormat = AFMT_S16_LE; int dspSpeed = (int)sampleRate; int dspStereo = stereo ? 1 : 0; int ioctlMode = 0; switch(audioMode) { case AM_ANALOGUE: ioctlMode = EM8300_AUDIOMODE_ANALOG; break; case AM_DIGITAL_PCM: ioctlMode = EM8300_AUDIOMODE_DIGITALPCM; break; case AM_DIGITAL_AC3: ioctlMode = EM8300_AUDIOMODE_DIGITALAC3; dspFormat = AFMT_AC3; break; } stream.ioctl(SNDCTL_DSP_SPEED, &dspSpeed, "Error setting audio sample rate to %d", dspSpeed); stream.ioctl(SNDCTL_DSP_STEREO, &dspStereo, "Error setting DSP stereo to %d", dspStereo); stream.ioctl(SNDCTL_DSP_SETFMT, &dspFormat, "Error setting audio format to %d", dspFormat); dxr3.dev.ioctl(EM8300_IOCTL_SET_AUDIOMODE, &ioctlMode, "Error setting audio mode to %d", ioctlMode);}//------------------------------------------------------------------------------void Audio::play(){ executeCommand(MACOMMAND_PLAY);}//------------------------------------------------------------------------------void Audio::pause(){ executeCommand(MACOMMAND_PAUSE);}//------------------------------------------------------------------------------void Audio::stop(){ executeCommand(MACOMMAND_STOP);}//------------------------------------------------------------------------------void Audio::flush(){ unsigned subDevice = EM8300_SUBDEVICE_AUDIO; dxr3.dev.ioctl(EM8300_IOCTL_FLUSH, &subDevice, "Error flushing audio");}//------------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -