/***************************************************************************** * Open: probe the decoder and return score ***************************************************************************** * Tries to launch a decoder and return score so that the interface is able * to choose. *****************************************************************************/ static int Open( vlc_object_t *p_this ) { decoder_t *p_dec = (decoder_t*)p_this; /* create a mutex */ var_Create( p_this->p_libvlc, "qt_mutex", VLC_VAR_MUTEX ); switch( p_dec->fmt_in.i_codec ) { case VLC_FOURCC('S','V','Q','3'): /* Sorenson v3 */ /* case VLC_FOURCC('S','V','Q','1'): Sorenson v1 case VLC_FOURCC('Z','y','G','o'): case VLC_FOURCC('V','P','3','1'): case VLC_FOURCC('3','I','V','1'): */ case VLC_FOURCC('r','l','e',' '): /* QuickTime animation (RLE) */ case VLC_FOURCC('r','p','z','a'): /* QuickTime Apple Video */ case VLC_FOURCC('a','z','p','r'): /* QuickTime animation (RLE) */ #ifdef LOADER p_dec->p_sys = NULL; p_dec->pf_decode_video = DecodeVideo; return VLC_SUCCESS; #else return OpenVideo( p_dec ); #endif case VLC_FOURCC('s','a','m','r'): /* 3GPP AMR audio */ case VLC_FOURCC('m','p','4','a'): /* MPEG-4 audio */ case VLC_FOURCC('Q','D','M','C'): /* QDesign */ case VLC_FOURCC('Q','D','M','2'): /* QDesign* 2 */ case VLC_FOURCC('Q','c','l','p'): /* Qualcomm Purevoice Codec */ case VLC_FOURCC('Q','C','L','P'): /* Qualcomm Purevoice Codec */ case VLC_FOURCC('M','A','C','3'): /* MACE3 audio decoder */ case VLC_FOURCC('M','A','C','6'): /* MACE6 audio decoder */ case VLC_FOURCC('d','v','c','a'): /* DV Audio */ case VLC_FOURCC('s','o','w','t'): /* 16-bit Little Endian */ case VLC_FOURCC('t','w','o','s'): /* 16-bit Big Endian */ case VLC_FOURCC('a','l','a','w'): /* ALaw 2:1 */ case VLC_FOURCC('u','l','a','w'): /* mu-Law 2:1 */ case VLC_FOURCC('r','a','w',' '): /* 8-bit offset binaries */ case VLC_FOURCC('f','l','3','2'): /* 32-bit Floating Point */ case VLC_FOURCC('f','l','6','4'): /* 64-bit Floating Point */ case VLC_FOURCC('i','n','2','4'): /* 24-bit Interger */ case VLC_FOURCC('i','n','3','2'): /* 32-bit Integer */ case 0x0011: /* DVI IMA */ case 0x6D730002: /* Microsoft ADPCM-ACM */ case 0x6D730011: /* DVI Intel IMAADPCM-ACM */ #ifdef LOADER p_dec->p_sys = NULL; p_dec->pf_decode_audio = DecodeAudio; return VLC_SUCCESS; #else return OpenAudio( p_dec ); #endif default: return VLC_EGENERIC; } }
//////////////////////////////////////////////////////////////// // ビデオキャプチャ開始 // // 引数: filename 出力ファイル名 // sw スクリーンの幅 // sh スクリーンの高さ // vrate フレームレート(fps) // arate 音声サンプリングレート(Hz) // bpp 色深度(16,24,32) // 返値: bool true:成功 false:失敗 //////////////////////////////////////////////////////////////// bool AVI6::StartAVI( const char *filename, int sw, int sh, int vrate, int arate, int bpp ) { #ifndef NOAVI cCritical::Lock(); Init(); ABPP = bpp; // オーディオバッファ作成 ABuf.InitBuffer( arate / vrate * 2 ); // 出力コンテキスト作成 avformat_alloc_output_context2(&oc, NULL, NULL, filename); if (!oc) return false; fmt = oc->oformat; // 音声、ビデオストリームを作成 if (fmt->video_codec != AV_CODEC_ID_NONE) { // ビデオコーデックにVP9を選択されると画像が崩れるため、暫定措置として強制的にVP8にする。 fmt->video_codec = AV_CODEC_ID_VP8; AddStream(&video_st, oc, &video_codec, fmt->video_codec, sw, sh); } if (fmt->audio_codec != AV_CODEC_ID_NONE) { // オーディオコーデックにOPUSを選択されると落ちるため、暫定措置として強制的にVORBISにする。 fmt->audio_codec = AV_CODEC_ID_VORBIS; AddStream(&audio_st, oc, &audio_codec, fmt->audio_codec, sw, sh); } OpenVideo(oc, video_codec, &video_st, opt); OpenAudio(oc, audio_codec, &audio_st, opt, arate); av_dump_format(oc, 0, filename, 1); int ret = 0; // ファイルを開く if (!(fmt->flags & AVFMT_NOFILE)) { ret = avio_open(&oc->pb, filename, AVIO_FLAG_WRITE); if (0 > ret) { return false; } } // ストリームヘッダを書き込み ret = avformat_write_header(oc, &opt); if (0 > ret) { return false; } isAVI = true; cCritical::UnLock(); return true; #else return false; #endif }
INT ReopenAudioDevice( DWORD Rate, INT OutputMode, INT Latency ) { ALock; debugf( NAME_Init, TEXT("Reopening audio device.") ); CloseAudio(); INT Result = OpenAudio( Rate, OutputMode, Latency ); AUnlock; return Result; }
int CAudioMuxer::CreateOutputContext(const char* pFileName, int nBitrate, int nSampleRate, int nChannels) { // avoid re-creating the context if (m_pCtx) { return E_HANDLED; } /* allocate the output media context */ avformat_alloc_output_context2(&m_pCtx, NULL, NULL, pFileName); if (!m_pCtx) { Log("Could not deduce output format from file extension: using MPEG.\n"); avformat_alloc_output_context2(&m_pCtx, NULL, "mpeg", pFileName); if (!m_pCtx) { return E_FAIL; } } m_pFmt = m_pCtx->oformat; // set the input bitrate, sample rate and channels m_nBitrate = nBitrate; m_nSampleRate = nSampleRate; m_nChannels = nChannels; /* Add the audio and video streams using the default format codecs * and initialize the codecs. */ AVCodec *pAudioCodec; m_pAudioStream = NULL; AVCodecID eCodecID = m_pFmt->audio_codec; if (eCodecID != AV_CODEC_ID_NONE) { m_pAudioStream = AddAudioStream(&pAudioCodec, eCodecID); } /* Now that all the parameters are set, we can open the audio and * video codecs and allocate the necessary encode buffers. */ if (m_pAudioStream) { OpenAudio(pAudioCodec); } /* open the output file, if needed */ if (!(m_pFmt->flags & AVFMT_NOFILE)) { if (avio_open(&m_pCtx->pb, pFileName, AVIO_FLAG_WRITE) < 0) { Log("Could not open '%s'\n", pFileName); return E_IO; } } return S_OK; }
void SoundInitialize(SoundDevice *device, const char *path) { memset(device, 0, sizeof *device); if (OpenAudio(44100, AUDIO_S16, 2, 1024) != 0) { return; } device->channels = 64; SoundReconfigure(device); CArrayInit(&device->sounds, sizeof(SoundData)); CArrayInit(&device->customSounds, sizeof(SoundData)); SoundLoadDirImpl(device, path, NULL); // Look for commonly used sounds to set our pointers CArrayInit(&device->footstepSounds, sizeof(Mix_Chunk *)); for (int i = 0;; i++) { char buf[CDOGS_FILENAME_MAX]; sprintf(buf, "footsteps/%d", i); Mix_Chunk *s = StrSound(buf); if (s == NULL) break; CArrayPushBack(&device->footstepSounds, &s); } device->slideSound = StrSound("slide"); device->healthSound = StrSound("health"); device->clickSound = StrSound("click"); device->keySound = StrSound("key"); device->wreckSound = StrSound("bang"); CArrayInit(&device->screamSounds, sizeof(Mix_Chunk *)); for (int i = 0;; i++) { char buf[CDOGS_FILENAME_MAX]; sprintf(buf, "aargh%d", i); Mix_Chunk *scream = StrSound(buf); if (scream == NULL) { break; } CArrayPushBack(&device->screamSounds, &scream); } }
bool AVFormatWriter::Init(void) { if (m_videoOutBuf) delete [] m_videoOutBuf; if (m_width && m_height) m_videoOutBuf = new unsigned char[m_width * m_height * 2 + 10]; AVOutputFormat *fmt = av_guess_format(m_container.toAscii().constData(), NULL, NULL); if (!fmt) { LOG(VB_RECORD, LOG_ERR, LOC + QString("Init(): Unable to guess AVOutputFormat from container %1") .arg(m_container)); return false; } m_fmt = *fmt; if (m_width && m_height) { m_avVideoCodec = avcodec_find_encoder_by_name( m_videoCodec.toAscii().constData()); if (!m_avVideoCodec) { LOG(VB_RECORD, LOG_ERR, LOC + QString("Init(): Unable to find video codec %1").arg(m_videoCodec)); return false; } m_fmt.video_codec = m_avVideoCodec->id; } else m_fmt.video_codec = CODEC_ID_NONE; m_avAudioCodec = avcodec_find_encoder_by_name( m_audioCodec.toAscii().constData()); if (!m_avAudioCodec) { LOG(VB_RECORD, LOG_ERR, LOC + QString("Init(): Unable to find audio codec %1").arg(m_audioCodec)); return false; } m_fmt.audio_codec = m_avAudioCodec->id; m_ctx = avformat_alloc_context(); if (!m_ctx) { LOG(VB_RECORD, LOG_ERR, LOC + "Init(): Unable to allocate AVFormatContext"); return false; } m_ctx->oformat = &m_fmt; if (m_container == "mpegts") m_ctx->packet_size = 2324; snprintf(m_ctx->filename, sizeof(m_ctx->filename), "%s", m_filename.toAscii().constData()); if (m_fmt.video_codec != CODEC_ID_NONE) m_videoStream = AddVideoStream(); if (m_fmt.audio_codec != CODEC_ID_NONE) m_audioStream = AddAudioStream(); m_pkt = new AVPacket; if (!m_pkt) { LOG(VB_RECORD, LOG_ERR, LOC + "Init(): error allocating AVPacket"); return false; } if (av_set_parameters(m_ctx, NULL) < 0) { LOG(VB_RECORD, LOG_ERR, "Init(): Invalid output format parameters"); return false; } if ((m_videoStream) && (!OpenVideo())) { LOG(VB_RECORD, LOG_ERR, LOC + "Init(): OpenVideo() failed"); return false; } if ((m_audioStream) && (!OpenAudio())) { LOG(VB_RECORD, LOG_ERR, LOC + "Init(): OpenAudio() failed"); return false; } return true; }
void AudioController::OnAudioProviderChanged() { if (IsAudioOpen()) // url is cloned because CloseAudio clears it and OpenAudio takes a const reference OpenAudio(audio_url.Clone()); }
/***************************************************************************** * DecodeAudio: *****************************************************************************/ static aout_buffer_t *DecodeAudio( decoder_t *p_dec, block_t **pp_block ) { decoder_sys_t *p_sys = p_dec->p_sys; block_t *p_block; int i_error; #ifdef LOADER /* We must do open and close in the same thread (unless we do * Setup_LDT_Keeper in the main thread before all others */ if( p_sys == NULL ) { if( OpenAudio( p_dec ) ) { /* Fatal */ p_dec->b_error = true; return NULL; } p_sys = p_dec->p_sys; } #endif if( pp_block == NULL || *pp_block == NULL ) { return NULL; } p_block = *pp_block; if( p_sys->i_out_frames > 0 && p_sys->i_out >= p_sys->i_out_frames ) { /* Ask new data */ p_sys->i_out = 0; p_sys->i_out_frames = 0; *pp_block = NULL; return NULL; } if( p_sys->i_out_frames <= 0 ) { p_sys->pts = p_block->i_pts; mtime_t i_display_date = 0; if( !(p_block->i_flags & BLOCK_FLAG_PREROLL) ) i_display_date = decoder_GetDisplayDate( p_dec, p_block->i_pts ); if( i_display_date > 0 && i_display_date < mdate() ) { block_Release( p_block ); *pp_block = NULL; return NULL; } /* Append data */ if( p_sys->i_buffer_size < p_sys->i_buffer + p_block->i_buffer ) { p_sys->i_buffer_size = p_sys->i_buffer + p_block->i_buffer + 1024; p_sys->p_buffer = realloc( p_sys->p_buffer, p_sys->i_buffer_size ); } memcpy( &p_sys->p_buffer[p_sys->i_buffer], p_block->p_buffer, p_block->i_buffer ); p_sys->i_buffer += p_block->i_buffer; if( p_sys->i_buffer > p_sys->InFrameSize ) { int i_frames = p_sys->i_buffer / p_sys->InFrameSize; unsigned long i_out_frames, i_out_bytes; vlc_mutex_lock( &qt_mutex ); i_error = p_sys->SoundConverterConvertBuffer( p_sys->myConverter, p_sys->p_buffer, i_frames, p_sys->out_buffer, &i_out_frames, &i_out_bytes ); vlc_mutex_unlock( &qt_mutex ); /* msg_Dbg( p_dec, "decoded %d frames -> %ld frames (error=%d)", i_frames, i_out_frames, i_error ); msg_Dbg( p_dec, "decoded %ld frames = %ld bytes", i_out_frames, i_out_bytes ); */ p_sys->i_buffer -= i_frames * p_sys->InFrameSize; if( p_sys->i_buffer > 0 ) { memmove( &p_sys->p_buffer[0], &p_sys->p_buffer[i_frames * p_sys->InFrameSize], p_sys->i_buffer ); } if( p_sys->pts != 0 && p_sys->pts != date_Get( &p_sys->date ) ) { date_Set( &p_sys->date, p_sys->pts ); } else if( !date_Get( &p_sys->date ) ) { return NULL; } if( !i_error && i_out_frames > 0 ) { /* we have others samples */ p_sys->i_out_frames = i_out_frames; p_sys->i_out = 0; } } } if( p_sys->i_out < p_sys->i_out_frames ) { aout_buffer_t *p_out; int i_frames = __MIN( p_sys->i_out_frames - p_sys->i_out, 1000 ); p_out = decoder_NewAudioBuffer( p_dec, i_frames ); if( p_out ) { p_out->i_pts = date_Get( &p_sys->date ); p_out->i_length = date_Increment( &p_sys->date, i_frames ) - p_out->i_pts; memcpy( p_out->p_buffer, &p_sys->out_buffer[2 * p_sys->i_out * p_dec->fmt_out.audio.i_channels], p_out->i_buffer ); p_sys->i_out += i_frames; } return p_out; } return NULL; }
/***************************************************************************** * Open: probe the decoder and return score ***************************************************************************** * Tries to launch a decoder and return score so that the interface is able * to choose. *****************************************************************************/ static int Open( vlc_object_t *p_this ) { decoder_t *p_dec = (decoder_t*)p_this; #ifdef __APPLE__ OSErr err; SInt32 qtVersion, macosversion; err = Gestalt(gestaltQuickTimeVersion, &qtVersion); err = Gestalt(gestaltSystemVersion, &macosversion); #ifndef NDEBUG msg_Dbg( p_this, "Mac OS version is %#lx", macosversion ); msg_Dbg( p_this, "Quicktime version is %#lx", qtVersion ); #endif /* bail out. This plugin is soo Carbon, that it can't be used on 10.5 at all */ msg_Info( p_dec, "Your Mac OS version is to new to use this plugin for anything." ); return VLC_EGENERIC; #endif switch( p_dec->fmt_in.i_codec ) { case VLC_CODEC_H264: case VLC_CODEC_CINEPAK: case VLC_FOURCC('I','V','4','1'): /* Indeo Video IV */ case VLC_FOURCC('i','v','4','1'): /* dto. */ #ifdef __APPLE__ case VLC_FOURCC('p','x','l','t'): /* Pixlet */ #endif case VLC_CODEC_DV: case VLC_CODEC_SVQ3: /* Sorenson v3 */ /* case VLC_CODEC_SVQ1: Sorenson v1 case VLC_FOURCC('Z','y','G','o'): case VLC_FOURCC('V','P','3','1'): case VLC_FOURCC('3','I','V','1'): */ case VLC_CODEC_QTRLE: case VLC_CODEC_RPZA: #ifdef LOADER p_dec->p_sys = NULL; p_dec->pf_decode_video = DecodeVideo; p_dec->fmt_out.i_cat = VIDEO_ES; return VLC_SUCCESS; #else return OpenVideo( p_dec ); #endif #ifdef __APPLE__ case VLC_FOURCC('I','L','B','C'): /* iLBC */ if ((err != noErr) || (qtVersion < 0x07500000)) return VLC_EGENERIC; case VLC_FOURCC('i','l','b','c'): /* iLBC */ if ((err != noErr) || (qtVersion < 0x07500000)) return VLC_EGENERIC; #endif case VLC_CODEC_AMR_NB: /* 3GPP AMR audio */ case VLC_FOURCC('s','a','m','b'): /* 3GPP AMR-WB audio */ case VLC_CODEC_MP4A: /* MPEG-4 audio */ case VLC_FOURCC('Q','D','M','C'): /* QDesign */ case VLC_CODEC_QDM2: /* QDesign* 2 */ case VLC_CODEC_QCELP: /* Qualcomm Purevoice Codec */ case VLC_FOURCC('Q','C','L','P'): /* Qualcomm Purevoice Codec */ case VLC_CODEC_MACE3: /* MACE3 audio decoder */ case VLC_CODEC_MACE6: /* MACE6 audio decoder */ case VLC_FOURCC('d','v','c','a'): /* DV Audio */ case VLC_FOURCC('s','o','w','t'): /* 16-bit Little Endian */ case VLC_FOURCC('t','w','o','s'): /* 16-bit Big Endian */ case VLC_CODEC_ALAW: /* ALaw 2:1 */ case VLC_FOURCC('u','l','a','w'): /* mu-Law 2:1 */ case VLC_FOURCC('r','a','w',' '): /* 8-bit offset binaries */ case VLC_CODEC_FL32: /* 32-bit Floating Point */ case VLC_CODEC_FL64: /* 64-bit Floating Point */ case VLC_FOURCC('i','n','2','4'): /* 24-bit Interger */ case VLC_FOURCC('i','n','3','2'): /* 32-bit Integer */ case 0x0011: /* DVI IMA */ case 0x6D730002: /* Microsoft ADPCM-ACM */ case 0x6D730011: /* DVI Intel IMAADPCM-ACM */ #ifdef LOADER p_dec->p_sys = NULL; p_dec->pf_decode_audio = DecodeAudio; p_dec->fmt_out.i_cat = AUDIO_ES; return VLC_SUCCESS; #else return OpenAudio( p_dec ); #endif default: return VLC_EGENERIC; } }
bool AVFormatWriter::Init(void) { AVOutputFormat *fmt = av_guess_format(m_container.toLatin1().constData(), NULL, NULL); if (!fmt) { LOG(VB_RECORD, LOG_ERR, LOC + QString("Init(): Unable to guess AVOutputFormat from container %1") .arg(m_container)); return false; } m_fmt = *fmt; if (m_width && m_height) { m_avVideoCodec = avcodec_find_encoder_by_name( m_videoCodec.toLatin1().constData()); if (!m_avVideoCodec) { LOG(VB_RECORD, LOG_ERR, LOC + QString("Init(): Unable to find video codec %1").arg(m_videoCodec)); return false; } m_fmt.video_codec = m_avVideoCodec->id; } else m_fmt.video_codec = AV_CODEC_ID_NONE; m_avAudioCodec = avcodec_find_encoder_by_name( m_audioCodec.toLatin1().constData()); if (!m_avAudioCodec) { LOG(VB_RECORD, LOG_ERR, LOC + QString("Init(): Unable to find audio codec %1").arg(m_audioCodec)); return false; } m_fmt.audio_codec = m_avAudioCodec->id; m_ctx = avformat_alloc_context(); if (!m_ctx) { LOG(VB_RECORD, LOG_ERR, LOC + "Init(): Unable to allocate AVFormatContext"); return false; } m_ctx->oformat = &m_fmt; if (m_container == "mpegts") m_ctx->packet_size = 2324; snprintf(m_ctx->filename, sizeof(m_ctx->filename), "%s", m_filename.toLatin1().constData()); if (m_fmt.video_codec != AV_CODEC_ID_NONE) m_videoStream = AddVideoStream(); if (m_fmt.audio_codec != AV_CODEC_ID_NONE) m_audioStream = AddAudioStream(); if ((m_videoStream) && (!OpenVideo())) { LOG(VB_RECORD, LOG_ERR, LOC + "Init(): OpenVideo() failed"); return false; } if ((m_audioStream) && (!OpenAudio())) { LOG(VB_RECORD, LOG_ERR, LOC + "Init(): OpenAudio() failed"); return false; } return true; }
/***************************************************************************** * DecodeAudio: *****************************************************************************/ static aout_buffer_t *DecodeAudio( decoder_t *p_dec, block_t **pp_block ) { decoder_sys_t *p_sys = p_dec->p_sys; vlc_value_t lockval; block_t *p_block; int i_error; #ifdef LOADER /* We must do open and close in the same thread (unless we do * Setup_LDT_Keeper in the main thread before all others */ if( p_sys == NULL ) { if( OpenAudio( p_dec ) ) { /* Fatal */ p_dec->b_error = VLC_TRUE; return NULL; } p_sys = p_dec->p_sys; } #endif if( pp_block == NULL || *pp_block == NULL ) { return NULL; } p_block = *pp_block; if( p_sys->i_out_frames > 0 && p_sys->i_out >= p_sys->i_out_frames ) { /* Ask new data */ p_sys->i_out = 0; p_sys->i_out_frames = 0; *pp_block = NULL; return NULL; } if( p_sys->i_out_frames <= 0 ) { if( ( p_sys->pts = p_block->i_pts ) < mdate() ) { block_Release( p_block ); *pp_block = NULL; return NULL; } /* Append data */ if( p_sys->i_buffer_size < p_sys->i_buffer + p_block->i_buffer ) { p_sys->i_buffer_size = p_sys->i_buffer + p_block->i_buffer + 1024; p_sys->p_buffer = realloc( p_sys->p_buffer, p_sys->i_buffer_size ); } memcpy( &p_sys->p_buffer[p_sys->i_buffer], p_block->p_buffer, p_block->i_buffer ); p_sys->i_buffer += p_block->i_buffer; if( p_sys->i_buffer > p_sys->InFrameSize ) { int i_frames = p_sys->i_buffer / p_sys->InFrameSize; unsigned long i_out_frames, i_out_bytes; var_Get( p_dec->p_libvlc, "qt_mutex", &lockval ); vlc_mutex_lock( lockval.p_address ); i_error = p_sys->SoundConverterConvertBuffer( p_sys->myConverter, p_sys->p_buffer, i_frames, p_sys->out_buffer, &i_out_frames, &i_out_bytes ); vlc_mutex_unlock( lockval.p_address ); /* msg_Dbg( p_dec, "decoded %d frames -> %ld frames (error=%d)", i_frames, i_out_frames, i_error ); msg_Dbg( p_dec, "decoded %ld frames = %ld bytes", i_out_frames, i_out_bytes ); */ p_sys->i_buffer -= i_frames * p_sys->InFrameSize; if( p_sys->i_buffer > 0 ) { memmove( &p_sys->p_buffer[0], &p_sys->p_buffer[i_frames * p_sys->InFrameSize], p_sys->i_buffer ); } if( p_sys->pts != 0 && p_sys->pts != aout_DateGet( &p_sys->date ) ) { aout_DateSet( &p_sys->date, p_sys->pts ); } else if( !aout_DateGet( &p_sys->date ) ) { return NULL; } if( !i_error && i_out_frames > 0 ) { /* we have others samples */ p_sys->i_out_frames = i_out_frames; p_sys->i_out = 0; } } } if( p_sys->i_out < p_sys->i_out_frames ) { aout_buffer_t *p_out; int i_frames = __MIN( p_sys->i_out_frames - p_sys->i_out, 1000 ); p_out = p_dec->pf_aout_buffer_new( p_dec, i_frames ); if( p_out ) { p_out->start_date = aout_DateGet( &p_sys->date ); p_out->end_date = aout_DateIncrement( &p_sys->date, i_frames ); memcpy( p_out->p_buffer, &p_sys->out_buffer[2 * p_sys->i_out * p_dec->fmt_out.audio.i_channels], p_out->i_nb_bytes ); p_sys->i_out += i_frames; } return p_out; } return NULL; }
BlackberryAudio() { paused = false; OpenAudio(); }
//-------------------------------------------------------------------------------------------------- static void MyCallEventHandler ( le_voicecall_CallRef_t reference, const char* identifier, le_voicecall_Event_t event, void* contextPtr ) { LE_INFO("MyCallEventHandler DestNumber=> %s", identifier); char eventString[EVENT_STRING_LEN]; switch(event) { case LE_VOICECALL_EVENT_CONNECTED: { snprintf(eventString, EVENT_STRING_LEN, "%s", "LE_VOICECALL_EVENT_CONNECTED"); OpenAudio(reference); } break; case LE_VOICECALL_EVENT_ALERTING: { snprintf(eventString, EVENT_STRING_LEN, "%s", "LE_VOICECALL_EVENT_ALERTING"); } break; case LE_VOICECALL_EVENT_BUSY: { snprintf(eventString, EVENT_STRING_LEN, "%s", "LE_VOICECALL_EVENT_BUSY"); } break; case LE_VOICECALL_EVENT_INCOMING: { snprintf(eventString, EVENT_STRING_LEN, "%s", "LE_VOICECALL_EVENT_INCOMING"); RequestCallRef = reference; } break; case LE_VOICECALL_EVENT_OFFLINE: { snprintf(eventString, EVENT_STRING_LEN, "%s", "LE_VOICECALL_EVENT_OFFLINE"); } break; case LE_VOICECALL_EVENT_RESOURCE_BUSY: { snprintf(eventString, EVENT_STRING_LEN, "%s", "LE_VOICECALL_EVENT_RESOURCE_BUSY"); } break; case LE_VOICECALL_EVENT_TERMINATED: { le_voicecall_TerminationReason_t reason; le_result_t result; LE_DEBUG("LE_VOICECALL_EVENT_TERMINATED audio Disconnecting"); DisconnectAllAudio(reference); result = le_voicecall_GetTerminationReason(reference, &reason); if (result == LE_OK) { char reasonstring[REASON_STRING_LEN]; switch(reason) { case LE_VOICECALL_TERM_BAD_ADDRESS: { snprintf(reasonstring, REASON_STRING_LEN, "%s", "LE_VOICECALL_TERM_BAD_ADDRESS"); } break; case LE_VOICECALL_TERM_BUSY: { snprintf(reasonstring, REASON_STRING_LEN, "%s", "LE_VOICECALL_TERM_BUSY"); } break; case LE_VOICECALL_TERM_LOCAL_ENDED: { snprintf(reasonstring, REASON_STRING_LEN, "%s", "LE_VOICECALL_TERM_LOCAL_ENDED"); } break; case LE_VOICECALL_TERM_NETWORK_FAIL: { snprintf(reasonstring, REASON_STRING_LEN, "%s", "LE_VOICECALL_TERM_NETWORK_FAIL"); } break; case LE_VOICECALL_TERM_REMOTE_ENDED: { snprintf(reasonstring, REASON_STRING_LEN, "%s", "LE_VOICECALL_TERM_REMOTE_ENDED"); } break; case LE_VOICECALL_TERM_UNDEFINED: { snprintf(reasonstring, REASON_STRING_LEN, "%s", "LE_VOICECALL_TERM_UNDEFINED"); } break; default: { snprintf(reasonstring, REASON_STRING_LEN, "%s", "reason not defined"); } break; break; } snprintf(eventString, EVENT_STRING_LEN, "%s reason =%d => %s", "LE_VOICECALL_EVENT_TERMINATED", reason, reasonstring); } else { snprintf(eventString, EVENT_STRING_LEN, "%s reason not found", "LE_VOICECALL_EVENT_TERMINATED"); } le_voicecall_Delete(reference); } break; default: { snprintf(eventString,EVENT_STRING_LEN,"udefined"); LE_INFO("Unknown event"); } break; } fprintf(stderr,"\n=>Destination %s, Event %d => %s\n\n", identifier ,event, eventString); LE_INFO("MyCallEventHandler Event state %d, %s", event,eventString); return; }
bool wxSoundBackendSDL::Play(wxSoundData *data, unsigned flags, volatile wxSoundPlaybackStatus *WXUNUSED(status)) { Stop(); int format; if (data->m_bitsPerSample == 8) format = AUDIO_U8; else if (data->m_bitsPerSample == 16) format = AUDIO_S16LSB; else return false; bool needsOpen = true; if (m_audioOpen) { if (format == m_spec.format && m_spec.freq == (int)data->m_samplingRate && m_spec.channels == data->m_channels) { needsOpen = false; } else { CloseAudio(); } } if (needsOpen) { m_spec.format = format; m_spec.freq = data->m_samplingRate; m_spec.channels = data->m_channels; if (!OpenAudio()) return false; } SDL_LockAudio(); wxLogTrace(wxT("sound"), wxT("playing new sound")); m_playing = true; m_pos = 0; m_loop = (flags & wxSOUND_LOOP); m_data = data; data->IncRef(); SDL_UnlockAudio(); SDL_PauseAudio(0); // wait until playback finishes if called in sync mode: if (!(flags & wxSOUND_ASYNC)) { wxLogTrace(wxT("sound"), wxT("waiting for sample to finish")); while (m_playing && m_data == data) { #if wxUSE_THREADS // give the playback thread a chance to add event to pending // events queue, release GUI lock temporarily: if (wxThread::IsMain()) wxMutexGuiLeave(); #endif wxMilliSleep(10); #if wxUSE_THREADS if (wxThread::IsMain()) wxMutexGuiEnter(); #endif } wxLogTrace(wxT("sound"), wxT("sample finished")); } return true; }