diff --git a/content/media/test/crashtests/495794-1.html b/content/media/test/crashtests/495794-1.html new file mode 100644 index 000000000000..e8777e709a37 --- /dev/null +++ b/content/media/test/crashtests/495794-1.html @@ -0,0 +1,7 @@ + + + + + + + diff --git a/content/media/test/crashtests/495794-1.ogg b/content/media/test/crashtests/495794-1.ogg new file mode 100644 index 000000000000..1c19a640612d Binary files /dev/null and b/content/media/test/crashtests/495794-1.ogg differ diff --git a/content/media/test/crashtests/crashtests.list b/content/media/test/crashtests/crashtests.list index 1325beb50479..1d16b8371494 100644 --- a/content/media/test/crashtests/crashtests.list +++ b/content/media/test/crashtests/crashtests.list @@ -1,2 +1,3 @@ load 468763-1.html load 474744-1.html +load 495794-1.html diff --git a/media/libsydneyaudio/README_MOZILLA b/media/libsydneyaudio/README_MOZILLA index 98a32cd25a15..0f6ea052b2dd 100644 --- a/media/libsydneyaudio/README_MOZILLA +++ b/media/libsydneyaudio/README_MOZILLA @@ -12,3 +12,6 @@ with pausing and resuming audio streams. include-CoreServices.patch is applied to include CoreServices headers on Mac OS X. Fixes a build failure on Mac OS X 10.6. b=492072 + +bug495794_closeAudio.patch fixes a crash when destroying the sa_stream_t after +a failed attempt to open the stream. diff --git a/media/libsydneyaudio/bug495794_closeAudio.patch b/media/libsydneyaudio/bug495794_closeAudio.patch new file mode 100644 index 000000000000..527f195503e7 --- /dev/null +++ b/media/libsydneyaudio/bug495794_closeAudio.patch @@ -0,0 +1,105 @@ +diff --git a/media/libsydneyaudio/src/sydney_audio_waveapi.c b/media/libsydneyaudio/src/sydney_audio_waveapi.c +--- a/media/libsydneyaudio/src/sydney_audio_waveapi.c ++++ b/media/libsydneyaudio/src/sydney_audio_waveapi.c +@@ -416,29 +416,34 @@ int openAudio(sa_stream_t *s) { + wfx.nBlockAlign = (wfx.wBitsPerSample * wfx.nChannels) >> 3; + wfx.nAvgBytesPerSec = wfx.nBlockAlign * wfx.nSamplesPerSec; + + supported = waveOutOpen(NULL, WAVE_MAPPER, &wfx, (DWORD_PTR)0, (DWORD_PTR)0, + WAVE_FORMAT_QUERY); + if (supported == MMSYSERR_NOERROR) { // audio device opened sucessfully + status = waveOutOpen((LPHWAVEOUT)&(s->hWaveOut), WAVE_MAPPER, &wfx, + (DWORD_PTR)waveOutProc, (DWORD_PTR)s, CALLBACK_FUNCTION); +- HANDLE_WAVE_ERROR(status, "opening audio device for playback"); +- printf("Audio device sucessfully opened\n"); ++ if (status != MMSYSERR_NOERROR) { ++ freeBlocks(s->waveBlocks); ++ s->waveBlocks = NULL; ++ HANDLE_WAVE_ERROR(status, "opening audio device for playback"); ++ } + } + else if (supported == WAVERR_BADFORMAT) { +- printf("Requested format not supported...\n"); +- // clean up the memory +- freeBlocks(s->waveBlocks); ++ printf("Requested format not supported.\n"); ++ // clean up the memory ++ freeBlocks(s->waveBlocks); ++ s->waveBlocks = NULL; + return SA_ERROR_NOT_SUPPORTED; + } + else { +- printf("Error opening default audio device. Exiting...\n"); +- // clean up the memory +- freeBlocks(s->waveBlocks); ++ printf("Error opening default audio device.\n"); ++ // clean up the memory ++ freeBlocks(s->waveBlocks); ++ s->waveBlocks = NULL; + return SA_ERROR_SYSTEM; + } + // create notification for data written to a device + s->callbackEvent = CreateEvent(0, FALSE, FALSE, 0); + // initialise critical section for operations on waveFreeBlockCound variable + InitializeCriticalSection(&(s->waveCriticalSection)); + + return SA_SUCCESS; +@@ -454,40 +459,43 @@ int closeAudio(sa_stream_t * s) { + result = SA_SUCCESS; + + // reseting audio device and flushing buffers + status = waveOutReset(s->hWaveOut); + if (status != MMSYSERR_NOERROR) { + result = getSAErrorCode(status); + } + +- /* wait for all blocks to complete */ +- while(s->waveFreeBlockCount < BLOCK_COUNT) { +- Sleep(10); ++ if (s->waveBlocks) { ++ /* wait for all blocks to complete */ ++ while(s->waveFreeBlockCount < BLOCK_COUNT) { ++ Sleep(10); ++ } ++ ++ /* unprepare any blocks that are still prepared */ ++ for(i = 0; i < s->waveFreeBlockCount; i++) { ++ if(s->waveBlocks[i].dwFlags & WHDR_PREPARED) { ++ status = waveOutUnprepareHeader(s->hWaveOut, &(s->waveBlocks[i]), sizeof(WAVEHDR)); ++ if (status != MMSYSERR_NOERROR) { ++ result = getSAErrorCode(status); ++ } ++ } ++ } ++ ++ freeBlocks(s->waveBlocks); ++ s->waveBlocks = NULL; + } + +- /* unprepare any blocks that are still prepared */ +- for(i = 0; i < s->waveFreeBlockCount; i++) { +- if(s->waveBlocks[i].dwFlags & WHDR_PREPARED) { +- status = waveOutUnprepareHeader(s->hWaveOut, &(s->waveBlocks[i]), sizeof(WAVEHDR)); +- if (status != MMSYSERR_NOERROR) { +- result = getSAErrorCode(status); +- } +- } +- } +- +- freeBlocks(s->waveBlocks); + status = waveOutClose(s->hWaveOut); + if (status != MMSYSERR_NOERROR) { + result = getSAErrorCode(status); + } + + DeleteCriticalSection(&(s->waveCriticalSection)); + CloseHandle(s->callbackEvent); +- printf("[audio] audio resources cleanup completed\n"); + + return result; + } + /** + * \brief - writes PCM audio samples to audio device + * \param s - valid handle to opened sydney stream + * \param data - pointer to memory storing audio samples to be played + * \param nsamples - number of samples in the memory pointed by previous parameter diff --git a/media/libsydneyaudio/src/sydney_audio_waveapi.c b/media/libsydneyaudio/src/sydney_audio_waveapi.c index 5670183c70bc..d23615487325 100644 --- a/media/libsydneyaudio/src/sydney_audio_waveapi.c +++ b/media/libsydneyaudio/src/sydney_audio_waveapi.c @@ -421,19 +421,24 @@ int openAudio(sa_stream_t *s) { if (supported == MMSYSERR_NOERROR) { // audio device opened sucessfully status = waveOutOpen((LPHWAVEOUT)&(s->hWaveOut), WAVE_MAPPER, &wfx, (DWORD_PTR)waveOutProc, (DWORD_PTR)s, CALLBACK_FUNCTION); - HANDLE_WAVE_ERROR(status, "opening audio device for playback"); - printf("Audio device sucessfully opened\n"); + if (status != MMSYSERR_NOERROR) { + freeBlocks(s->waveBlocks); + s->waveBlocks = NULL; + HANDLE_WAVE_ERROR(status, "opening audio device for playback"); + } } else if (supported == WAVERR_BADFORMAT) { - printf("Requested format not supported...\n"); - // clean up the memory - freeBlocks(s->waveBlocks); + printf("Requested format not supported.\n"); + // clean up the memory + freeBlocks(s->waveBlocks); + s->waveBlocks = NULL; return SA_ERROR_NOT_SUPPORTED; } else { - printf("Error opening default audio device. Exiting...\n"); - // clean up the memory - freeBlocks(s->waveBlocks); + printf("Error opening default audio device.\n"); + // clean up the memory + freeBlocks(s->waveBlocks); + s->waveBlocks = NULL; return SA_ERROR_SYSTEM; } // create notification for data written to a device @@ -459,22 +464,26 @@ int closeAudio(sa_stream_t * s) { result = getSAErrorCode(status); } - /* wait for all blocks to complete */ - while(s->waveFreeBlockCount < BLOCK_COUNT) { - Sleep(10); + if (s->waveBlocks) { + /* wait for all blocks to complete */ + while(s->waveFreeBlockCount < BLOCK_COUNT) { + Sleep(10); + } + + /* unprepare any blocks that are still prepared */ + for(i = 0; i < s->waveFreeBlockCount; i++) { + if(s->waveBlocks[i].dwFlags & WHDR_PREPARED) { + status = waveOutUnprepareHeader(s->hWaveOut, &(s->waveBlocks[i]), sizeof(WAVEHDR)); + if (status != MMSYSERR_NOERROR) { + result = getSAErrorCode(status); + } + } + } + + freeBlocks(s->waveBlocks); + s->waveBlocks = NULL; } - /* unprepare any blocks that are still prepared */ - for(i = 0; i < s->waveFreeBlockCount; i++) { - if(s->waveBlocks[i].dwFlags & WHDR_PREPARED) { - status = waveOutUnprepareHeader(s->hWaveOut, &(s->waveBlocks[i]), sizeof(WAVEHDR)); - if (status != MMSYSERR_NOERROR) { - result = getSAErrorCode(status); - } - } - } - - freeBlocks(s->waveBlocks); status = waveOutClose(s->hWaveOut); if (status != MMSYSERR_NOERROR) { result = getSAErrorCode(status); @@ -482,7 +491,6 @@ int closeAudio(sa_stream_t * s) { DeleteCriticalSection(&(s->waveCriticalSection)); CloseHandle(s->callbackEvent); - printf("[audio] audio resources cleanup completed\n"); return result; } diff --git a/media/libsydneyaudio/update.sh b/media/libsydneyaudio/update.sh index d381585ac36c..029313174bab 100644 --- a/media/libsydneyaudio/update.sh +++ b/media/libsydneyaudio/update.sh @@ -7,3 +7,4 @@ cp $1/src/*.c src/ cp $1/AUTHORS ./AUTHORS patch -p4