Dear All I try to build myself library which would use MediaPlayerService::decode() to decode audio and get IMemory.
After getting IMediaPlayerService, I call sp<IMemory> MediaPlayerService::decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, int* pFormat). However, I found that the IMemory pointer, values of SampleRate, NumChannels and Format are all zero. The code is as following: ============================== android::sp<android::IMediaPlayerService> shw = getDefaultMediaPlayerService(); if (shw == 0) { LOGE("MediaPlayerService doesn't exist"); return; } uint32_t SampleRate; int NumChannels; int Format; int fileDescriptor = open("/sdcard/1.mp3", O_RDONLY); if (fileDescriptor == -1) { LOGE("Error opening"); return; } long fileLength = getFileLength(fileDescriptor); android::sp<android::IMemory> p=shw->decode(fileDescriptor, 0, fileLength, &SampleRate, &NumChannels, &Format); LOGI("SampleRate: %u, NumChannels: %d, Format: %d", SampleRate, NumChannels, Format); ============================== I has no ideal as there is no error or warning log but values are wrong. I try this in the emulator based on images built by my own source code , which I include for previous program. However, it still cannot decode the file and return NULL pointer. Is there any mistakes in code? Or any comment about this issue. Thank you all very much! Bram -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en