mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	fix pacat
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@550 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
		
							parent
							
								
									36c8861db6
								
							
						
					
					
						commit
						a10257d680
					
				
					 1 changed files with 51 additions and 13 deletions
				
			
		| 
						 | 
					@ -80,7 +80,12 @@ static void do_stream_write(size_t length) {
 | 
				
			||||||
    if (l > buffer_length)
 | 
					    if (l > buffer_length)
 | 
				
			||||||
        l = buffer_length;
 | 
					        l = buffer_length;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    pa_stream_write(stream, (uint8_t*) buffer + buffer_index, l, NULL, 0, PA_SEEK_RELATIVE);
 | 
					    if (pa_stream_write(stream, (uint8_t*) buffer + buffer_index, l, NULL, 0, PA_SEEK_RELATIVE) < 0) {
 | 
				
			||||||
 | 
					        fprintf(stderr, "pa_stream_write() failed: %s\n", pa_strerror(pa_context_errno(context)));
 | 
				
			||||||
 | 
					        quit(1);
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    buffer_length -= l;
 | 
					    buffer_length -= l;
 | 
				
			||||||
    buffer_index += l;
 | 
					    buffer_index += l;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
| 
						 | 
					@ -112,12 +117,20 @@ static void stream_read_callback(pa_stream *s, size_t length, void *userdata) {
 | 
				
			||||||
    if (stdio_event)
 | 
					    if (stdio_event)
 | 
				
			||||||
        mainloop_api->io_enable(stdio_event, PA_IO_EVENT_OUTPUT);
 | 
					        mainloop_api->io_enable(stdio_event, PA_IO_EVENT_OUTPUT);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_stream_peek(s, &data, &length);
 | 
					    if (pa_stream_peek(s, &data, &length) < 0) {
 | 
				
			||||||
 | 
					        fprintf(stderr, "pa_stream_peek() failed: %s\n", pa_strerror(pa_context_errno(context)));
 | 
				
			||||||
 | 
					        quit(1);
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    assert(data && length);
 | 
					    assert(data && length);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (buffer) {
 | 
					    if (buffer) {
 | 
				
			||||||
        fprintf(stderr, "Buffer overrun, dropping incoming data\n");
 | 
					        fprintf(stderr, "Buffer overrun, dropping incoming data\n");
 | 
				
			||||||
        pa_stream_drop(s);
 | 
					        if (pa_stream_drop(s) < 0) {
 | 
				
			||||||
 | 
					            fprintf(stderr, "pa_stream_drop() failed: %s\n", pa_strerror(pa_context_errno(context)));
 | 
				
			||||||
 | 
					            quit(1);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -159,15 +172,18 @@ static void context_state_callback(pa_context *c, void *userdata) {
 | 
				
			||||||
        case PA_CONTEXT_SETTING_NAME:
 | 
					        case PA_CONTEXT_SETTING_NAME:
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        case PA_CONTEXT_READY:
 | 
					        case PA_CONTEXT_READY: {
 | 
				
			||||||
 | 
					            int r;
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            assert(c && !stream);
 | 
					            assert(c && !stream);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (verbose)
 | 
					            if (verbose)
 | 
				
			||||||
                fprintf(stderr, "Connection established.\n");
 | 
					                fprintf(stderr, "Connection established.\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            stream = pa_stream_new(c, stream_name, &sample_spec, NULL);
 | 
					            if (!(stream = pa_stream_new(c, stream_name, &sample_spec, NULL))) {
 | 
				
			||||||
            assert(stream);
 | 
					                fprintf(stderr, "pa_stream_new() failed: %s\n", pa_strerror(pa_context_errno(c)));
 | 
				
			||||||
 | 
					                goto fail;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            pa_stream_set_state_callback(stream, stream_state_callback, NULL);
 | 
					            pa_stream_set_state_callback(stream, stream_state_callback, NULL);
 | 
				
			||||||
            pa_stream_set_write_callback(stream, stream_write_callback, NULL);
 | 
					            pa_stream_set_write_callback(stream, stream_write_callback, NULL);
 | 
				
			||||||
| 
						 | 
					@ -175,11 +191,20 @@ static void context_state_callback(pa_context *c, void *userdata) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (mode == PLAYBACK) {
 | 
					            if (mode == PLAYBACK) {
 | 
				
			||||||
                pa_cvolume cv;
 | 
					                pa_cvolume cv;
 | 
				
			||||||
                pa_stream_connect_playback(stream, device, NULL, 0, pa_cvolume_set(&cv, PA_CHANNELS_MAX, volume), NULL);
 | 
					                if ((r = pa_stream_connect_playback(stream, device, NULL, 0, pa_cvolume_set(&cv, sample_spec.channels, volume), NULL)) < 0) {
 | 
				
			||||||
            } else
 | 
					                    fprintf(stderr, "pa_stream_connect_playback() failed: %s\n", pa_strerror(pa_context_errno(c)));
 | 
				
			||||||
                pa_stream_connect_record(stream, device, NULL, 0);
 | 
					                    goto fail;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                    
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                if ((r = pa_stream_connect_record(stream, device, NULL, 0)) < 0) {
 | 
				
			||||||
 | 
					                    fprintf(stderr, "pa_stream_connect_record() failed: %s\n", pa_strerror(pa_context_errno(c)));
 | 
				
			||||||
 | 
					                    goto fail;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
                
 | 
					                
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
        case PA_CONTEXT_TERMINATED:
 | 
					        case PA_CONTEXT_TERMINATED:
 | 
				
			||||||
            quit(0);
 | 
					            quit(0);
 | 
				
			||||||
| 
						 | 
					@ -188,8 +213,14 @@ static void context_state_callback(pa_context *c, void *userdata) {
 | 
				
			||||||
        case PA_CONTEXT_FAILED:
 | 
					        case PA_CONTEXT_FAILED:
 | 
				
			||||||
        default:
 | 
					        default:
 | 
				
			||||||
            fprintf(stderr, "Connection failure: %s\n", pa_strerror(pa_context_errno(c)));
 | 
					            fprintf(stderr, "Connection failure: %s\n", pa_strerror(pa_context_errno(c)));
 | 
				
			||||||
            quit(1);
 | 
					            goto fail;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					fail:
 | 
				
			||||||
 | 
					    quit(1);
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Connection draining complete */
 | 
					/* Connection draining complete */
 | 
				
			||||||
| 
						 | 
					@ -216,8 +247,6 @@ static void stream_drain_complete(pa_stream*s, int success, void *userdata) {
 | 
				
			||||||
    if (!(o = pa_context_drain(context, context_drain_complete, NULL)))
 | 
					    if (!(o = pa_context_drain(context, context_drain_complete, NULL)))
 | 
				
			||||||
        pa_context_disconnect(context);
 | 
					        pa_context_disconnect(context);
 | 
				
			||||||
    else {
 | 
					    else {
 | 
				
			||||||
        pa_operation_unref(o);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (verbose)
 | 
					        if (verbose)
 | 
				
			||||||
            fprintf(stderr, "Draining connection to server.\n");
 | 
					            fprintf(stderr, "Draining connection to server.\n");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -241,9 +270,18 @@ static void stdin_callback(pa_mainloop_api*a, pa_io_event *e, int fd, pa_io_even
 | 
				
			||||||
    assert(buffer);
 | 
					    assert(buffer);
 | 
				
			||||||
    if ((r = read(fd, buffer, l)) <= 0) {
 | 
					    if ((r = read(fd, buffer, l)) <= 0) {
 | 
				
			||||||
        if (r == 0) {
 | 
					        if (r == 0) {
 | 
				
			||||||
 | 
					            pa_operation *o;
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
            if (verbose)
 | 
					            if (verbose)
 | 
				
			||||||
                fprintf(stderr, "Got EOF.\n");
 | 
					                fprintf(stderr, "Got EOF.\n");
 | 
				
			||||||
            pa_operation_unref(pa_stream_drain(stream, stream_drain_complete, NULL));
 | 
					            
 | 
				
			||||||
 | 
					            if (!(o = pa_stream_drain(stream, stream_drain_complete, NULL))) {
 | 
				
			||||||
 | 
					                fprintf(stderr, "pa_stream_drain(): %s\n", pa_strerror(pa_context_errno(context)));
 | 
				
			||||||
 | 
					                quit(1);
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            pa_operation_unref(o);
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            fprintf(stderr, "read() failed: %s\n", strerror(errno));
 | 
					            fprintf(stderr, "read() failed: %s\n", strerror(errno));
 | 
				
			||||||
            quit(1);
 | 
					            quit(1);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue