(Note 11/26: I edited the title of the thread to more accurately reflect the issue. The problem in the initial post was solved by sending GAVD_Start_Stream_Request prior to starting the A3DP streamer, and I then happened upon a problem with disconnection while streaming. Original post left here for posterity)
I am attempting to stream from a CC2564B to two sink devices. I am using the Bluetopia 1.2 R2 release and a Panasonic PAN1326B. The CC256xB 1.0 patch included with 1.2 R2 is being used. (Do I still need the multiroom version of the patch installed for this to work?)
The I2S format going to the module is 16-bit left justified, coming from a DSP. The LRCLK is running at around 48,077 hz (being driven by a TM4C1290 PWM - system clock is 120 mhz). Thus, I have changed VS_PCM_Codec_Config to slave/input/I2S with the following parameters (changes highlighted in bold):
/* PCM clock rate (kHz) and direction (0 = output, 1 = input) */
ASSIGN_HOST_WORD_TO_LITTLE_ENDIAN_UNALIGNED_WORD(&CommandBuffer[0], PCMFreq);
CommandBuffer[2] = 0x01;
/* Frame-sync freq (Hz) and duty cycle. For duty cycle, 0 will */
/* generate 50% duty cycle, >= 1 uses number of PCM clock cycles. */
ASSIGN_HOST_DWORD_TO_LITTLE_ENDIAN_UNALIGNED_DWORD(&CommandBuffer[3], FSyncFreq);
ASSIGN_HOST_WORD_TO_LITTLE_ENDIAN_UNALIGNED_WORD(&CommandBuffer[7], 0x0000);
/* Frame-sync edge: 0 = rising edge, 1 = falling edge */
CommandBuffer[9] = 0x00;
/* Frame-sync polarity: 0 = active high, 1 = active low */
CommandBuffer[10] = 0x00;
/* channel 1 data out size, offset, and edge (0 = rise, 1 = fall) */
ASSIGN_HOST_WORD_TO_LITTLE_ENDIAN_UNALIGNED_WORD(&CommandBuffer[12], 16);
ASSIGN_HOST_WORD_TO_LITTLE_ENDIAN_UNALIGNED_WORD(&CommandBuffer[14], 0);
CommandBuffer[16] = 0x00;
/* channel 1 data in size, offset, and edge (0 = rise, 1 = fall) */
ASSIGN_HOST_WORD_TO_LITTLE_ENDIAN_UNALIGNED_WORD(&CommandBuffer[17], 16);
ASSIGN_HOST_WORD_TO_LITTLE_ENDIAN_UNALIGNED_WORD(&CommandBuffer[19], 0);
CommandBuffer[21] = 0x00;
/* channel 2 data out size, offset, and edge (0 = rise, 1 = fall) */
ASSIGN_HOST_WORD_TO_LITTLE_ENDIAN_UNALIGNED_WORD(&CommandBuffer[23], 16);
ASSIGN_HOST_WORD_TO_LITTLE_ENDIAN_UNALIGNED_WORD(&CommandBuffer[25], 16);
CommandBuffer[27] = 0x01;
/* channel 2 data in size, offset, and edge (0 = rise, 1 = fall) */
ASSIGN_HOST_WORD_TO_LITTLE_ENDIAN_UNALIGNED_WORD(&CommandBuffer[28], 16);
ASSIGN_HOST_WORD_TO_LITTLE_ENDIAN_UNALIGNED_WORD(&CommandBuffer[30], 16);
CommandBuffer[32] = 0x01;
Here is the rough sequence of relevant startup events
BSC_EnableFeature BSC_FEATURE_A3DP_SOURCE
[Each of the following for both devices:]
GAVD_Connect
Connect confirmation
Discover endpoints
Get capabilities
Connect remote endpoint
Open endpoint confirmation
Role change to become master
Everything works up to this point, and if I'm doing the encoding on the MCU, with standard GAVD_Start_Stream_Request, SBC_Encode, and GAVD_Write_Data rather than the A3DP stuff, I do hear the audio. The I2S output line from the DSP is going to the MCU as well as to the CC2564B, and the MCU can read it with two SPIs forming a hackjob I2S
So, when I try to set up the assisted mode, here's what I do: (MaxBitpool is a number determined by the lowest common denominator - either my maximum bitpool, the first device's maximum bitpool, or the second device's maximum bitpool, whichever is lowest)
VS_A3DP_Open_Stream(stackid, Handle1, RemoteCID1, OutMTU1);
VS_A3DP_Open_Stream(stackid, Handle2, RemoteCID2, OutMTU2);
VS_PCM_Codec_Config(stackid, 1538, 48077);
AudioFormat = (AVRP_AUDIO_FORMAT_SBC_SAMPLE_RATE_48K | AVRP_AUDIO_FORMAT_PCM_SAMPLE_RATE_48K | AVRP_AUDIO_FORMAT_SBC_MODE_STEREO);
SBCFormat = (AVRP_SBC_FORMAT_ALLOCATION_METHOD_LOUDNESS | AVRP_SBC_FORMAT_BLOCK_LENGTH_16);
VS_A3DP_Codec_Configuration(stackid, AudioFormat, SBCFormat, MaxBitpool);
This all returns success the first time I call it.
When I try to start the assisted streams, the function calls return success but I hear no audio in the sinks.
VS_A3DP_Start_Stream(stackid, Handle1);
VS_A3DP_Start_Stream(stackid, Handle2);
Furthermore, although I don't know if this is relevant to finding out why starting it seems to do nothing, I get a vendor specific debug event with 3 bytes 0x00 0x03 0x01 after sending stop stream commands for both handles. After that, most of my commands in the VS_A3DP_* category fail with -512, -518, or block for 5 seconds and then return -57. e.g.
VS_A3DP_Close_Stream(stackid, Handle1); // returns 0
VS_A3DP_Close_Stream(stackid, Handle2); // returns -518 aka HCI error code 18 aka INVALID_HCI_COMMAND_PARAMETERS
VS_A3DP_Open_Stream(stackid, Handle1); // returns 0
VS_A3DP_Open_Stream(stackid, Handle2); // returns -518
VS_A3DP_Start_Stream(stackid, Handle1); // returns 0
VS_A3DP_Start_Stream(stackid, Handle2); // returns -518
VS_A3DP_Stop_Stream(stackid, Handle1); // blocks 5 seconds, returns -57
VS_A3DP_Stop_Stream(stackid, Handle2); // blocks 5 seconds, returns -57
I assume this funky behavior is mostly just due to me messing something up in the setup/starting of the streams and therefore it's left in some limbo state.
I have tried with the original offsets of 1 and 17 in VS_PCM_Codec_Config, but from what I understand with left justified mode the offset is supposed to be 0 and 16
I have also tried setting the Fsync multiplier parameter to 32, but to no avail.
CommandBuffer[22] = 32;
So, where do I look for where I went wrong?
Any other information needed? I have complete logs of all function calls, the return codes, event data, etc., so just let me know what would help figure it out.
Thanks :)