0

Android Audio Sink Crash on Play

asked 2014-06-03 12:54:26 -0700

amit.nishry gravatar image

updated 2014-06-03 16:30:05 -0700

Hi,

I have successfully build both the Linux & Android audio examples app. Using the Android AllJoynAudioServiceAndroidExample I'm able to play send wav files to the Linux ./SinkService but the Android AllJoynAudioServiceSinkExample crash on play.

Below is the crash trace:

Thread [29] 10486 [core: 1] (Suspended : Signal : SIGSEGV:Segmentation fault)   
    memset() at 0x40104a20  
    ajn::services::AndroidDevice::Write() at AndroidDevice.cc:296 0x5f9d4ca4    
    ajn::services::AudioSinkObject::AudioOutputThread() at AudioSinkObject.cc:710 0x5f9da9d4    
    qcc::Thread::Run() at Thread.cc:444 0x5fab584c  
    qcc::Thread::RunInternal() at Thread.cc:218 0x5fab4508  
    __thread_entry() at 0x400f3b64  
    pthread_create() at 0x400f3ce0  
    0x0

The problem is in:

    uint32_t bufferSizeInFrames = sizeRead / apo->mBytesPerFrame;
    apo->mAudioDevice->Write(buffer, bufferSizeInFrames);

The crash is when sizeRead == 0 I can't tell what is apo->mBytesPerFrame...

sizeToRead          size_t      65536   
delay               uint64_t    2721088435  
newSize             size_t      0   
bufferSizeInFrames  uint32_t    16384   
ts  ajn::services::TimedSamples {...}   
size                size_t      65536   
framesWanted        uint32_t    1   
delayInFrames       uint32_t    120000  
sizeRead            size_t      65536

Hope that helps.

edit retag flag offensive close merge delete

Comments

I have tried to mask the problem in `AudioSinkObject.cc:487` by `if (args[1].v_scalarArray.numElements > 0){` Now I have a new crash at: `QStatus _Message::Unmarshal(qcc::String& endpointName, bool handlePassing, bool checkSender, bool pedantic, uint32_t timeout)` With `ER_BUS_BAD_HEADER_FIELD` at line 1317 when `delete [] _msgBuf;`

amit.nishry ( 2014-06-03 14:03:09 -0700 )edit

Dear Amit May you please let me know how to build both the application for android as well as linux. As i have build the both application for linux but the sink does not find the device to play .what should be command line argument to play. And I am not able to build the application for android . Please provide the step by step guid to build the .so and all required . Thanks

Bhagwatks ( 2015-04-16 01:54:01 -0700 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-06-06 13:51:27 -0700

bspencer gravatar image

updated 2014-06-09 14:40:41 -0700

The issue is in the AndroidDevice.cc file. If you make the following changes you will be able to play audio from the Android device to other Sink devices:

1) @ line 30 change: #define BYTES_PER_FRAME 4096 to #define FRAME_BYTE_SIZE 4096

2) @ line line 39 replace mNumberOfFrames with mBytesPerFrame

3) @line 153 change:

mNumberOfFrames = (16 >> 3) * numChannels;
bufferSize = BYTES_PER_FRAME * mNumberOfFrames; 
for (int i = 0; i < NUM_BUFFERS; i++) {
    if (mAudioBuffers[i] == NULL) {
        mAudioBuffers[i] = (uint8_t*)malloc(bufferSize * sizeof(uint8_t));
    }
}

to

mBytesPerFrame = (16 >> 3) * numChannels;
bufferSize = FRAME_BYTE_SIZE / mBytesPerFrame;
for (int i = 0; i < NUM_BUFFERS; i++) {
    if (mAudioBuffers[i] == NULL) {
        mAudioBuffers[i] = (uint8_t*)malloc( FRAME_BYTE_SIZE );
    }
}

4) @line 294 change: bufferSizeInFrames *= mNumberOfFrames; to bufferSizeInFrames *= mBytesPerFrame;

In inc/alljoyn/audio/android/AndroidDevice.h replace @ line 79 uint32_t mNumberOfFrames; with uint32_t mBytesPerFrame;

That should correct the issue of the Android Source from crashing.

edit flag offensive delete publish link more

Comments

Thanks ! I works, this is really nice. (you still have BYTES_PER_FRAME in (3) bufferSize = ... )

amit.nishry ( 2014-06-07 00:53:53 -0700 )edit

Glad it works, corrected the posting.

bspencer ( 2014-06-09 14:40:50 -0700 )edit
Login/Signup to Answer

Question Tools

Follow
1 follower

Stats

Asked: 2014-06-03 12:54:26 -0700

Seen: 181 times

Last updated: Jun 09 '14