LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-30-2016, 01:24 PM   #1
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,959

Rep: Reputation: 271Reputation: 271Reputation: 271
beep returns -1, strerror returns SUCCESS


My computer stopped beeping. Audio works. My default audio device has a separate beep function which has a separate volume control (now set to 100, usually too loud). I wrote a program that calls curses's beep function (man beep) that reports what beep returns (the man page tells me that older versions always returned SuCCESS). beep returns -1, strerror returns SUCCESS.
 
Old 05-02-2016, 07:14 AM   #2
cliffordw
Member
 
Registered: Jan 2012
Location: South Africa
Posts: 509

Rep: Reputation: 203Reputation: 203Reputation: 203
Hi there,

Regarding the beep in general, can you share some info on your setup - distro, desktop, etc?

Regarding the ncurses sample program, I'm not an expert at this, but as far as I can tell, beep() calls putp(), which in turn calls tputs(). According to the tputs man page, "It does not detect I/O errors: X/Open states that tputs ignores the return value of the output function putc.". I read this as meaning beep should return OK if it could send the BELL request to the terminal, whether that produces a sound or not. This is what happened for me with alerts turned off in my desktop sound preferences.

Any chance you can share the code?
 
Old 05-02-2016, 04:00 PM   #3
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,959

Original Poster
Rep: Reputation: 271Reputation: 271Reputation: 271
Code:
	void main(){
	int value;
	
	/* this is the curses beep function */
	value=beep();
	printf("curses beep returns: %d, %s", value, strerror(errno));
	return;
	}
beep's man page says:
Quote:
These routines return OK if they succeed in beeping or flashing, ERR otherwise.
Does -1 indicate success? I expected 0. If -1 indicates failure, why is errno 0?
 
Old 05-02-2016, 05:12 PM   #4
ardvark71
LQ Veteran
 
Registered: Feb 2015
Location: USA
Distribution: Lubuntu 14.04, 22.04, Windows 8.1 and 10
Posts: 6,282
Blog Entries: 4

Rep: Reputation: 842Reputation: 842Reputation: 842Reputation: 842Reputation: 842Reputation: 842Reputation: 842
Hi...

So the speaker no longer beeps no matter what you try? It might be that the speaker itself has gone out and needs replaced.

Regards...
 
Old 05-02-2016, 05:56 PM   #5
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,959

Original Poster
Rep: Reputation: 271Reputation: 271Reputation: 271
Quote:
Originally Posted by ardvark71 View Post
the speaker no longer beeps no matter what you try? It might be that the speaker itself has gone out and needs replaced.
The speaker makes every other sound *but* the beep. The original IBM PC had a chip (the 8042) that controlled the keyboard but was also used for other purposes, among them generating sine waves. One programmed it by sending I/O to the 8042's port, first telling it what frequency to use then the length of time. Eventually IBM-type PCs no longer had 8042s or their ports. They either ignored attempts to write to the 8042's port or treated them as a privilege violation. For compatibility's sake some started capturing the attempt and making their own beep. This matters in some cases because some audio players lock out multiple attempts to make sound and some won't play from background, which means I won't hear a warning beep interrupt listening to the stuff I have playing.

I used to have IBM Thinkpads that had specially-privileged beeps. The drivers that come with the builtin audio (Realtek) have a special beep function, which has its own volume control. which dmesg reports as loading. I suppose it's possible there's a hardware failure that causes the beep to not-work while all other sound does.

I asked because the output of curses's beep on my system is ambiguous: -1 seems to report failure, errno=0 reports success. If beep() reports failure, then perhaps I have a software problem.

I tried booting into DOS and running the short assembler program that beeps, but that didn't work back when the beep worked. As near as I can tell Windoze doesn't make a 'real' beep.
 
Old 05-02-2016, 06:10 PM   #6
ardvark71
LQ Veteran
 
Registered: Feb 2015
Location: USA
Distribution: Lubuntu 14.04, 22.04, Windows 8.1 and 10
Posts: 6,282
Blog Entries: 4

Rep: Reputation: 842Reputation: 842Reputation: 842Reputation: 842Reputation: 842Reputation: 842Reputation: 842
Quote:
Originally Posted by RandomTroll View Post
The speaker makes every other sound *but* the beep.
Ok, well, scratch that idea. Had you not heard anything, I could have offered you this information, as well.

Your problem is a bit strange or unusual, though.

Regards...

Last edited by ardvark71; 05-02-2016 at 06:12 PM. Reason: Added information and link.
 
Old 05-03-2016, 12:11 AM   #7
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,959

Original Poster
Rep: Reputation: 271Reputation: 271Reputation: 271
The mixer for the builtin audio has a switch for the beep: it's off; I don't know how that happened: I've never turned it off.

Quote:
amixer -c 0 set Beep Playback Switch on
turns it on. I added this to rc.local.

Oddly, the beep program still makes no beep.
Quote:
echo -ne "\007"
does.

Aftermath: it stopped working again a few minutes later. Then my internal speakers stopped working but the audio to the jack started working (but ignores volume control). I think the audio chip is misbehaving.

Aftermath 2: After reboot the PCM control has disappeared, so I can't control the volume. An hour later it has returned. /proc/asound/timers doesn't report whether any audio is playing, as it used to: more data consistent with hardware misbehavior.

Last edited by RandomTroll; 05-03-2016 at 08:55 AM.
 
Old 05-03-2016, 09:29 AM   #8
cliffordw
Member
 
Registered: Jan 2012
Location: South Africa
Posts: 509

Rep: Reputation: 203Reputation: 203Reputation: 203
Quote:
Originally Posted by RandomTroll View Post
Code:
	void main(){
	int value;
	
	/* this is the curses beep function */
	value=beep();
	printf("curses beep returns: %d, %s", value, strerror(errno));
	return;
	}
I think you need to at least initialize the terminal with
Code:
initscr();
first.
 
1 members found this post helpful.
Old 05-03-2016, 12:10 PM   #9
cliffordw
Member
 
Registered: Jan 2012
Location: South Africa
Posts: 509

Rep: Reputation: 203Reputation: 203Reputation: 203
Quote:
Originally Posted by cliffordw View Post
I think you need to at least initialize the terminal with
Code:
initscr();
first.
Working sample:

Code:
#include <ncurses/curses.h>
#include <errno.h>
#include <string.h>
int main(){
    int value;
                                                                                                                                                                                                      
    initscr();
    /* this is the curses beep function */
    value=beep();
    endwin();
    printf("curses beep returns: %d, %s\n", value, strerror(errno));
    return value;
}
This works for me, and returns zero whether the alert is enabled or not in my mixer.
 
1 members found this post helpful.
Old 05-03-2016, 11:22 PM   #10
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,959

Original Poster
Rep: Reputation: 271Reputation: 271Reputation: 271
Quote:
Originally Posted by cliffordw View Post
I think you need to at least initialize the terminal with
Code:
initscr();
first.
You are right. Thanks.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
dd never returns in BackTrack2 manolakis Linux - Newbie 17 03-01-2007 06:53 AM
Carriage Returns Thorkyl Linux - Software 7 06-28-2004 05:42 PM
setup returns after doing nothing?? dfong63 Slackware - Installation 5 06-04-2004 01:40 AM
c difftime returns zero mr.neil Programming 3 06-02-2004 12:43 PM
mktime() returns -1 nodger Programming 2 01-27-2004 04:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration