Ticket #5313: 5313-v1.patch
File 5313-v1.patch, 4.6 KB (added by , 16 years ago) |
---|
-
libs/libmyth/audiooutputbase.h
74 74 virtual void Drain(void); 75 75 76 76 virtual int GetAudiotime(void); 77 virtual int GetAudioBufferedTime(void) const; 77 78 78 79 // Send output events showing current progress 79 80 virtual void Status(void); -
libs/libmyth/audiooutputalsa.cpp
89 89 } 90 90 else 91 91 { 92 fragment_size = 6144; // nicely divisible by 2,4,6,8 channels @ 16-bits 93 buffer_time = 500000; // 500 ms 94 period_time = buffer_time / 4; // 4 interrupts per buffer 92 fragment_size = 1536 * audio_channels * audio_bits / 8; 93 period_time = 25000; // in usec, interrupt period time 94 // in usec, for driver buffer alloc (64k max) 95 buffer_time = period_time * 16; 95 96 } 96 97 97 98 if (audio_bits == 8) -
libs/libmyth/audiooutputbase.cpp
110 110 void AudioOutputBase::SetStretchFactorLocked(float laudio_stretchfactor) 111 111 { 112 112 effdspstretched = (int)((float)effdsp / laudio_stretchfactor); 113 if ( audio_stretchfactor != laudio_stretchfactor)113 if ((audio_stretchfactor != laudio_stretchfactor) || !pSoundStretch) 114 114 { 115 115 audio_stretchfactor = laudio_stretchfactor; 116 116 if (pSoundStretch) … … 363 363 364 364 if (redo_stretch) 365 365 { 366 float laudio_stretchfactor = audio_stretchfactor;367 366 delete pSoundStretch; 368 367 pSoundStretch = NULL; 369 audio_stretchfactor = 0.0f; 370 SetStretchFactorLocked(laudio_stretchfactor); 368 SetStretchFactorLocked(audio_stretchfactor); 371 369 } 372 370 else 373 371 { … … 678 676 pthread_mutex_unlock(&audio_buflock); 679 677 } 680 678 679 int AudioOutputBase::GetAudioBufferedTime(void) const 680 { 681 return audbuf_timecode - GetAudiotime(); 682 } 683 681 684 bool AudioOutputBase::AddSamples(char *buffers[], int samples, 682 685 long long timecode) 683 686 { … … 699 702 len += (pSoundStretch->numUnprocessedSamples() + 700 703 (int)(pSoundStretch->numSamples()/audio_stretchfactor))*abps; 701 704 702 if (((len > afree) || ((audbuf_timecode - GetAudiotime()) > 2000))&& !blocking)705 if (((len > afree) && !blocking) 703 706 { 704 707 VERBOSE(VB_AUDIO|VB_TIMESTAMP, LOC + QString( 705 708 "AddSamples FAILED bytes=%1, used=%2, free=%3, timecode=%4") … … 768 771 (int)(pSoundStretch->numSamples()/audio_stretchfactor))*abps; 769 772 } 770 773 771 if (((len > afree) || (audiotime && ((audbuf_timecode - GetAudiotime()) > 2000)))&& !blocking)774 if (((len > afree) && !blocking) 772 775 { 773 776 VERBOSE(VB_AUDIO|VB_TIMESTAMP, LOC + QString( 774 777 "AddSamples FAILED bytes=%1, used=%2, free=%3, timecode=%4") … … 958 961 if (audio_bits == 16) 959 962 audiobuffer[org_waud++] = mybuf[chan][itemp+1]; 960 963 961 if (org_waud >= AUDBUFSIZE) 962 org_waud -= AUDBUFSIZE; 964 org_waud %= AUDBUFSIZE; 963 965 } 964 966 } 965 967 } … … 1034 1036 memcpy(audiobuffer + org_waud, ob, amount); 1035 1037 1036 1038 bdiff = AUDBUFSIZE - amount; 1037 org_waud += amount;1039 org_waud += (org_waud + amount) % AUDBUFSIZE; 1038 1040 } 1039 1041 } 1040 1042 else … … 1061 1063 } 1062 1064 else 1063 1065 { 1064 org_waud += nSamples * audio_bytes_per_sample; 1066 int bufsz = nSamples * audio_bytes_per_sample; 1067 org_waud = (org_waud + bufsz) % AUDBUFSIZE; 1065 1068 nSamplesToEnd -= nSamples; 1066 1069 } 1067 1070 -
libs/libmyth/audiooutput.h
62 62 63 63 virtual int GetAudiotime(void) = 0; 64 64 65 /// report amount of audio buffered in milliseconds. 66 virtual int GetAudioBufferedTime(void) const { return 0; } 67 65 68 virtual void SetSourceBitrate(int ) { } 66 69 67 70 QString GetError(void) const { return lastError; }