OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/audio/win/waveout_output_win.h" | 5 #include "media/audio/win/waveout_output_win.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <mmsystem.h> | 8 #include <mmsystem.h> |
9 #pragma comment(lib, "winmm.lib") | 9 #pragma comment(lib, "winmm.lib") |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
(...skipping 10 matching lines...) Expand all Loading... |
22 // thus it forces you to maintain state, which naturally is not exactly | 22 // thus it forces you to maintain state, which naturally is not exactly |
23 // synchronized to the actual device state. | 23 // synchronized to the actual device state. |
24 // - Some functions, like waveOutReset cannot be called in the callback thread | 24 // - Some functions, like waveOutReset cannot be called in the callback thread |
25 // or called in any random state because they deadlock. This results in a | 25 // or called in any random state because they deadlock. This results in a |
26 // non- instantaneous Stop() method. waveOutPrepareHeader seems to be in the | 26 // non- instantaneous Stop() method. waveOutPrepareHeader seems to be in the |
27 // same boat. | 27 // same boat. |
28 // - waveOutReset() will forcefully kill the _waveThread so it is important | 28 // - waveOutReset() will forcefully kill the _waveThread so it is important |
29 // to make sure we are not executing inside the audio source's OnMoreData() | 29 // to make sure we are not executing inside the audio source's OnMoreData() |
30 // or that we take locks inside WaveCallback() or QueueNextPacket(). | 30 // or that we take locks inside WaveCallback() or QueueNextPacket(). |
31 | 31 |
32 namespace { | |
33 // Sixty four MB is the maximum buffer size per AudioOutputStream. | 32 // Sixty four MB is the maximum buffer size per AudioOutputStream. |
34 const uint32 kMaxOpenBufferSize = 1024 * 1024 * 64; | 33 static const uint32 kMaxOpenBufferSize = 1024 * 1024 * 64; |
35 | 34 |
36 // Our sound buffers are allocated once and kept in a linked list using the | 35 // Our sound buffers are allocated once and kept in a linked list using the |
37 // the WAVEHDR::dwUser variable. The last buffer points to the first buffer. | 36 // the WAVEHDR::dwUser variable. The last buffer points to the first buffer. |
38 WAVEHDR* GetNextBuffer(WAVEHDR* current) { | 37 static WAVEHDR* GetNextBuffer(WAVEHDR* current) { |
39 return reinterpret_cast<WAVEHDR*>(current->dwUser); | 38 return reinterpret_cast<WAVEHDR*>(current->dwUser); |
40 } | 39 } |
41 | 40 |
42 } // namespace | |
43 | |
44 // See Also | 41 // See Also |
45 // http://www.thx.com/consumer/home-entertainment/home-theater/surround-sound-sp
eaker-set-up/ | 42 // http://www.thx.com/consumer/home-entertainment/home-theater/surround-sound-sp
eaker-set-up/ |
46 // http://en.wikipedia.org/wiki/Surround_sound | 43 // http://en.wikipedia.org/wiki/Surround_sound |
47 | 44 |
48 const int kMaxChannelsToMask = 8; | 45 static const int kMaxChannelsToMask = 8; |
49 const unsigned int kChannelsToMask[kMaxChannelsToMask + 1] = { | 46 static const unsigned int kChannelsToMask[kMaxChannelsToMask + 1] = { |
50 0, | 47 0, |
51 // 1 = Mono | 48 // 1 = Mono |
52 SPEAKER_FRONT_CENTER, | 49 SPEAKER_FRONT_CENTER, |
53 // 2 = Stereo | 50 // 2 = Stereo |
54 SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT, | 51 SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT, |
55 // 3 = Stereo + Center | 52 // 3 = Stereo + Center |
56 SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER, | 53 SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER, |
57 // 4 = Quad | 54 // 4 = Quad |
58 SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | | 55 SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | |
59 SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT, | 56 SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT, |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 // Time to send the buffer to the audio driver. Since we are reusing | 338 // Time to send the buffer to the audio driver. Since we are reusing |
342 // the same buffers we can get away without calling waveOutPrepareHeader. | 339 // the same buffers we can get away without calling waveOutPrepareHeader. |
343 MMRESULT result = ::waveOutWrite(hwo, buffer, sizeof(WAVEHDR)); | 340 MMRESULT result = ::waveOutWrite(hwo, buffer, sizeof(WAVEHDR)); |
344 if (result != MMSYSERR_NOERROR) | 341 if (result != MMSYSERR_NOERROR) |
345 obj->HandleError(result); | 342 obj->HandleError(result); |
346 | 343 |
347 obj->pending_bytes_ += buffer->dwBufferLength; | 344 obj->pending_bytes_ += buffer->dwBufferLength; |
348 | 345 |
349 } | 346 } |
350 } | 347 } |
OLD | NEW |