void CAESinkIntelSMD::Deinitialize() { VERBOSE2(); CSingleLock lock(m_SMDAudioLock); CLog::Log(LOGINFO, "%s", __DEBUG_ID__); if(!m_bIsAllocated) return; g_IntelSMDGlobals.DisableAudioOutput(g_IntelSMDGlobals.GetHDMIOutput()); g_IntelSMDGlobals.DisableAudioOutput(g_IntelSMDGlobals.GetSPDIFOutput()); g_IntelSMDGlobals.DisableAudioOutput(g_IntelSMDGlobals.GetI2SOutput()); //g_IntelSMDGlobals.BuildAudioOutputs(); g_IntelSMDGlobals.ConfigureMasterClock(48000); g_IntelSMDGlobals.SetAudioDeviceState(ISMD_DEV_STATE_STOP, m_audioDevice); g_IntelSMDGlobals.DisableAudioInput(m_audioDevice); g_IntelSMDGlobals.RemoveAudioInput(m_audioDevice); g_IntelSMDGlobals.SetPrimaryAudioDevice(-1); m_audioDevice = -1; m_audioDeviceInput = -1; // enable outputs g_IntelSMDGlobals.EnableAudioOutput(g_IntelSMDGlobals.GetHDMIOutput()); g_IntelSMDGlobals.EnableAudioOutput(g_IntelSMDGlobals.GetSPDIFOutput()); g_IntelSMDGlobals.EnableAudioOutput(g_IntelSMDGlobals.GetI2SOutput()); m_bIsAllocated = false; return; }
/** * Initialize platform level services. * * \note This must be called from the main thread due to issues with the devices * we use via the WINAPI, MCI (cdaudio, mixer etc) on the WIN32 platform. */ void Sys_Init(void) { uint startTime; Con_Message("Setting up platform state..."); startTime = (verbose >= 2? Timer_RealMilliseconds() : 0); VERBOSE( Con_Message("Initializing Audio subsystem...") ) S_Init(); #ifdef DENG_CATCH_SIGNALS // Register handler for abnormal situations (in release build). signal(SIGSEGV, handler); signal(SIGTERM, handler); signal(SIGILL, handler); signal(SIGFPE, handler); signal(SIGILL, handler); signal(SIGABRT, handler); #endif #ifndef WIN32 // We are not worried about broken pipes. When a TCP connection closes, // we prefer to receive an error code instead of a signal. signal(SIGPIPE, SIG_IGN); #endif VERBOSE( Con_Message("Initializing Network subsystem...") ) N_Init(); VERBOSE2( Con_Message("Sys_Init: Completed in %.2f seconds.", (Timer_RealMilliseconds() - startTime) / 1000.0f) ); }
void CDXAppView::SetVideoWindowSize(int width, int height) { CDXAppDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); int source_width, source_height; pDoc->GetDXManager()->GetVideoSourceSize(&source_width, &source_height); if (source_height<0) { source_height = -source_height; } CRect rc; GetClientRect( &rc ); if (width==0 && height==0) { width = source_width; height = source_height; // MoveWindow(&rc); } else { width = max(width, source_width); height = max(height, source_height); double ratio = (double)source_width/(double)source_height; width = min(width, (int)((double)height*ratio)); height = min(height, (int)((double)width/ratio)); } pDoc->GetDXManager()->SetVideoWindowPosition( rc.left, rc.top, width, height ); m_video_scale = (double)(rc.right-rc.left)/(double)source_width; m_local_fixed_mouse.x = m_virtual_mouse.x = (rc.right-rc.left)/2; m_local_fixed_mouse.y = m_virtual_mouse.y = (rc.bottom-rc.top)/2; SetScrollSizes(MM_TEXT, CSize(source_width, source_height)); VERBOSE2(4, "ApV: scroll size %d %d", source_width, source_height); }
static fi_state_t* stateForFinaleId(finaleid_t id) { if(finaleStackInited) { uint i; for(i = 0; i < finaleStackSize; ++i) { fi_state_t* s = &finaleStack[i]; if(s->finaleId == id) return s; } } if(IS_CLIENT) { if(remoteFinaleState.finaleId) { #ifdef _DEBUG VERBOSE2( Con_Message("stateForFinaleId: Finale %i is remote, using server's state (id %i).", id, remoteFinaleState.finaleId) ); #endif return &remoteFinaleState; } } return 0; }
void CDXAppView::OnSize(UINT nType, int cx, int cy) { CScrollView::OnSize(nType, cx, cy); VERBOSE2(4, "ApV: OnSize %d %d", cx, cy); SetVideoWindowSize(cx, cy); // Invalidate(true); }
void DxArchiverProxyInternal::setIntrinsics(const DxArchiverIntrinsics & intrinsics) { ACE_Guard<ACE_Recursive_Thread_Mutex> guard(intrinsicsMutex_); intrinsics_ = intrinsics; setNameInternal(intrinsics_.name); VERBOSE2(getVerboseLevel(), intrinsics_ ); }
void CAESinkIntelSMD::Drain() { VERBOSE2(); int milliseconds = (int)(GetCacheTime() * 1000.0); if (milliseconds) Sleep(++milliseconds); // add 1 for the possible truncation used in the conversion to int CLog::Log(LOGDEBUG, "%s delay:%dms now:%dms", __DEBUG_ID__, milliseconds, (int)(GetCacheTime() * 1000.0)); }
bool CAESinkIntelSMD::SoftResume() { VERBOSE2(); CSingleLock lock(m_SMDAudioLock); if (!m_bIsAllocated) return false; if (!m_bPause) return true; g_IntelSMDGlobals.SetAudioDeviceState(ISMD_DEV_STATE_PLAY, m_audioDevice); m_bPause = false; return true; }
/* * Set the data path. The game module is responsible for calling this. */ void R_InitDataPaths(const char *path, boolean justGamePaths) { int i; M_TranslatePath(path, dataPath); Dir_ValidDir(dataPath); VERBOSE(Con_Message("R_SetDataPath: %s\n", M_Pretty(dataPath))); // Update the paths of each class. for(i = 0; i < NUM_RESOURCE_CLASSES; i++) { // The Graphics class resources are under Doomsday's control. if(justGamePaths && i == RC_GRAPHICS) continue; memset(&classInfo[i], 0, sizeof(classInfo[i])); // The -texdir option specifies a path to look for TGA textures. if(ArgCheckWith(explicitOption[i][0], 1)) { M_TranslatePath(ArgNext(), classInfo[i].path); } else { // Build the path for the resource class using the default // elements. strcpy(classInfo[i].path, dataPath); strcat(classInfo[i].path, defaultResourcePath[i]); } Dir_ValidDir(classInfo[i].path); // The overriding path. if(ArgCheckWith(explicitOption[i][1], 1)) { M_TranslatePath(ArgNext(), classInfo[i].overridePath); } Dir_ValidDir(classInfo[i].overridePath); VERBOSE2(Con_Message (" %i: %s (%s)\n", i, M_Pretty(classInfo[i].path), M_Pretty(classInfo[i].overridePath))); } }
bool CAESinkIntelSMD::SoftSuspend() { VERBOSE2(); // We need to wait until we're done with our packets CSingleLock lock(m_SMDAudioLock); if (!m_bIsAllocated) return false; if (m_bPause) return true; g_IntelSMDGlobals.SetAudioDeviceState(ISMD_DEV_STATE_PAUSE, m_audioDevice); m_bPause = true; return true; }
CAESinkIntelSMD::CAESinkIntelSMD() { VERBOSE2(); m_bIsAllocated = false; m_latency = 0.025; m_dwChunkSize = 0; m_dwBufferLen = 0; m_dSampleRate = 0.0; m_frameSize = 0; m_audioDevice = -1; m_audioDeviceInput = -1; //m_fCurrentVolume = 0; if (!m_checkedCodecs) { m_checkedCodecs = true; for(int i = 1; i < ISMD_AUDIO_MEDIA_FMT_COUNT; ++i) CLog::Log(LOGDEBUG, "%s: ismd_audio_format %d codec available: %d", __DEBUG_ID__, i, ismd_audio_codec_available((ismd_audio_format_t)i) == ISMD_SUCCESS); } }
/* * Reads a zipentry into the buffer. The buffer must be large enough. * Zip_GetSize() returns the size. Returns the number of bytes read. */ uint Zip_Read(zipindex_t index, void *buffer) { package_t *pack; zipentry_t *entry; index--; if(index < 0 || index >= zipNumFiles) return 0; // Doesn't exist. entry = zipFiles + index; pack = entry->package; VERBOSE2(Con_Printf ("Zip_Read: %s: '%s' (%i bytes)\n", M_Pretty(pack->name), M_Pretty(entry->name), entry->size)); //Con_Printf("Zip_Read: offset=%i\n", entry->offset); F_Seek(pack->file, entry->offset, SEEK_SET); F_Read(buffer, entry->size, pack->file); // TODO: Use zlib to inflate deflated entries. return entry->size; }
/// disconnects from ecasound AudioRecorder::~AudioRecorder() { _eca.command("cs-disconnect"); // implies "stop" and "engine-halt" VERBOSE2("AudioRecorder dtor ('" + client_name + "')."); }
bool CAESinkIntelSMD::Initialize(AEAudioFormat &format, std::string &device) { VERBOSE2(); CLog::Log(LOGDEBUG, "%s: device: %s, data format: %s, sample rate: %d, channel count: %d, frame size: %d", __DEBUG_ID__, device.c_str(), CAEUtil::DataFormatToStr(format.m_dataFormat), format.m_sampleRate, format.m_channelLayout.Count(), format.m_frameSize); CSingleLock lock(m_SMDAudioLock); bool bIsHDMI = isHDMI(device); bool bIsSPDIF = isSPDIF(device); bool bIsAnalog = isAnalog(device); int deviceType = getDeviceType(device); ismd_result_t result; AEDataFormat inputDataFormat = format.m_dataFormat; bool bSPDIFPassthrough = false; bool bHDMIPassthrough = false; bool bIsRawCodec = AE_IS_RAW(inputDataFormat); format.m_sampleRate = getOutputSampleRate(deviceType, format.m_sampleRate); format.m_dataFormat = getAEDataFormat(deviceType, format.m_dataFormat, format.m_frameSize); int channels = format.m_channelLayout.Count(); // can not support more than 2 channels on anything other than HDMI if (channels > 2 && (bIsSPDIF || bIsAnalog)) channels = 2; // support for more than 8 channels not supported else if (channels > 8) channels = 8; ismd_audio_processor_t audioProcessor = -1; ismd_audio_format_t ismdAudioInputFormat = ISMD_AUDIO_MEDIA_FMT_INVALID; audioProcessor = g_IntelSMDGlobals.GetAudioProcessor(); if(audioProcessor == -1) { CLog::Log(LOGERROR, "%s audioProcessor is not valid", __DEBUG_ID__); return false; } // disable all outputs g_IntelSMDGlobals.DisableAudioOutput(g_IntelSMDGlobals.GetHDMIOutput()); g_IntelSMDGlobals.DisableAudioOutput(g_IntelSMDGlobals.GetSPDIFOutput()); g_IntelSMDGlobals.DisableAudioOutput(g_IntelSMDGlobals.GetI2SOutput()); m_audioDevice = g_IntelSMDGlobals.CreateAudioInput(false); if(m_audioDevice == -1) { CLog::Log(LOGERROR, "%s failed to create audio input", __DEBUG_ID__); return false; } g_IntelSMDGlobals.SetPrimaryAudioDevice(m_audioDevice); m_audioDeviceInput = g_IntelSMDGlobals.GetAudioDevicePort(m_audioDevice); if(m_audioDeviceInput == -1) { CLog::Log(LOGERROR, "%s failed to create audio input port", __DEBUG_ID__); return false; } ismdAudioInputFormat = GetISMDFormat(inputDataFormat); unsigned int uiBitsPerSample = CAEUtil::DataFormatToBits(format.m_dataFormat); unsigned int uiUsedBitsPerSample = CAEUtil::DataFormatToUsedBits(format.m_dataFormat); // Are we doing DD+ -> DD mode bool bAC3Encode = false; if (bIsHDMI) { unsigned int sampleRate = format.m_sampleRate; unsigned int bitsPerSample = uiUsedBitsPerSample; if (format.m_encodedRate != 0) sampleRate = format.m_encodedRate; unsigned int suggSampleRate = sampleRate; if (!CheckEDIDSupport(ismdAudioInputFormat, channels, suggSampleRate, bitsPerSample, bAC3Encode)) { if (suggSampleRate != sampleRate) format.m_sampleRate = suggSampleRate; if (bitsPerSample != uiUsedBitsPerSample) { if (uiUsedBitsPerSample == 24) { format.m_dataFormat = AE_FMT_S24NE4; uiUsedBitsPerSample = bitsPerSample; } else if (uiUsedBitsPerSample == 32) { format.m_dataFormat = AE_FMT_S32LE; uiUsedBitsPerSample = bitsPerSample; } else { format.m_dataFormat = AE_FMT_S16LE; uiUsedBitsPerSample = 16; } uiBitsPerSample = CAEUtil::DataFormatToBits(format.m_dataFormat); } //format.m_frameSize = uiBitsPerSample/4; } } else if (bIsSPDIF && ismdAudioInputFormat == ISMD_AUDIO_MEDIA_FMT_DD_PLUS && ISMD_SUCCESS == ismd_audio_codec_available((ismd_audio_format_t) ISMD_AUDIO_ENCODE_FMT_AC3)) { bAC3Encode = true; } unsigned int outputSampleRate = format.m_sampleRate; // for raw codecs, send as PCM passthrough if (!bAC3Encode && bIsRawCodec && ismdAudioInputFormat != ISMD_AUDIO_MEDIA_FMT_DD && ismdAudioInputFormat != ISMD_AUDIO_MEDIA_FMT_TRUE_HD) { format.m_dataFormat = AE_FMT_S16NE; ismdAudioInputFormat = ISMD_AUDIO_MEDIA_FMT_PCM; bHDMIPassthrough = bSPDIFPassthrough = true; } format.m_channelLayout.Reset(); if (bIsRawCodec) { for (int i = 0; i < channels; ++i) format.m_channelLayout += AE_CH_RAW; } // TODO: This currently handles Mono,Stereo, 5.1, 7.1 correctly // Handle the other cases (i.e. 6.1 DTS) else { for (int i = 0; i < channels; ++i) format.m_channelLayout += s_chMap[i]; } //TODO: Handle non normal channel configs (3 channel, etc). int inputChannelConfig = AUDIO_CHAN_CONFIG_2_CH; if (format.m_channelLayout.Count() == 1) inputChannelConfig = AUDIO_CHAN_CONFIG_1_CH; else if (format.m_channelLayout.Count() == 6) inputChannelConfig = AUDIO_CHAN_CONFIG_6_CH; else if (format.m_channelLayout.Count() == 8) inputChannelConfig = AUDIO_CHAN_CONFIG_8_CH; format.m_frameSize = channels * (CAEUtil::DataFormatToBits(format.m_dataFormat) >> 3); // if standard audio keep buffer small so delay is short if (!bIsRawCodec) { // try to keep roughly 5ms buffer using multiples of a 1024 buffer size int numBuffers = ((0.005*((double)(format.m_sampleRate*format.m_frameSize))) / 1024.0) + 0.5; if (numBuffers == 0) numBuffers = 1; else if (numBuffers > 8) numBuffers = 8; m_dwChunkSize = numBuffers*1024; } else { m_dwChunkSize = 8*1024; } m_dwBufferLen = m_dwChunkSize; format.m_frames = m_dwChunkSize/format.m_frameSize; format.m_frameSamples = format.m_frames*channels; m_frameSize = format.m_frameSize; CLog::Log(LOGINFO, "%s ismdAudioInputFormat %d\n", __DEBUG_ID__, ismdAudioInputFormat); int counter = 0; while(counter < 5) { result = ismd_audio_input_set_data_format(audioProcessor, m_audioDevice, ismdAudioInputFormat); if (result != ISMD_SUCCESS) { CLog::Log(LOGERROR, "%s ismd_audio_input_set_data_format failed. retrying %d %d", __DEBUG_ID__, counter, result); counter++; usleep(1000); } else break; } switch( ismdAudioInputFormat ) { case ISMD_AUDIO_MEDIA_FMT_DD: CLog::Log(LOGDEBUG, "%s: Initialize DD detected", __DEBUG_ID__); bHDMIPassthrough = bSPDIFPassthrough = true; break; case ISMD_AUDIO_MEDIA_FMT_DD_PLUS: CLog::Log(LOGDEBUG, "%s: Initialize DD Plus detected", __DEBUG_ID__); bHDMIPassthrough = true; // check special case for DD+->DD using DDCO if(bAC3Encode) { CLog::Log(LOGDEBUG, "%s: Initialize EAC3->AC3 transcoding is on", __DEBUG_ID__); bHDMIPassthrough = false; bAC3Encode = true; ConfigureDolbyPlusModes(audioProcessor, m_audioDevice, bAC3Encode); } break; case ISMD_AUDIO_MEDIA_FMT_DTS: case ISMD_AUDIO_MEDIA_FMT_DTS_LBR: CLog::Log(LOGDEBUG, "%s: Initialize DTS detected", __DEBUG_ID__); bHDMIPassthrough = bSPDIFPassthrough = true; break; case ISMD_AUDIO_MEDIA_FMT_DTS_HD: case ISMD_AUDIO_MEDIA_FMT_DTS_HD_MA: case ISMD_AUDIO_MEDIA_FMT_DTS_HD_HRA: CLog::Log(LOGDEBUG, "%s: Initialize DTS-HD detected", __DEBUG_ID__); bHDMIPassthrough = true; outputSampleRate = format.m_encodedRate; channels = 2; break; case ISMD_AUDIO_MEDIA_FMT_TRUE_HD: CLog::Log(LOGDEBUG, "%s: Initialize TrueHD detected", __DEBUG_ID__); bHDMIPassthrough = true; outputSampleRate = format.m_encodedRate; channels = 2; break; case ISMD_AUDIO_MEDIA_FMT_PCM: result = ismd_audio_input_set_pcm_format(audioProcessor, m_audioDevice, uiBitsPerSample, format.m_sampleRate, inputChannelConfig); if (result != ISMD_SUCCESS) { CLog::Log(LOGERROR, "%s - ismd_audio_input_set_pcm_format: %d", __DEBUG_ID__, result); // return false; } break; default: break; } // I2S. Nothing to touch here. we always use defaults // SPIDF if(bIsSPDIF) { ismd_audio_output_t OutputSPDIF = g_IntelSMDGlobals.GetSPDIFOutput(); ismd_audio_output_config_t spdif_output_config; ConfigureAudioOutputParams(spdif_output_config, AE_DEVTYPE_IEC958, uiUsedBitsPerSample, outputSampleRate, channels, ismdAudioInputFormat, bSPDIFPassthrough, bAC3Encode); if(!g_IntelSMDGlobals.ConfigureAudioOutput(OutputSPDIF, spdif_output_config)) { CLog::Log(LOGERROR, "%s ConfigureAudioOutput SPDIF failed %d", __DEBUG_ID__, result); // return false; } //format.m_sampleRate = spdif_output_config.sample_rate; } // HDMI if(bIsHDMI) { ismd_audio_output_t OutputHDMI = g_IntelSMDGlobals.GetHDMIOutput(); ismd_audio_output_config_t hdmi_output_config; ConfigureAudioOutputParams(hdmi_output_config, AE_DEVTYPE_HDMI, uiUsedBitsPerSample, outputSampleRate, channels, ismdAudioInputFormat, bHDMIPassthrough, bAC3Encode); if(!g_IntelSMDGlobals.ConfigureAudioOutput(OutputHDMI, hdmi_output_config)) { CLog::Log(LOGERROR, "%s ConfigureAudioOutput HDMI failed %d", __DEBUG_ID__, result); return false; } //format.m_sampleRate = hdmi_output_config.sample_rate; } // Configure the master clock frequency CLog::Log(LOGINFO, "%s ConfigureMasterClock %d", __DEBUG_ID__, format.m_sampleRate); g_IntelSMDGlobals.ConfigureMasterClock(format.m_sampleRate); bSPDIFPassthrough = bIsSPDIF && bSPDIFPassthrough; bHDMIPassthrough = bIsHDMI && bHDMIPassthrough; ismd_audio_input_pass_through_config_t passthrough_config; memset(&passthrough_config, 0, sizeof(&passthrough_config)); if (bSPDIFPassthrough || bHDMIPassthrough) { passthrough_config.is_pass_through = TRUE; passthrough_config.supported_format_count = 1; passthrough_config.supported_formats[0] = ismdAudioInputFormat; } result = ismd_audio_input_set_as_primary(audioProcessor, m_audioDevice, passthrough_config); if (result != ISMD_SUCCESS) { CLog::Log(LOGERROR, "%s ismd_audio_input_set_as_primary failed %d", __DEBUG_ID__, result); // return false; } if(!g_IntelSMDGlobals.EnableAudioInput(m_audioDevice)) { CLog::Log(LOGERROR, "%s EnableAudioInput", __DEBUG_ID__); // return false; } // enable outputs if (bIsHDMI) { if(!g_IntelSMDGlobals.EnableAudioOutput(g_IntelSMDGlobals.GetHDMIOutput())) { CLog::Log(LOGERROR, "%s EnableAudioOutput HDMI failed", __DEBUG_ID__); // return false; } } if (bIsSPDIF) { if(!g_IntelSMDGlobals.EnableAudioOutput(g_IntelSMDGlobals.GetSPDIFOutput())) { CLog::Log(LOGERROR, "%s EnableAudioOutput SPDIF failed", __DEBUG_ID__); // return false; } } if (bIsAnalog) { if(!g_IntelSMDGlobals.EnableAudioOutput(g_IntelSMDGlobals.GetI2SOutput())) { CLog::Log(LOGERROR, "%s EnableAudioOutput I2S failed", __DEBUG_ID__); // return false; } } g_IntelSMDGlobals.SetAudioDeviceState(ISMD_DEV_STATE_PLAY, m_audioDevice); // m_fCurrentVolume = g_settings.m_fVolumeLevel; //g_IntelSMDGlobals.SetMasterVolume(m_fCurrentVolume); m_bPause = false; m_dSampleRate = format.m_sampleRate; m_bIsAllocated = true; // set latency when using passthrough since we are not using a timed audio interface if (bAC3Encode || ismdAudioInputFormat == ISMD_AUDIO_MEDIA_FMT_DD) m_latency = 0.675;//0.45; CLog::Log(LOGINFO, "%s done", __DEBUG_ID__); return true; }
CAESinkIntelSMD::~CAESinkIntelSMD() { VERBOSE2(); Deinitialize(); }