UINT32 MCI_AudioSetVolume(UINT16 volume) { MPS_ERR_T err; MCI_TRACE(MCI_AUD_TRC_LVL,0x0,"MCI_AudioSetVolume: %d ",volume) ; g_mciConfig.volume = volume-1; g_mciAudioSavedVolume = volume-1; // Only update now if a file is opened // if no file is opened, it will be applied in the Open function if (g_mciMediaHandle != NULL) { err = mps_SetConfig(g_mciMediaHandle, &g_mciConfig); if (err == MPS_ERR_NO) { return (UINT32) MCI_ERR_NO; } MCI_TRACE(MCI_AUD_TRC_LVL, 0x0, "MCI_AudioSetVolume Error:%d ", err) ; return (UINT32) MCI_ERR_ACTION_NOT_ALLOWED; } MCI_TRACE(MCI_AUD_TRC_LVL, 0x0, "MCI_AudioSetVolume: No handler"); return (UINT32) MCI_ERR_NO; }
// ============================================================================= // MCI_AudioSetEQ // ----------------------------------------------------------------------------- // Resume an already paused audio object // ============================================================================= UINT32 MCI_AudioSetEQ(AUDIO_EQ EQMode) { MPS_ERR_T err; MCI_TRACE(MCI_AUD_TRC_LVL,0x0,"MCI_AudioSetEQ %d", EQMode) ; // Update the configuration switch (EQMode) { case NORMAL: g_mciConfig.equalizerMode = MPS_EQUALIZER_MODE_NORMAL; break; case BASS: g_mciConfig.equalizerMode = MPS_EQUALIZER_MODE_BASS; break; case DANCE: g_mciConfig.equalizerMode = MPS_EQUALIZER_MODE_DANCE; break; case CLASSICAL: g_mciConfig.equalizerMode = MPS_EQUALIZER_MODE_CLASSICAL; break; case TREBLE: g_mciConfig.equalizerMode = MPS_EQUALIZER_MODE_TREBLE; break; case PARTY: g_mciConfig.equalizerMode = MPS_EQUALIZER_MODE_PARTY; break; case POP: g_mciConfig.equalizerMode = MPS_EQUALIZER_MODE_POP; break; case ROCK: g_mciConfig.equalizerMode = MPS_EQUALIZER_MODE_ROCK; break; default: // Mode not supported return (UINT32) MCI_ERR_INVALID_PARAMETER; } // Only update now if a file is opened // if no file is opened, it will be applied in the Open function if (g_mciMediaHandle != NULL) { err = mps_SetConfig(g_mciMediaHandle,&g_mciConfig); if (err == MPS_ERR_NO) { return (UINT32) MCI_ERR_NO; } MCI_TRACE(MCI_AUD_TRC_LVL,0x0,"MCI_AudioSetEQ Error:%d ",err) ; return (UINT32) MCI_ERR_ACTION_NOT_ALLOWED; } return (UINT32) MCI_ERR_NO; }
void sbc_Flush( SSHdl *hdl ) { INT32 cnt; MCI_TRACE (TSTDOUT | MCI_AUDIO_TRC,0,"dafRTPSS_Flush "); ass( hdl == NULL ); if( !is_SSHdl_valid( hdl ) ) return; cnt = SSHdl_GetDataCount( hdl ); MCI_TRACE (TSTDOUT | MCI_AUDIO_TRC,0, "-cnt:%d,hdl->wait:%d", cnt, hdl->wait); if( cnt > 0 ) hdl->callback( (void *)2 ); }
static UINT32 sbc_SetBitRate(UINT32 bit_rate) { MCI_TRACE ( TSTDOUT | MCI_AUDIO_TRC,0,"sbc_SetBitRate bit_rate=%d",bit_rate); return bit_rate ; }
static UINT32 sbc_AdjustBitRateFromQos(UINT8 qos) // return adjusted bit rate { UINT32 bit_rate_prev = sbc.current_bit_rate; MCI_TRACE ( TSTDOUT | MCI_AUDIO_TRC,0,"sbc_AdjustBitRateFromQos qos=%d, bit_rate_prev=%d",qos, bit_rate_prev); return 0;//( sbc.current_bit_rate ); }
UINT32 MCI_AudioSetOutputPath(UINT16 OutputPath,UINT16 Mute) { MPS_ERR_T err; MCI_TRACE(MCI_AUD_TRC_LVL,0x0,"MCI_AudioSetOutputPath OutputPath:%d Mute:%d",OutputPath,Mute) ; // Only allow set output path on an opened file // as the output path is setup in the open function if (g_mciMediaHandle != NULL) { if (Mute == 1) { g_mciAudioSavedVolume = g_mciConfig.volume; g_mciConfig.volume=0; } else { g_mciConfig.volume = g_mciAudioSavedVolume; } switch (OutputPath) { case MCI_PATH_NORMAL: g_mciConfig.audioPath = MPS_AUDIO_PATH_RECEIVER; break; case MCI_PATH_HP: g_mciConfig.audioPath = MPS_AUDIO_PATH_HEADSET; break; case MCI_PATH_LSP: g_mciConfig.audioPath = MPS_AUDIO_PATH_LOUD_SPEAKER; break; default: // Mode not supported return (UINT32) MCI_ERR_INVALID_PARAMETER; } err = mps_SetConfig(g_mciMediaHandle,&g_mciConfig); if (err == MPS_ERR_NO) { return (UINT32) MCI_ERR_NO; } MCI_TRACE(MCI_AUD_TRC_LVL,0x0,"MCI_AudioSetOutputPath Error:%d ",err) ; return (UINT32) MCI_ERR_ACTION_NOT_ALLOWED; } MCI_TRACE(MCI_AUD_TRC_LVL,0x0,"MCI_AudioSetOutputPath Error: No Open File") ; return (UINT32) MCI_ERR_ACTION_NOT_ALLOWED; }
static VOID sbc_GetPayloadDone() { MCI_TRACE (TSTDOUT | MCI_AUDIO_TRC,0,"sbc_GetPayloadDone\n"); if( a2dp_sbc_strm.sbc_ss_handle == NULL ) return ; sbc_GetDataDone( (SSHdl *)a2dp_sbc_strm.sbc_ss_handle ); }
// ============================================================================= // MCI_AudioResume // ----------------------------------------------------------------------------- // Resume an already paused audio object // ============================================================================= UINT32 MCI_AudioResume(VOID) { MPS_ERR_T err; MCI_TRACE(MCI_AUD_TRC_LVL,0x0,"MCI_AudioResume") ; if (g_mciMediaHandle != NULL) { err = mps_Play(g_mciMediaHandle, 1); if (err == MPS_ERR_NO) { return (UINT32) MCI_ERR_NO; } MCI_TRACE(MCI_AUD_TRC_LVL,0x0,"MCI_AudioResume Error %d",err) ; return (UINT32) MCI_ERR_ACTION_NOT_ALLOWED; } MCI_TRACE(MCI_AUD_TRC_LVL,0x0,"MCI_AudioResume Error: No Open File") ; return (UINT32) MCI_ERR_ACTION_NOT_ALLOWED; }
void SBC_Close(SSHdl **ss_handle) { MCI_TRACE ( TSTDOUT | MCI_AUDIO_TRC,0," SBC_Close!!"); *ss_handle = NULL; }
// ============================================================================= // MCI_AudioPlay // ----------------------------------------------------------------------------- /// Starts playing a file // ============================================================================= UINT32 MCI_AudioPlay (INT32 OutputPath,UINT8* file, MCI_AUDIO_PLAY_CALLBACK_T callback) { MPS_ERR_T err; if (g_mciMediaHandle == NULL) { // Save callback function g_mciAudioPlayCallback=callback; switch (OutputPath) { case MCI_PATH_NORMAL: MCI_TRACE(MCI_AUD_TRC_LVL,0x1,"MCI_AudioPlay on Receiver"); g_mciConfig.audioPath = MPS_AUDIO_PATH_RECEIVER; break; case MCI_PATH_HP: MCI_TRACE(MCI_AUD_TRC_LVL,0x1,"MCI_AudioPlay on Headset"); g_mciConfig.audioPath = MPS_AUDIO_PATH_HEADSET; break; case MCI_PATH_LSP: MCI_TRACE(MCI_AUD_TRC_LVL,0x1,"MCI_AudioPlay on Louspeaker"); g_mciConfig.audioPath = MPS_AUDIO_PATH_LOUD_SPEAKER; break; default: // Mode not supported MCI_TRACE(MCI_AUD_TRC_LVL,0x1,"MCI_AudioPlay Error: Unsupported Outputpath"); return (UINT32) MCI_ERR_INVALID_PARAMETER; } mps_Open(); err = mps_OpenFile(&g_mciMediaHandle, file, MCI_AudioPlayerCallback,&g_mciConfig); if (MPS_ERR_NO!=err) { if (MPS_ERR_UNKNOWN_FORMAT==err) { // File format not recognized MCI_TRACE(MCI_AUD_TRC_LVL,0x1,"MCI_AudioPlay Error : wrong file format %s",file) ; return (UINT32) MCI_ERR_UNKNOWN_FORMAT; } else if (MPS_ERR_FILE_NOT_FOUND==err) { // Open file failed MCI_TRACE(MCI_AUD_TRC_LVL,0x1,"MCI_AudioPlay Error : could not open %s",file) ; return (UINT32) MCI_ERR_INVALID_PARAMETER; } } err = mps_Play(g_mciMediaHandle, 1); if (err == MPS_ERR_NO) { return (UINT32) MCI_ERR_NO; } MCI_TRACE(MCI_AUD_TRC_LVL,0x1,"MCI_AudioPlay Error %d",err) ; return (UINT32) MCI_ERR_ACTION_NOT_ALLOWED; } return (UINT32) MCI_ERR_ACTION_NOT_ALLOWED; }
//============================ A2DP Service =============================== void sbc_PutData( SSHdl *hdl, UINT8 *buf, UINT32 length ) { INT32 cnt; INT32 length_t = (INT32)length; // MCI_TRACE (TSTDOUT | MCI_AUDIO_TRC,0, " Entry sbc_PutData!! length=%d ", length); ass( hdl == NULL ); if( !is_SSHdl_valid( hdl ) ) return; cnt = SSHdl_GetFreeSpace( hdl ); if( cnt<length ) { // Buffer overflow MCI_TRACE (TSTDOUT | MCI_AUDIO_TRC,0, " Buffer overflow!! length_t:%d,-cnt:%d,hdl->wait:%d",length_t, -cnt, hdl->wait); /* hdl->overflow = TRUE; hdl->overflow_size = length; ass( length >= SBC_OVERFLOW_SIZE ); memcpy( hdl->overflow_buf, buf, length ); */ return; // ass(0); } while( length>0 ) { UINT8 *dest; SSHdl_GetWriteBuffer( hdl, &dest, &cnt ); if( cnt > length ) cnt = length; memcpy( dest, buf, cnt ); SSHdl_ShiftWritePointer( hdl, cnt ); buf += cnt; length -= cnt; } cnt = SSHdl_GetDataCount( hdl ); // MCI_TRACE ( TSTDOUT | MCI_AUDIO_TRC,0, " Entry sbc_PutData!! length_t:%d,cnt:%d,hdl->wait:%d",length_t, cnt, hdl->wait); if( hdl->wait == FALSE && cnt >= hdl->rb_threshold ) { hdl->wait = TRUE; hdl->callback( 0 ); } }
// ============================================================================= // MCI_AudioStop // ----------------------------------------------------------------------------- // Resume an already paused audio object // ============================================================================= UINT32 MCI_AudioStop(VOID) { MPS_ERR_T err; MCI_TRACE(MCI_AUD_TRC_LVL,0x0,"MCI_AudioStop") ; if (g_mciMediaHandle != NULL) { err = mps_CloseFile(g_mciMediaHandle); if (err == MPS_ERR_NO) { // Reset the audio handle g_mciMediaHandle=NULL; // Reset the callback handle g_mciAudioPlayCallback=NULL; return (UINT32) MCI_ERR_NO; } MCI_TRACE(MCI_AUD_TRC_LVL,0x0,"MCI_AudioStop Error %d", err) ; return (UINT32) MCI_ERR_ACTION_NOT_ALLOWED; } MCI_TRACE(MCI_AUD_TRC_LVL,0x0,"MCI_AudioStop Error: No Open File") ; return (UINT32) MCI_ERR_ACTION_NOT_ALLOWED; }
VOID MCI_AudioPlayerCallback(MPS_HANDLE_T handle, MPS_STATE_T state) { MCI_AUDIO_PLAY_CALLBACK_T tempCallback = g_mciAudioPlayCallback; MCI_TRACE(MCI_AUD_TRC_LVL,0x0,"MCI_AudioPlayerCallback %d",state); if (handle == g_mciMediaHandle) { if ( state == MPS_STATE_EOF ) { // End of file reached, close the Audio MCI_AudioStop(); } // Call the callback function if it has been defined if (tempCallback) { tempCallback(state); } else { MCI_TRACE(MCI_AUD_TRC_LVL,0x0,"MCI_AudioPlayerCallback : No handler defined"); } } }
VOID MCI_AudioGetInfo() { MPS_FILE_INFO_T* fileInfo; if (g_mciMediaHandle != NULL) { fileInfo = mps_GetInfo(g_mciMediaHandle); } else { MCI_TRACE(MCI_AUD_TRC_LVL,0x0,"MCI_AudioGetInfo Error: No Open File") ; } }
A2DP_codec_struct *SBC_Open( SSHdl **ss_handle, A2DP_Callback pHandler, bt_a2dp_sbc_codec_cap_struct *sbc_config_data, UINT8 *buf, UINT32 buf_len ) { A2DP_codec_struct *a2dp_codec_handle; // ass( buf_len>SBC_GetMemReq() ); MCI_TRACE ( TSTDOUT | MCI_AUDIO_TRC,0,"SBC_Open buf_len=%d",buf_len); { sbc_struct *ihdl=&sbc; ihdl->ss_handle.PutData = sbc_PutData; ihdl->ss_handle.Flush = sbc_Flush; ihdl->ss_handle.rb_base = buf; ihdl->ss_handle.rb_size = buf_len; ihdl->ss_handle.rb_read = 0; ihdl->ss_handle.rb_write = 0; ihdl->ss_handle.rb_threshold = (2048<(buf_len/2))? 2048: (buf_len/2); ihdl->ss_handle.callback = a2dp_sbc_callback; ihdl->ss_handle.wait = FALSE; ihdl->ss_handle.rb_read_total = 0; *(UINT32 *)&(ihdl->config_header) = 0; /* ihdl->ss_handle.overflow= FALSE; ihdl->ss_handle.overflow_size= 0; ihdl->ss_handle.overflow_buf= overflow_buf; */ sbc.current_bit_rate = sbc_config( sbc_config_data ); // sbc.current_frame_size shall be set here a2dp_sbc_strm.sbc_ss_handle = ihdl; *ss_handle = (SSHdl *)&ihdl->ss_handle; MCI_TRACE ( TSTDOUT | MCI_AUDIO_TRC,0," a2dp_sbc_strm.sbc_ss_handle =0x%x, config_header = 0x%x ",a2dp_sbc_strm.sbc_ss_handle,ihdl->config_header); a2dp_codec_handle=&a2dp_codec_handle_Sbc; a2dp_codec_handle->GetPayload = sbc_GetPayload; a2dp_codec_handle->GetPayloadDone = sbc_GetPayloadDone; a2dp_codec_handle->QueryPayloadSize = sbc_QueryPayloadSize; a2dp_codec_handle->SetBitRate = sbc_SetBitRate; a2dp_codec_handle->AdjustBitRateFromQos = sbc_AdjustBitRateFromQos; a2dp_codec_handle->state = 0; a2dp_sbc_strm.a2dp_codec_hdl = a2dp_codec_handle; a2dp_sbc_strm.callback = pHandler; } MCI_TRACE ( TSTDOUT | MCI_AUDIO_TRC,0," sbc.aud_id=%d, sbc.current_bit_rate=%d",sbc.aud_id,sbc.current_bit_rate); return a2dp_codec_handle; // return &sbc.a2dp_codec_hdl; }
UINT32 SBC_GetMemReq(void) { MCI_TRACE ( TSTDOUT | MCI_AUDIO_TRC,0," L1SBC_ENTER_SBC_GETMEMREQ" ); return 8*1024; // recommended minimum sbc frame buffer length , it is adjustable }
static UINT32 sbc_config(bt_a2dp_sbc_codec_cap_struct *sbc_config_data) { // UINT8 bitpool_t; UINT32 bit_rate; UINT32 frame_length_t=0; UINT32 headerstream;; if( sbc_config_data!=NULL ) { UINT8 header_data = 0; if( sbc_config_data->block_len==1 ) { sbc.frame_state.blocks = 16; header_data = SBC_NB_16<<4; } else if( sbc_config_data->block_len==2 ) { sbc.frame_state.blocks = 12; header_data = SBC_NB_12<<4; } else if( sbc_config_data->block_len==4 ) { sbc.frame_state.blocks = 8; header_data = SBC_NB_8<<4; } else if( sbc_config_data->block_len==8 ) { sbc.frame_state.blocks = 4; header_data = SBC_NB_4<<4; } else { ass(1); // EXT_ASSERT(0, sbc_config_data->block_len, 0, 0); } if( sbc_config_data->subband_num==1 ) { sbc.frame_state.subbands = 8; header_data |= SBC_SB_8; } else if( sbc_config_data->subband_num==2 ) { sbc.frame_state.subbands = 4; header_data |= SBC_SB_4; } else { ass(1); // EXT_ASSERT(0, sbc_config_data->subband_num, 0, 0); } if( sbc_config_data->alloc_method==1 ) { sbc.frame_state.allocation_method = SBC_AM_LOUDNESS; header_data |= SBC_AM_LOUDNESS<<1; } else if( sbc_config_data->alloc_method==2 ) { sbc.frame_state.allocation_method = SBC_AM_SNR; header_data |= SBC_AM_SNR<<1; } else { ass(1); // EXT_ASSERT(0, sbc_config_data->alloc_method, 0, 0); } if( sbc_config_data->sample_rate==1 ) { sbc.frame_state.sampling_frequency = 48000; header_data |= SBC_FS_48<<6; } else if( sbc_config_data->sample_rate==2 ) { sbc.frame_state.sampling_frequency = 44100; header_data |= SBC_FS_44<<6; } else if( sbc_config_data->sample_rate==4 ) { sbc.frame_state.sampling_frequency = 32000; header_data |= SBC_FS_32<<6; } else if( sbc_config_data->sample_rate==8 ) { sbc.frame_state.sampling_frequency = 16000; header_data |= SBC_FS_16<<6; } else { ass(1); // EXT_ASSERT(0, sbc_config_data->sample_rate, 0, 0); } if( sbc_config_data->channel_mode==1 ) { sbc.frame_state.channel_mode = SBC_CM_JOINT_STEREO; header_data |= SBC_CM_JOINT_STEREO<<2; } else if( sbc_config_data->channel_mode==2 ) { sbc.frame_state.channel_mode = SBC_CM_STEREO; header_data |= SBC_CM_STEREO<<2; } else if( sbc_config_data->channel_mode==4 ) { sbc.frame_state.channel_mode = SBC_CM_DUAL_CHANNEL; header_data |= SBC_CM_DUAL_CHANNEL<<2; } else if( sbc_config_data->channel_mode==8 ) { sbc.frame_state.channel_mode = SBC_CM_MONO; header_data |= SBC_CM_MONO<<2; } else { ass(1); // EXT_ASSERT(0, sbc_config_data->channel_mode, 0, 0); } if( sbc.frame_state.channel_mode==SBC_CM_MONO ) sbc.frame_state.channels = 1; else sbc.frame_state.channels = 2; sbc.frame_state.sbc_frame_header_data = header_data; sbc.max_bit_pool = sbc_config_data->max_bit_pool; sbc.min_bit_pool = sbc_config_data->min_bit_pool; } // MCI_TRACE ( TSTDOUT | MCI_AUDIO_TRC,0,"sbc_config bit_rate=%d",bit_rate); headerstream = (SBC_SYNCWORD<<24| sbc.frame_state.sbc_frame_header_data<<16|SBC_BIT_POOL<<8|0); memcpy(&sbc.config_header, &headerstream, 4); MCI_TRACE ( TSTDOUT | MCI_AUDIO_TRC,0,"sbc.config_header=%x , sampling_frequency = %d ",sbc.config_header, sbc.frame_state.sampling_frequency ); bit_rate =sbc_calc_bitrate_from_bitpool( SBC_BIT_POOL, sbc.frame_state.subbands, sbc.frame_state.blocks, sbc.frame_state.channel_mode, sbc.frame_state.sampling_frequency, &frame_length_t ); sbc.frame_state.bitpool = SBC_BIT_POOL; sbc.current_frame_size = frame_length_t; /* SBC_TRACE( TRACE_INFO, L1SBC_CONFIG_REPORT, sbc.frame_state.sampling_frequency, sbc.frame_state.channel_mode, sbc.min_bit_pool, sbc.frame_state.bitpool, sbc.max_bit_pool ); */ //kal_prompt_trace(0, "sbc_config bit_rate=%d",bit_rate); return( bit_rate ); }
UINT32 sbc_GetData( SSHdl *hdl, UINT8 *buf, UINT32 buf_len, UINT32 *sample_cnt ) { UINT8 uSbcHeaderWord[4]; UINT32 headerstream,skip_num=0; sbcHeaderStruct stSbcHeader; UINT32 get_length=0,frame_length,offset =0; UINT8 media_head=0; UINT16 nframe=0; sbc_struct*ihdl = (sbc_struct *)hdl; ass( hdl == NULL ); if( SSHdl_GetDataCount( hdl ) == 0 ) return 0; // MCI_TRACE ( TSTDOUT | MCI_AUDIO_TRC,0,"sbc_GetData is called,ihdl->current_frame_size=%d",ihdl->current_frame_size); frame_length=ihdl->current_frame_size; nframe = (UINT16) buf_len/frame_length; do { if( SSHdl_GetDataCount( hdl ) >= 4 ) { SSHdl_SniffNBytes( hdl, 0, 4, uSbcHeaderWord ); headerstream = GET_UINT32( uSbcHeaderWord ); memcpy(&stSbcHeader, &headerstream, 4); if((stSbcHeader.Sync==ihdl->config_header.Sync)&& (stSbcHeader.Subbands==ihdl->config_header.Subbands)&& // (stSbcHeader.Sample_rate==ihdl->config_header.Sample_rate)&& (stSbcHeader.ChannelMode==ihdl->config_header.ChannelMode)&& (stSbcHeader.Blocks==ihdl->config_header.Blocks)&& (stSbcHeader.Bitpool==ihdl->config_header.Bitpool)&& (stSbcHeader.Allocation_method==ihdl->config_header.Allocation_method) ) { get_length=nframe*(frame_length); media_head=nframe; if(SSHdl_GetDataCount( hdl ) >(get_length+4)) { offset=get_length; } else { get_length=(nframe-1)*(frame_length); media_head=(nframe-1); if(SSHdl_GetDataCount( hdl ) >(get_length+4)) offset=get_length; else { MCI_TRACE ( TSTDOUT | MCI_AUDIO_TRC,0,"sbc_GetData rb no enough data"); break; } } break; } else { MCI_TRACE ( TSTDOUT | MCI_AUDIO_TRC,0,"skip 1 byte"); SSHdl_ShiftReadPointer( hdl, 1 );//skip 1 byte if((++skip_num)>frame_length) { skip_num=0; MCI_TRACE ( TSTDOUT | MCI_AUDIO_TRC,0,"***skip_num>frame_length"); break; // ass(1); } } } else { MCI_TRACE ( TSTDOUT | MCI_AUDIO_TRC,0,"rb number <4bytes"); break; } }while(1); skip_num=0; if(offset ) { UINT8 flag=0; do { SSHdl_SniffNBytes( hdl, offset, 4, uSbcHeaderWord ); headerstream = GET_UINT32( uSbcHeaderWord ); memcpy(&stSbcHeader, &headerstream, 4); if((stSbcHeader.Sync==ihdl->config_header.Sync)&& (stSbcHeader.Subbands==ihdl->config_header.Subbands)&& // (stSbcHeader.Sample_rate==ihdl->config_header.Sample_rate)&& (stSbcHeader.ChannelMode==ihdl->config_header.ChannelMode)&& (stSbcHeader.Blocks==ihdl->config_header.Blocks)&& (stSbcHeader.Bitpool==ihdl->config_header.Bitpool)&& (stSbcHeader.Allocation_method==ihdl->config_header.Allocation_method) ) { flag=1; break; } else { offset++; get_length++; MCI_TRACE ( TSTDOUT | MCI_AUDIO_TRC,0,"skip 1 byte next packet"); if((++skip_num)>frame_length) { skip_num=0; MCI_TRACE ( TSTDOUT | MCI_AUDIO_TRC,0,"***skip 1 byte next packet>frame_length"); //ass(1); break; } } }while(1); // MCI_TRACE ( TSTDOUT | MCI_AUDIO_TRC,0,"flag=%d",flag); if(flag) { UINT32 cnt=get_length, cnt2=0; *buf=media_head; buf++; buf_len--; //if(buf_len<cnt) ?????? while( cnt > 0 ) { UINT8 *src; SSHdl_GetReadBuffer( hdl, &src, &cnt2 ); if( cnt2 > cnt ) cnt2 = cnt; memcpy( buf, src, cnt2 ); SSHdl_ShiftReadPointer( hdl, cnt2 ); buf += cnt2; cnt -= cnt2; } // MCI_TRACE ( TSTDOUT | MCI_AUDIO_TRC,0,"sbc_GetData success ~!~!get_length=%d",get_length); return get_length+1; } else { MCI_TRACE ( TSTDOUT | MCI_AUDIO_TRC,0,"sbc_GetData flag =0!!"); return 0; } } else { MCI_TRACE ( TSTDOUT | MCI_AUDIO_TRC,0,"sbc rb is null!!"); return 0; } }