⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 oss_dev.cpp

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 CPP
字号:
/*//////////////////////////////////////////////////////////////////////////////////                  INTEL CORPORATION PROPRIETARY INFORMATION//     This software is supplied under the terms of a license agreement or//     nondisclosure agreement with Intel Corporation and may not be copied//     or disclosed except in accordance with the terms of that agreement.//          Copyright(c) 2003-2005 Intel Corporation. All Rights Reserved.//*/////      This file contains class covering OSS Linux devices interface//#include "umc_defs.h"#ifdef UMC_ENABLE_OSS_AUDIO_RENDER#include <sys/soundcard.h>#include "fcntl.h"#include "oss_dev.h"#include "vm_debug.h"UMC::StatusUMC::OSSDev::Init(const vm_var32 uiBitsPerSample,                  const vm_var32 uiNumOfChannels,                  const vm_var32 uiFreq){    UMC::Status umcRes = UMC_OK;    if (UMC_OK == umcRes)    {   umcRes = m_Device.Init(VM_STRING("/dev/dsp"), O_WRONLY);    }    if (UMC_OK == umcRes)    {        m_uiBitsPerSample = uiBitsPerSample;        m_uiNumOfChannels = uiNumOfChannels;        m_uiFreq = uiFreq;        umcRes = Reset();    }    if (UMC_OK == umcRes)    {   vm_debug_trace(4, VM_STRING("OSSDev::Init OK\n"));  }    else    {   vm_debug_trace(7, VM_STRING("OSSDev::Init failed\n"));  }    return umcRes;}UMC::StatusUMC::OSSDev::RenderData(vm_byte* pbData, vm_var32 uiDataSize){    if (0x3 & uiDataSize)    {        vm_debug_trace(7, VM_STRING("OSSDev::RenderData data size misalignment: %d\n"),                                                                    uiDataSize);    }    m_uiBytesPlayed += uiDataSize;    return m_Device.Write(pbData, uiDataSize, NULL);}UMC::StatusUMC::OSSDev::SetBitsPerSample(const vm_var32 uiBitsPerSample){    Status umcRes = UMC_OK;    vm_var32 uiFormat;    switch (uiBitsPerSample)    {    case 16:        uiFormat = AFMT_S16_LE;        break;    case 8:        uiFormat = AFMT_S8;        break;    default:        vm_debug_trace(7,            VM_STRING("OSSDev::SetBitsPerSample - unsupported: %dbps requested\n"),            uiFormat);        umcRes = UMC_UNSUPPORTED;    }    vm_var32 uiFormatSet = uiFormat;    if (UMC_OK == umcRes)    {   umcRes = m_Device.Ioctl(SNDCTL_DSP_SETFMT, (vm_var32)&uiFormatSet); }    if (UMC_OK == umcRes && uiFormat != uiFormatSet)    {        umcRes = UMC_UNSUPPORTED;        vm_debug_trace(7,            VM_STRING("OSSDev::SetBitsPerSample - unsupported: %dbps requested, %dbps returned\n"),            uiFormat, uiFormatSet);    }    return umcRes;}UMC::StatusUMC::OSSDev::SetNumOfChannels(const vm_var32 uiNumOfChannels){    Status umcRes = UMC_OK;    vm_var32 uiNumOfChannelsSet = uiNumOfChannels;    if (UMC_OK == umcRes)    {        umcRes = m_Device.Ioctl(SNDCTL_DSP_CHANNELS,                                (vm_var32)&uiNumOfChannelsSet);    }    if (UMC_OK == umcRes && uiNumOfChannels != uiNumOfChannelsSet)    {        vm_debug_trace(7,            VM_STRING("OSSDev::SetNumOfChannels - unsupported: %d channels requested, %d channels returned\n"),            uiNumOfChannels, uiNumOfChannelsSet);        umcRes = UMC_UNSUPPORTED;    }    return umcRes;}UMC::StatusUMC::OSSDev::SetFreq(const vm_var32 uiFreq){    Status umcRes = UMC_OK;    vm_var32 uiFreqSet = uiFreq;    if (UMC_OK == umcRes)    {   umcRes = m_Device.Ioctl(SNDCTL_DSP_SPEED, (vm_var32)&uiFreqSet);    }    if (UMC_OK == umcRes && uiFreq != uiFreqSet)    {        vm_debug_trace(7,            VM_STRING("OSSDev::SetFreq - unsupported: %dHz requested, %dHz returned\n"),            uiFreq, uiFreqSet);        umcRes = UMC_UNSUPPORTED;    }    return umcRes;}UMC::StatusUMC::OSSDev::Post(){    Status umcRes = m_Device.Ioctl(SNDCTL_DSP_POST);    if (UMC_OK != umcRes)    {   vm_debug_trace(7, VM_STRING("OSSDev::Post failed\n"));  }    return umcRes;}UMC::StatusUMC::OSSDev::Reset(){    Status umcRes = m_Device.Ioctl(SNDCTL_DSP_RESET);    if (UMC_OK == umcRes)    {   umcRes = SetBitsPerSample(m_uiBitsPerSample);   }    if (UMC_OK == umcRes)    {   umcRes = SetNumOfChannels(m_uiNumOfChannels);   }    if (UMC_OK == umcRes)    {   umcRes = SetFreq(m_uiFreq);    }    if (UMC_OK != umcRes)    {   vm_debug_trace(7, VM_STRING("OSSDev::Reset failed\n"));  }    m_uiBytesPlayed = 0;    return umcRes;}UMC::StatusUMC::OSSDev::GetBytesPlayed(vm_var32& ruiBytesPlayed){    Status umcRes = UMC_OK;    count_info Info;    Info.bytes = 0;    umcRes = m_Device.Ioctl(SNDCTL_DSP_GETODELAY,(vm_var32)&Info);    if (UMC_OK == umcRes)    {   ruiBytesPlayed = m_uiBytesPlayed - Info.bytes;    }    return umcRes;}#endif // UMC_ENABLE_OSS_AUDIO_RENDER

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -