mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	Print message when stream started playback, use terminal sequence to clear line when printing that message
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/glitch-free@2436 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
		
							parent
							
								
									86ea73acd3
								
							
						
					
					
						commit
						e0dc1e483c
					
				
					 1 changed files with 18 additions and 6 deletions
				
			
		| 
						 | 
					@ -44,6 +44,8 @@
 | 
				
			||||||
#error Invalid PulseAudio API version
 | 
					#error Invalid PulseAudio API version
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define CLEAR_LINE "\x1B[K"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static enum { RECORD, PLAYBACK } mode = PLAYBACK;
 | 
					static enum { RECORD, PLAYBACK } mode = PLAYBACK;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static pa_context *context = NULL;
 | 
					static pa_context *context = NULL;
 | 
				
			||||||
| 
						 | 
					@ -206,29 +208,38 @@ static void stream_suspended_callback(pa_stream *s, void *userdata) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (verbose) {
 | 
					    if (verbose) {
 | 
				
			||||||
        if (pa_stream_is_suspended(s))
 | 
					        if (pa_stream_is_suspended(s))
 | 
				
			||||||
            fprintf(stderr, "Stream device suspended.\n");
 | 
					            fprintf(stderr, "Stream device suspended." CLEAR_LINE " \n");
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
            fprintf(stderr, "Stream device resumed.\n");
 | 
					            fprintf(stderr, "Stream device resumed." CLEAR_LINE " \n");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void stream_underflow_callback(pa_stream *s, void *userdata) {
 | 
					static void stream_underflow_callback(pa_stream *s, void *userdata) {
 | 
				
			||||||
    assert(s);
 | 
					    assert(s);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fprintf(stderr, "Underrun.\n");
 | 
					    if (verbose)
 | 
				
			||||||
 | 
					        fprintf(stderr, "Stream underrun." CLEAR_LINE " \n");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void stream_overflow_callback(pa_stream *s, void *userdata) {
 | 
					static void stream_overflow_callback(pa_stream *s, void *userdata) {
 | 
				
			||||||
    assert(s);
 | 
					    assert(s);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fprintf(stderr, "Overrun.\n");
 | 
					    if (verbose)
 | 
				
			||||||
 | 
					        fprintf(stderr, "Stream overrun." CLEAR_LINE " \n");
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void stream_started_callback(pa_stream *s, void *userdata) {
 | 
				
			||||||
 | 
					    assert(s);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (verbose)
 | 
				
			||||||
 | 
					        fprintf(stderr, "Stream started." CLEAR_LINE " \n");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void stream_moved_callback(pa_stream *s, void *userdata) {
 | 
					static void stream_moved_callback(pa_stream *s, void *userdata) {
 | 
				
			||||||
    assert(s);
 | 
					    assert(s);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (verbose)
 | 
					    if (verbose)
 | 
				
			||||||
        fprintf(stderr, "Stream moved to device %s (%u, %ssuspended).\n", pa_stream_get_device_name(s), pa_stream_get_device_index(s), pa_stream_is_suspended(s) ? "" : "not ");
 | 
					        fprintf(stderr, "Stream moved to device %s (%u, %ssuspended)." CLEAR_LINE " \n", pa_stream_get_device_name(s), pa_stream_get_device_index(s), pa_stream_is_suspended(s) ? "" : "not ");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* This is called whenever the context status changes */
 | 
					/* This is called whenever the context status changes */
 | 
				
			||||||
| 
						 | 
					@ -249,7 +260,7 @@ static void context_state_callback(pa_context *c, void *userdata) {
 | 
				
			||||||
            assert(!stream);
 | 
					            assert(!stream);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (verbose)
 | 
					            if (verbose)
 | 
				
			||||||
                fprintf(stderr, "Connection established.\n");
 | 
					                fprintf(stderr, "Connection established." CLEAR_LINE " \n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (!(stream = pa_stream_new(c, stream_name, &sample_spec, channel_map_set ? &channel_map : NULL))) {
 | 
					            if (!(stream = pa_stream_new(c, stream_name, &sample_spec, channel_map_set ? &channel_map : NULL))) {
 | 
				
			||||||
                fprintf(stderr, "pa_stream_new() failed: %s\n", pa_strerror(pa_context_errno(c)));
 | 
					                fprintf(stderr, "pa_stream_new() failed: %s\n", pa_strerror(pa_context_errno(c)));
 | 
				
			||||||
| 
						 | 
					@ -263,6 +274,7 @@ static void context_state_callback(pa_context *c, void *userdata) {
 | 
				
			||||||
            pa_stream_set_moved_callback(stream, stream_moved_callback, NULL);
 | 
					            pa_stream_set_moved_callback(stream, stream_moved_callback, NULL);
 | 
				
			||||||
            pa_stream_set_underflow_callback(stream, stream_underflow_callback, NULL);
 | 
					            pa_stream_set_underflow_callback(stream, stream_underflow_callback, NULL);
 | 
				
			||||||
            pa_stream_set_overflow_callback(stream, stream_overflow_callback, NULL);
 | 
					            pa_stream_set_overflow_callback(stream, stream_overflow_callback, NULL);
 | 
				
			||||||
 | 
					            pa_stream_set_started_callback(stream, stream_started_callback, NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (latency > 0) {
 | 
					            if (latency > 0) {
 | 
				
			||||||
                memset(&buffer_attr, 0, sizeof(buffer_attr));
 | 
					                memset(&buffer_attr, 0, sizeof(buffer_attr));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue