示例#1
0
/*
 *  -doxygen comments moved to header-
 *
 *	Constructs, and returns a pointer to, a new CMMFDevSound object.
 *
 *	Leaves on failure.
 *
 */
EXPORT_C CMMFDevSound* CMMFDevSound::NewL()
{
    CMMFDevSound* self = new (ELeave) CMMFDevSound;
    CleanupStack::PushL(self);
    self->ConstructL();
    CleanupStack::Pop();
    return self;
}
/**
 * Create an instance of CAudioOutput
 * @param aSection  - Section to read param from the ini file
 * @return none
 */
void CT_CAudioOutputData::DoCmdNewL(const TTEFSectionName& aSection) //quite return
	{
	DestroyData();
	INFO_PRINTF1(_L("*START*CT_CAudioOutputData::DoCmdNewL"));
	TPtrC devSoundObject;
    if( !GetStringFromConfig(aSection, KDevSoundKey, devSoundObject) )
    	{
    	ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDevSoundKey);
    	SetBlockResult(EFail);
    	}
    else
    	{
	    CMMFDevSound* DevSoundObject = static_cast<CMMFDevSound*>(GetDataObjectL(devSoundObject));
	    iAudioOutput = (CAudioOutput*)DevSoundObject->CustomInterface(KUidAudioOutput);
	    INFO_PRINTF1(_L("*END*CT_CAudioOutputData::DoCmdNewL"));
    	}
    }
示例#3
0
void DevSoundCapabilities::constructL(CMMFDevSound &devsound,
                                      QAudio::Mode mode)
{
    m_caps = devsound.Capabilities();

    TMMFPrioritySettings settings;

    switch (mode) {
    case QAudio::AudioOutput:
        settings.iState = EMMFStatePlaying;
        devsound.GetSupportedInputDataTypesL(m_fourCC, settings);
        break;

    case QAudio::AudioInput:
        settings.iState = EMMFStateRecording;
        devsound.GetSupportedInputDataTypesL(m_fourCC, settings);
        break;

    default:
        Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid mode");
    }
}
示例#4
0
void CCmdPlay::DoRunL()
	{
	if (iMaxVolume)
		{
		// we use DevSound to get the max volume, as CMdaAudioRecorderUtility
		// always returns 0 until we have opened a file.
		CMMFDevSound* devSound = CMMFDevSound::NewL();
		TInt maxVol = devSound->MaxVolume();
		TBool cons = Stdout().AttachedToConsole();
		if (cons) Printf(_L("Maximum volume: "));
		Printf(_L("%d"), maxVol);
		if (cons) Printf(_L("\r\n"));
		delete devSound;
		}
	else
		{
		if (!iArguments.IsPresent(0)) 
			{
			PrintError(KErrArgument, _L("No filename specified"));
			DisplayHelp();
			Complete(KErrArgument);
			return;
			}
		iPlayer->GetReady(iFile, iVerbose);
		if (iOptions.IsPresent(&iPriority) || iOptions.IsPresent(&iPreference))
			{
			iPlayer->SetPriority(iPriority, iPreference);
			}
		if (iOptions.IsPresent(&iVolume))
			{
			iPlayer->SetVolume(iVolume);
			}
		CActiveScheduler::Start();
		User::LeaveIfError(iPlayer->Error());
		}
	}
示例#5
0
/*!
  Constructor.
*/
PushAudioOut::PushAudioOut(AudioSource *source, QObject *parent /* = 0 */)
    : QThread(parent),
      m_audioOutput(0),
      m_outTarget(0),
      m_sendBuffer(0),
      m_sendBufferSize(0),
      m_samplesMixed(0),
      m_threadState(NotRunning),
      m_source(source)
{
    DEBUG_INFO(this);

    QAudioFormat format;
    format.setFrequency(AUDIO_FREQUENCY);
    format.setChannels(AUDIO_CHANNELS);
    format.setSampleSize(AUDIO_SAMPLE_BITS);
    format.setCodec(GEDefaultAudioCodec);
    switch (GEByteOrder) {
    case BigEndian:
        format.setByteOrder(QAudioFormat::BigEndian);
        break;
    case LittleEndian:
        format.setByteOrder(QAudioFormat::LittleEndian);
        break;
    default:
        DEBUG_INFO("INVALID BYTE ORDER");
    }
    switch (GESampleType) {
    case Unknown:
        format.setSampleType(QAudioFormat::Unknown);
        break;
    case SignedInt:
        format.setSampleType(QAudioFormat::SignedInt);
        break;
    case UnSignedInt:
        format.setSampleType(QAudioFormat::UnSignedInt);
        break;
    case Float:
        format.setSampleType(QAudioFormat::Float);
        break;
    default:
        DEBUG_INFO("INVALID SAMPLE TYPE");
    }
    QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());

    if (!info.isFormatSupported(format))
        format = info.nearestFormat(format);

    m_audioOutput = new QAudioOutput(info, format);

#if defined(Q_WS_MAEMO_5) || defined(MEEGO_EDITION_HARMATTAN)
    m_sendBufferSize = 4096 * 4;
#else
    m_audioOutput->setBufferSize(4096 * 4);
#endif

#if defined(Q_WS_MAEMO_5) || defined(MEEGO_EDITION_HARMATTAN)
    m_audioOutput->setBufferSize(4096 * 16);
    m_sendBufferSize = 4096 * 8;
#else
    m_audioOutput->setBufferSize(4096 * 4);
    m_sendBufferSize = 4096 * 2;
#endif

    DEBUG_INFO("Buffer size: " << m_audioOutput->bufferSize());
    m_sendBuffer = new AUDIO_SAMPLE_TYPE[m_sendBufferSize];

    m_needsTick = false;
#if defined(QTGAMEENABLER_USE_VOLUME_HACK) && defined(Q_OS_SYMBIAN)
    DEBUG_INFO("WARNING: Using the volume hack!");

    // This really ugly hack is used as the last resort. This allows us to
    // adjust the application volume in Symbian. The CMMFDevSound object lies
    // deep inside the QAudioOutput in Symbian implementation and it has the
    // needed functions. So, we dig the required object accessing it directly
    // from memory.
    unsigned int *pointer_to_abstract_audio =
            (unsigned int*)((unsigned char*)m_audioOutput + 8);

    unsigned int *dev_sound_wrapper =
            (unsigned int*)(*pointer_to_abstract_audio) + 13;

    unsigned int *temp = ((unsigned int*)(*dev_sound_wrapper) + 6);

    CMMFDevSound *devSound = (CMMFDevSound*)(*temp);
    devSound->SetVolume(devSound->MaxVolume() * 6 / 10);
#endif

}
示例#6
0
PullAudioOut::PullAudioOut(AudioSource *source, QObject *parent)
    : QIODevice(parent),
      m_source(source)
{
    DEBUG_INFO(this);

    QAudioFormat format;
    format.setFrequency(AUDIO_FREQUENCY);
    format.setChannels(AUDIO_CHANNELS);
    format.setSampleSize(AUDIO_SAMPLE_BITS);
    format.setCodec(GEDefaultAudioCodec);
    switch (GEByteOrder) {
    case BigEndian:
        format.setByteOrder(QAudioFormat::BigEndian);
        break;
    case LittleEndian:
        format.setByteOrder(QAudioFormat::LittleEndian);
        break;
    default:
        DEBUG_INFO("INVALID BYTE ORDER");
    }
    switch (GESampleType) {
    case Unknown:
        format.setSampleType(QAudioFormat::Unknown);
        break;
    case SignedInt:
        format.setSampleType(QAudioFormat::SignedInt);
        break;
    case UnSignedInt:
        format.setSampleType(QAudioFormat::UnSignedInt);
        break;
    case Float:
        format.setSampleType(QAudioFormat::Float);
        break;
    default:
        DEBUG_INFO("INVALID SAMPLE TYPE");
    }

    QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());

    if (!info.isFormatSupported(format))
        format = info.nearestFormat(format);

    m_sendBufferSize = 4096;
    m_audioOutput = new QAudioOutput(info, format);

#if defined(QTGAMEENABLER_USE_VOLUME_HACK) && defined(Q_OS_SYMBIAN)
    DEBUG_INFO("WARNING: Using the volume hack!");

    // This really ugly hack is used as the last resort. This allows us to
    // adjust the application volume in Symbian. The CMMFDevSound object lies
    // deep inside the QAudioOutput in Symbian implementation and it has the
    // needed functions. So, we get the needed object accessing it directly
    // from memory.
    unsigned int *pointer_to_abstract_audio =
            (unsigned int*)((unsigned char*)m_audioOutput + 8);

    unsigned int *dev_sound_wrapper =
            (unsigned int*)(*pointer_to_abstract_audio) + 13;

    unsigned int *temp = ((unsigned int*)(*dev_sound_wrapper) + 6);

    CMMFDevSound *devSound = (CMMFDevSound*)(*temp);
    devSound->SetVolume(devSound->MaxVolume() * 6 / 10);
#endif

    open(QIODevice::ReadOnly | QIODevice::Unbuffered);
    connect(m_audioOutput, SIGNAL(stateChanged(QAudio::State)),
        SLOT(audioStateChanged(QAudio::State)));
}