Skip to contentSkip to conversation

pcm_multi poll timeout error

DISCUSSION John Rigg 6 participants 12 messages Dec 8, 2005 – Aug 8, 2006

lore
Share & tools
lore

John Rigg

author
#0 lore raw
Quoted 8 lines · John Rigg

The pcm_multi plugin doesn't work currently with jackd in duplex mode. It's OK for either capture or playback with multi cards, but a poll time out occurs in duplex mode. Several users have experienced this problem with multiple ice1712 and RME cards.
After some testing I found the following:

alsa-lib-1.0.8 works
alsa-lib-1.0.9rc1 onwards gives poll time out

I got my two Delta 1010s working with jackd and pcm_multi in duplex mode by removing three functions that were added in pcm_multi.c rev 1.89:
snd_pcm_multi_link_fd_failed()
snd_pcm_multi_link_fd()
snd_pcm_multi_unlink()
along with two associated members of snd_pcm_multi_fast_ops structure:
.link_fd = snd_pcm_multi_link_fd
.unlink = snd_pcm_multi_unlink

I then started trying to debug the code causing the problem. Adding extra printf's showed that none of the extra functions executed unless jackd was started with both -C and -P devices (ie. duplex), and then only snd_pcm_multi_link_fd(). This executed twice (once for capture and once for playback presumably). Neither of the two other new functions was used when the poll time out occurred.

Unfortunately I'm now getting a little out of my depth. I've been studying the docs and the source code, but the source is a little sparse on comments and hard to follow for someone of my limited programming experience. Does anyone have any pointers for a dumb sound engineer/musician trying to understand what this extra linking code in pcm_multi.c is supposed to be doing?

John

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click

#1 lore raw

At Thu, 08 Dec 2005 19:13:40 +0000,

Quoted 27 lines · John Rigg
Quoted 8 lines · John Rigg

The pcm_multi plugin doesn't work currently with jackd in duplex mode. It's OK for either capture or playback with multi cards, but a poll time out occurs in duplex mode. Several users have experienced this problem with multiple ice1712 and RME cards.
After some testing I found the following:

alsa-lib-1.0.8 works
alsa-lib-1.0.9rc1 onwards gives poll time out

I got my two Delta 1010s working with jackd and pcm_multi in duplex mode by removing three functions that were added in pcm_multi.c rev 1.89:
snd_pcm_multi_link_fd_failed()
snd_pcm_multi_link_fd()
snd_pcm_multi_unlink()
along with two associated members of snd_pcm_multi_fast_ops structure:
.link_fd = snd_pcm_multi_link_fd
.unlink = snd_pcm_multi_unlink

I then started trying to debug the code causing the problem. Adding extra printf's showed that none of the extra functions executed unless jackd was started with both -C and -P devices (ie. duplex), and then only snd_pcm_multi_link_fd(). This executed twice (once for capture and once for playback presumably). Neither of the two other new functions was used when the poll time out occurred.

Quoted 5 lines

Unfortunately I'm now getting a little out of my depth. I've been studying the docs and the source code, but the source is a little sparse on comments and hard to follow for someone of my limited programming experience. Does anyone have any pointers for a dumb sound engineer/musician trying to understand what this extra linking code in pcm_multi.c is supposed to be doing?

The link_fd returns the file descriptor for linking multiple PCM streams. If you comment it out, it means that no link is possible. It means that snd_pcm_link() didn't do anything in fact after your patch.

The recent version of multi plugin returns only one pollfd of the master, and this seems breaking the stuff in JACK. And, I think checking only the master is a bad solution.

Takashi

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click

author
#2 lore raw
Quoted 4 lines · Takashi Iwai

The link_fd returns the file descriptor for linking multiple PCM streams. If you comment it out, it means that no link is possible. It means that snd_pcm_link() didn't do anything in fact after your patch.

Hi Takashi

Thanks for the information. Now I'm puzzled. I assumed that pcm_multi was working from the messages from jackd -v, but didn't actually try recording and playing back simultaneously (haven't got that far setting up my system). However, I just received the following info from another user who tried my makeshift patch:

Quoted 4 lines
Quoted 4 lines · Achim_Kuntz
Quoted 3 lines

I can confirm your results with my 2 x hdsp 9652 setup.
With your patch applied jackd works in duplex mode using the multi device.

....

Quoted 1 line
Quoted 1 line

Can you actually record and play back simultaneously?

....

Quoted 5 lines

Yes, I can record and play back simultaneously with the patch applied. I tested playback for all 2*24=48 channels of the multi device while recording audio from the first channel of the first hdsp card, i.e. I tested all playback channels but not all recording channels. Everything seemed to work as intended.

I can't understand why this works after my patch broke snd_pcm_link .

John

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click

#3 lore raw

It probably works because the rme cards are synced by an external means such as word clock or the entity they are connected to has master sync

_J

Quoted 32 lines · John Rigg
Quoted 4 lines · Takashi Iwai

The link_fd returns the file descriptor for linking multiple PCM streams. If you comment it out, it means that no link is possible. It means that snd_pcm_link() didn't do anything in fact after your patch.

Hi Takashi

Thanks for the information. Now I'm puzzled. I assumed that pcm_multi was working from the messages from jackd -v, but didn't actually try recording and playing back simultaneously (haven't got that far setting up my system). However, I just received the following info from another user who tried my makeshift patch:

Quoted 4 lines
Quoted 4 lines · Achim_Kuntz
Quoted 3 lines

I can confirm your results with my 2 x hdsp 9652 setup.
With your patch applied jackd works in duplex mode using the multi device.

....

Quoted 1 line
Quoted 1 line

Can you actually record and play back simultaneously?

....

Quoted 5 lines

Yes, I can record and play back simultaneously with the patch applied. I tested playback for all 2*24=48 channels of the multi device while recording audio from the first channel of the first hdsp card, i.e. I tested all playback channels but not all recording channels. Everything seemed to work as intended.

I can't understand why this works after my patch broke snd_pcm_link .

John

Quoted 10 lines

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click

author
#4 lore raw
Quoted 11 lines · Jeremy Hall
Quoted 7 lines · John Rigg
Quoted 4 lines · Takashi Iwai

The link_fd returns the file descriptor for linking multiple PCM streams. If you comment it out, it means that no link is possible. It means that snd_pcm_link() didn't do anything in fact after your patch.

I can't understand why this works after my patch broke snd_pcm_link .

It probably works because the rme cards are synced by an external means such as word clock or the entity they are connected to has master sync

Makes sense. So, the situation appears to be:
1 - The link code is unnecessary for duplex operation of multiple clock-synchronised sound cards with jackd.
2 - It breaks the above when present.

John

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click

#5 lore raw

At Fri, 9 Dec 2005 20:15:02 +0000,

Quoted 11 lines · John Rigg
Quoted 9 lines · Jeremy Hall
Quoted 7 lines · John Rigg
Quoted 4 lines · Takashi Iwai

The link_fd returns the file descriptor for linking multiple PCM streams. If you comment it out, it means that no link is possible. It means that snd_pcm_link() didn't do anything in fact after your patch.

I can't understand why this works after my patch broke snd_pcm_link .

Quoted 7 lines
Quoted 2 lines

It probably works because the rme cards are synced by an external means such as word clock or the entity they are connected to has master sync

Makes sense. So, the situation appears to be:
1 - The link code is unnecessary for duplex operation of multiple clock-synchronised sound cards with jackd.
2 - It breaks the above when present.

Hm, the question is what the cable-sync really does. Basically the linked PCM streams in ALSA are just for trigger actions, i.e. start/stop streams. The others are not really related.

However, the recent changes of multi pcm tries to use only one pollfd as a master, and this seems broken in your case. Or, it's really the matter of linked streams.

Will come back to this issue later...

Takashi

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click

#6 lore raw
Quoted 25 lines · Takashi Iwai

At Fri, 9 Dec 2005 20:15:02 +0000,

Quoted 11 lines · John Rigg
Quoted 9 lines · Jeremy Hall
Quoted 7 lines · John Rigg
Quoted 4 lines · Takashi Iwai

The link_fd returns the file descriptor for linking multiple PCM streams. If you comment it out, it means that no link is possible. It means that snd_pcm_link() didn't do anything in fact after your patch.

I can't understand why this works after my patch broke snd_pcm_link .

Quoted 7 lines
Quoted 2 lines

It probably works because the rme cards are synced by an external means such as word clock or the entity they are connected to has master sync

Makes sense. So, the situation appears to be:
1 - The link code is unnecessary for duplex operation of multiple clock-synchronised sound cards with jackd.
2 - It breaks the above when present.

Hm, the question is what the cable-sync really does. Basically the linked PCM streams in ALSA are just for trigger actions, i.e. start/stop streams. The others are not really related.

Quoted 6 lines

However, the recent changes of multi pcm tries to use only one pollfd as a master, and this seems broken in your case. Or, it's really the matter of linked streams.

Will come back to this issue later...

Takashi-san,

I'm not sure I fully understand - are you saying JACK is broken or that it's an ALSA bug?

Lee

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

#7 lore raw

At Mon, 31 Jul 2006 22:04:26 -0400,

Quoted 31 lines · Lee Revell
Quoted 29 lines · Takashi Iwai

At Fri, 9 Dec 2005 20:15:02 +0000,

Quoted 11 lines · John Rigg
Quoted 9 lines · Jeremy Hall
Quoted 7 lines · John Rigg
Quoted 4 lines · Takashi Iwai

The link_fd returns the file descriptor for linking multiple PCM streams. If you comment it out, it means that no link is possible. It means that snd_pcm_link() didn't do anything in fact after your patch.

I can't understand why this works after my patch broke snd_pcm_link .

Quoted 7 lines
Quoted 2 lines

It probably works because the rme cards are synced by an external means such as word clock or the entity they are connected to has master sync

Makes sense. So, the situation appears to be:
1 - The link code is unnecessary for duplex operation of multiple clock-synchronised sound cards with jackd.
2 - It breaks the above when present.

Hm, the question is what the cable-sync really does. Basically the linked PCM streams in ALSA are just for trigger actions, i.e. start/stop streams. The others are not really related.

However, the recent changes of multi pcm tries to use only one pollfd as a master, and this seems broken in your case. Or, it's really the matter of linked streams.

Quoted 7 lines
Quoted 2 lines

Will come back to this issue later...

Takashi-san,

I'm not sure I fully understand - are you saying JACK is broken or that it's an ALSA bug?

It's an "undefined behavior".
I suppose that software-linked PCM streams do right thing, but we need to investigate the detail.

John, could you check whether the problem still appears with the latest ALSA HG version, especially with alsa-lib? I remember that some fixes have been done on multi plugin.

Takashi

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

author
#8 lore raw
Quoted 7 lines · Takashi Iwai

It's an "undefined behavior".
I suppose that software-linked PCM streams do right thing, but we need to investigate the detail.

John, could you check whether the problem still appears with the latest ALSA HG version, especially with alsa-lib? I remember that some fixes have been done on multi plugin.

Yes, I'll check it. Might be a few days before I get time though.

John

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

#9 lore raw
In reply to Takashi Iwai
Quoted 41 lines · Takashi Iwai

At Mon, 31 Jul 2006 22:04:26 -0400,

Quoted 31 lines · Lee Revell
Quoted 29 lines · Takashi Iwai

At Fri, 9 Dec 2005 20:15:02 +0000,

Quoted 11 lines · John Rigg
Quoted 9 lines · Jeremy Hall
Quoted 7 lines · John Rigg
Quoted 4 lines · Takashi Iwai

The link_fd returns the file descriptor for linking multiple PCM streams. If you comment it out, it means that no link is possible. It means that snd_pcm_link() didn't do anything in fact after your patch.

I can't understand why this works after my patch broke snd_pcm_link .

Quoted 7 lines
Quoted 2 lines

It probably works because the rme cards are synced by an external means such as word clock or the entity they are connected to has master sync

Makes sense. So, the situation appears to be:
1 - The link code is unnecessary for duplex operation of multiple clock-synchronised sound cards with jackd.
2 - It breaks the above when present.

Hm, the question is what the cable-sync really does. Basically the linked PCM streams in ALSA are just for trigger actions, i.e. start/stop streams. The others are not really related.

However, the recent changes of multi pcm tries to use only one pollfd as a master, and this seems broken in your case. Or, it's really the matter of linked streams.

Quoted 7 lines
Quoted 2 lines

Will come back to this issue later...

Takashi-san,

I'm not sure I fully understand - are you saying JACK is broken or that it's an ALSA bug?

Quoted 7 lines

It's an "undefined behavior".
I suppose that software-linked PCM streams do right thing, but we need to investigate the detail.

John, could you check whether the problem still appears with the latest ALSA HG version, especially with alsa-lib? I remember that some fixes have been done on multi plugin.

The problem still appears with alsa-lib-1.0.12rc2 version. There are no changes in pcm_multi since 1.0.11.

Is there an easy way to view changes in the hg repository, ie. an equivalent to the old cvs viewer on Sourceforge?
I'm testing this on my production system, which is a little disruptive, so it would be convenient to be able to check for changes in the code before trying it.

John

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

#10 lore raw

At Sun, 6 Aug 2006 16:03:49 +0100,

Quoted 47 lines · John Rigg
Quoted 45 lines · Takashi Iwai

At Mon, 31 Jul 2006 22:04:26 -0400,

Quoted 31 lines · Lee Revell
Quoted 29 lines · Takashi Iwai

At Fri, 9 Dec 2005 20:15:02 +0000,

Quoted 11 lines · John Rigg
Quoted 9 lines · Jeremy Hall
Quoted 7 lines · John Rigg
Quoted 4 lines · Takashi Iwai

The link_fd returns the file descriptor for linking multiple PCM streams. If you comment it out, it means that no link is possible. It means that snd_pcm_link() didn't do anything in fact after your patch.

I can't understand why this works after my patch broke snd_pcm_link .

Quoted 7 lines
Quoted 2 lines

It probably works because the rme cards are synced by an external means such as word clock or the entity they are connected to has master sync

Makes sense. So, the situation appears to be:
1 - The link code is unnecessary for duplex operation of multiple clock-synchronised sound cards with jackd.
2 - It breaks the above when present.

Hm, the question is what the cable-sync really does. Basically the linked PCM streams in ALSA are just for trigger actions, i.e. start/stop streams. The others are not really related.

However, the recent changes of multi pcm tries to use only one pollfd as a master, and this seems broken in your case. Or, it's really the matter of linked streams.

Quoted 7 lines
Quoted 2 lines

Will come back to this issue later...

Takashi-san,

I'm not sure I fully understand - are you saying JACK is broken or that it's an ALSA bug?

It's an "undefined behavior".
I suppose that software-linked PCM streams do right thing, but we need to investigate the detail.

Quoted 6 lines
Quoted 3 lines

John, could you check whether the problem still appears with the latest ALSA HG version, especially with alsa-lib? I remember that some fixes have been done on multi plugin.

The problem still appears with alsa-lib-1.0.12rc2 version. There are no changes in pcm_multi since 1.0.11.

The change was not in pcm_multi.c but in pcm_hw.c. But anyway this seems irrelevant.

Quoted 5 lines

Is there an easy way to view changes in the hg repository, ie. an equivalent to the old cvs viewer on Sourceforge?
I'm testing this on my production system, which is a little disruptive, so it would be convenient to be able to check for changes in the code before trying it.

Try access to http://hg-mirror.alsa-project.org from your browser.

Takashi

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

#11 lore raw
In reply to John Rigg
Quoted 7 lines · John Rigg
Quoted 3 lines · Takashi Iwai

John, could you check whether the problem still appears with the latest ALSA HG version, especially with alsa-lib? I remember that some fixes have been done on multi plugin.

The problem still appears with alsa-lib-1.0.12rc2 version. There are no changes in pcm_multi since 1.0.11.

I can reproduce this problem. It seems to be a bug in the multi plugin.

snd_pcm_multi_start() does not call snd_pcm_start() for any of its slave PCMs that are linked to another, i.e., for slaves where the 'linked' field in the slaves array is set.

snd_pcm_multi_hw_params() sets 'linked' for all but one of the slaves. snd_pcm_multi_link_fd(), however, sets 'linked' for all its slaves, and gets called for both the playback and capture PCMs in the full duplex case.

This means that none of the slave PCMs ever gets started. After jackd's snd_pcm_start() call, the state is still PREPARED.

Regards,
Clemens

Signature · 9 lines
  Clemens Ladisch
  [email protected]


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642