Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
dbigham
Posts: 552
Registered: ‎04-01-2009
My Device: Z10, PlayBook
Accepted Solution

snd_pcm_channel_status

Some time ago I tried to port my Flix application to the Q10, but I was dismayed to find that when I ran the app even on the Z10, for which it's already released, it no longer worked from the IDE.  The app works fine if I use the BAR from App World, but if I re-compile and deploy it, the audio synchronization is way off.

 

I think I've debugged this to the call to:

 

snd_pcm_channel_status

 

... which returns a struct snd_pcm_channel_status_t. When I inspect the 'count', it always seems to return 0. It's supposed to return:

 

"The number of bytes processed since the playback/capture last started. This value is clipped when it reaches the SND_PCM_BOUNDARY value, and is reset when you prepare the channel."

 

As you can imagine, having this return 0 means that I am unable to sync the audio properly.

 

I am using SDK 10.0.9.2372.

 

I've also tried the 10.1 SDK.

 

Retired
s_rashid
Posts: 127
Registered: ‎02-27-2012
My Device: Bold

Re: snd_pcm_channel_status

Hi @dbigham,

Are you saying that if you compile the same code project and then deploy the BAR, it works fine? But if you just directly run from the IDE you get that error?

I'm not exactly sure yet as to what might be going on in you case but here are a few things to check against:

1) I am assuming you came across the following sample app which also uses "snd_pcm_channel_status"?
AudioLoopBackSample: https://github.com/blackberry/Core-Native-Community-Samples/tree/master/AudioLoopBackSample

Does this sample app also behaves the same for you?

 

2) What is the OS version on the device running and what device is it? Sometimes, it might be worth while to be safe and keep the SDK and device OS version as close as possible

3) I would recommend trying with the latest OS/SDK versions. That is,

10.2 SDK for your IDE: https://developer.blackberry.com/cascades/download/beta/

And 10.2.0.341 Device OS version through autoloader.exe files or OTA: https://developer.blackberry.com/devzone/blackberry10devalpha/devalpha_update.html

 

Let us know what you think/find.

Thanks,
Rashid

Application Development Consultant | Developer Relations

BlackBerry
@surashid

Developer
dbigham
Posts: 552
Registered: ‎04-01-2009
My Device: Z10, PlayBook

Re: snd_pcm_channel_status

Hi Rashid,

 

Thanks for getting back to me. I'll try your suggestions in the next few days.

 

To clarify, I was _not_ saying "that if you compile the same code project and then deploy the BAR, it works fine? But if you just directly run from the IDE you get that error?".

 

I was trying to say that if I install the app from App World, it works fine. There haven't been any substantial changes to the code since that BAR was published to App World a few months ago.

 

My OS version is the latest available for Z10s in Canada for devices not on any carrier... I'll confirm the exact version later. (when I check for updates, it doesn't show any 10.1 updates available... I'm stuck at 10.0)

Developer
dbigham
Posts: 552
Registered: ‎04-01-2009
My Device: Z10, PlayBook

Re: snd_pcm_channel_status

Rashid,

 

So my device version is: 10.0.9.348 (red Z10)

As mentioned my SDK version is: 10.0.9.2372

 

I don't see any SDKs available for download via the Help -> Update Native SDK that are anywhere near 10.0.9.348.

 

I took a look at the AudioLoopBackSample, which I had not seen before, but it doesn't make use of the troublesome 'count' member of the snd_pcm_channel_status_t struct. Running the app appears to work, although it has a confusing UI. The audio seemed a bit choppy, not sure if that was indicitive of any issue or not.

 

As for trying 10.2, there is a warning saying that 10.2 isn't compatible with devices. Is that implying that it wouldn't be compatible with my red Z10?

 

Not sure where to go from here.

Developer
dbigham
Posts: 552
Registered: ‎04-01-2009
My Device: Z10, PlayBook

Re: snd_pcm_channel_status

Rashid,

 

I downloaded the 10.2 SDK and ran the app on my red Z10, and with this SDK, the 'count' member has a value not of 0, but:

 

1664049524

Retired
gsandhu
Posts: 41
Registered: ‎07-14-2008
My Device: Not Specified

Re: snd_pcm_channel_status

Hi,

 

Are you using "count" or "scount"? I tested this using the below audioloopback sample

https://github.com/blackberry/Core-Native-Community-Samples/blob/master/AudioLoopBackSample/src/audi...

 

when calling snd_pcm_channel_status(g_pcm_handle_c, &status) in the capture thread.

 

I get the below results 

Capture -snd_pcm_channel_status counter is: 640
Capture -snd_pcm_channel_status counter is: 1280
Capture -snd_pcm_channel_status counter is: 1920
Capture -snd_pcm_channel_status counter is: 2560
Capture -snd_pcm_channel_status counter is: 3200
Capture -snd_pcm_channel_status counter is: 3840
Capture -snd_pcm_channel_status counter is: 4480
Capture -snd_pcm_channel_status counter is: 5120
Capture -snd_pcm_channel_status counter is: 5760

 

I am using 10.1.0.1020 SDK and using the 10.1 OS code. Can you run this same test using this sample on your device. Please ignore the behaviour in choppy audio as it was a known issue on pre 10.1 OS.

 

Thanks,
Gurtej Sandhu
Application Development Consultant
Developer Relations, 
@_GurtejSandhu

Developer
dbigham
Posts: 552
Registered: ‎04-01-2009
My Device: Z10, PlayBook

Re: snd_pcm_channel_status

Thanks.

 

I seem to still get 0s, using SDK 10.0.9.1673: (using count, not scount)

 

 

static int capture(circular_buffer_t* circular_buffer) {
	// Re-usable buffer for capture
	char *record_buffer;
	record_buffer = (char*) malloc(g_frame_size_c);

	// Some diagnostic variables
	int failed = 0;
	int totalRead = 0;
	snd_pcm_channel_status_t status;
	status.channel = SND_PCM_CHANNEL_CAPTURE;

	// Loop until stopAudio() flags us
	while (g_execute_audio) {
		// This blocking read appears to take much longer than 20ms on the simulator
		// but it never fails and always returns 160 bytes
		int read = snd_pcm_plugin_read(g_pcm_handle_c, record_buffer,
				g_frame_size_c);

		snd_pcm_plugin_status(g_pcm_handle_c, &status);
		fprintf(stderr, "Capture -snd_pcm_channel_status counter is: %i\n", status.count);

 

Does this imply that I should be upgrading my device to a newer version of software?  Remind me how to do that? I have found it frustrating that when I go to the "Software Updates" screen in Settings and look for updates, it tells me that I have the latest software, and yet 10.1 has been out for a long time. What's the reason for that?

Retired
s_rashid
Posts: 127
Registered: ‎02-27-2012
My Device: Bold

Re: snd_pcm_channel_status

Hi @dbigham,

The OS version you have now on the the public/consumer device is being dictated by the Carrier. Which carrier/network are you using anyway? Verizon & AT&T both should be rolling out the 10.1 version soon (hopefully, within a few weeks).

If you just want to test/develop against your phone, you can use the autoloader.exe file to just replace your current consumer OS and replace it with the developer OS (i.e. some core apps would most likely be missing).

https://developer.blackberry.com/devzone/blackberry10devalpha/devalpha_update.html

I believe you can also restore back to the original carrier OS version through the BlackBerry Link software, depending on how you initially got the OS. But you should double check that before you go ahead and wipe you consumer OS version.

Cheers,
Rashid

Application Development Consultant | Developer Relations

BlackBerry
@surashid






Developer
dbigham
Posts: 552
Registered: ‎04-01-2009
My Device: Z10, PlayBook

Re: snd_pcm_channel_status

Rashid,

 

I don't have this phone on any carrier at all... it's just a Wi-Fi device. It's a standard red Z10 that has never had a SIM card put in it.

 

This seems to limit me when I try and update my OS.  Is there no plan for updating non-carrier Z10 owners OS?

 

I would prefer not to wipe the OS and lose all of my apps, etc... that sounds like quite a hassle. Ugh. I kind of kills the device.

Developer
dbigham
Posts: 552
Registered: ‎04-01-2009
My Device: Z10, PlayBook

Re: snd_pcm_channel_status